idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
42,000 | public function create_form ( $ type ) { if ( isset ( $ _POST [ 'option_page' ] ) && 'github_updater_install' === $ _POST [ 'option_page' ] ) { return ; } $ this -> register_settings ( $ type ) ; ?> <form method="post"> <?php settings_fields ( 'github_updater_install' ) ; do_settings_sections ( 'github_updater_insta... | Create Install Plugin or Install Theme page . |
42,001 | public function register_settings ( $ type ) { $ repo_type = null ; if ( 'plugin' === $ type ) { $ repo_type = esc_html__ ( 'Plugin' , 'github-updater' ) ; } if ( 'theme' === $ type ) { $ repo_type = esc_html__ ( 'Theme' , 'github-updater' ) ; } register_setting ( 'github_updater_install' , 'github_updater_install_' . ... | Add settings sections . |
42,002 | public function install_api ( ) { ?> <label for="github_updater_api"> <select id="github_updater_api" name="github_updater_api"> <?php foreach ( self :: $ git_servers as $ key => $ value ) : ?> <?php if ( self :: $ installed_apis [ $ key . '_api' ] ) : ?> <option value=" <?php esc_attr_e ( $ key ) ; ?> " <?php s... | API setting . |
42,003 | public function install_theme_complete_actions ( $ install_actions , $ api , $ theme_info ) { if ( isset ( $ install_actions [ 'preview' ] ) ) { unset ( $ install_actions [ 'preview' ] ) ; } $ stylesheet = self :: $ install [ 'repo' ] ; $ activate_link = add_query_arg ( [ 'action' => 'activate' , 'stylesheet' => rawurl... | Fix activation links after theme installation no method to get proper theme name . |
42,004 | public function get_repo_cache ( $ repo = false ) { if ( ! $ repo ) { $ repo = isset ( $ this -> type -> slug ) ? $ this -> type -> slug : 'ghu' ; } $ cache_key = 'ghu-' . md5 ( $ repo ) ; $ cache = get_site_option ( $ cache_key ) ; if ( empty ( $ cache [ 'timeout' ] ) || time ( ) > $ cache [ 'timeout' ] ) { return fal... | Returns repo cached data . |
42,005 | public function set_repo_cache ( $ id , $ response , $ repo = false , $ timeout = false ) { if ( is_wp_error ( $ response ) ) { return false ; } $ hours = $ this -> get_class_vars ( 'API' , 'hours' ) ; if ( ! $ repo ) { $ repo = isset ( $ this -> type -> slug ) ? $ this -> type -> slug : 'ghu' ; } $ cache_key = 'ghu-' ... | Sets repo data for cache in site option . |
42,006 | public function get_class_vars ( $ class_name , $ var ) { $ class = Singleton :: get_instance ( $ class_name , $ this ) ; $ reflection_obj = new \ ReflectionObject ( $ class ) ; if ( ! $ reflection_obj -> hasProperty ( $ var ) ) { return false ; } $ property = $ reflection_obj -> getProperty ( $ var ) ; $ property -> s... | Getter for class variables . |
42,007 | public function can_update_repo ( $ type ) { $ wp_version = get_bloginfo ( 'version' ) ; $ wp_version_ok = ! empty ( $ type -> requires ) ? version_compare ( $ wp_version , $ type -> requires , '>=' ) : true ; $ php_version_ok = ! empty ( $ type -> requires_php ) ? version_compare ( phpversion ( ) , $ type -> requires_... | Function to check if plugin or theme object is able to be updated . |
42,008 | public function delete_all_cached_data ( ) { global $ wpdb ; $ table = is_multisite ( ) ? $ wpdb -> base_prefix . 'sitemeta' : $ wpdb -> base_prefix . 'options' ; $ column = is_multisite ( ) ? 'meta_key' : 'option_name' ; $ delete_string = 'DELETE FROM ' . $ table . ' WHERE ' . $ column . ' LIKE %s LIMIT 1000' ; $ wpdb... | Delete all ghu - prefixed data from options table . |
42,009 | public function override_dot_org ( $ type , $ repo ) { $ icon = is_array ( $ repo ) ; $ repo = is_array ( $ repo ) ? ( object ) $ repo : $ repo ; $ dot_org_master = ! $ icon ? $ repo -> dot_org && 'master' === $ repo -> branch : true ; $ transient_key = 'plugin' === $ type ? $ repo -> file : null ; $ transient_key = 't... | Do we override dot org updates? |
42,010 | public function sanitize ( $ input ) { $ new_input = [ ] ; foreach ( array_keys ( ( array ) $ input ) as $ id ) { $ new_input [ sanitize_file_name ( $ id ) ] = sanitize_text_field ( $ input [ $ id ] ) ; } return $ new_input ; } | Sanitize each setting field as needed . |
42,011 | public function get_running_git_servers ( ) { $ plugins = Singleton :: get_instance ( 'Plugin' , $ this ) -> get_plugin_configs ( ) ; $ themes = Singleton :: get_instance ( 'Theme' , $ this ) -> get_theme_configs ( ) ; $ repos = array_merge ( $ plugins , $ themes ) ; $ gits = array_map ( function ( $ e ) { if ( ! empty... | Return an array of the running git servers . |
42,012 | protected function parse_header_uri ( $ repo_header ) { $ header_parts = parse_url ( $ repo_header ) ; $ header_path = pathinfo ( $ header_parts [ 'path' ] ) ; $ header [ 'original' ] = $ repo_header ; $ header [ 'scheme' ] = isset ( $ header_parts [ 'scheme' ] ) ? $ header_parts [ 'scheme' ] : null ; $ header [ 'host'... | Parse URI param returning array of parts . |
42,013 | public function get_file_headers ( $ contents , $ type ) { $ all_headers = [ ] ; $ default_plugin_headers = [ 'Name' => 'Plugin Name' , 'PluginURI' => 'Plugin URI' , 'Version' => 'Version' , 'Description' => 'Description' , 'Author' => 'Author' , 'AuthorURI' => 'Author URI' , 'TextDomain' => 'Text Domain' , 'DomainPath... | Take remote file contents as string or array and parse and reduce headers . |
42,014 | private function is_repo_private ( $ url ) { $ slug = isset ( $ _REQUEST [ 'rollback' ] , $ _REQUEST [ 'plugin' ] ) ? dirname ( $ _REQUEST [ 'plugin' ] ) : false ; $ slug = isset ( $ _REQUEST [ 'rollback' ] , $ _REQUEST [ 'theme' ] ) ? $ _REQUEST [ 'theme' ] : $ slug ; $ slug = isset ( $ _REQUEST [ 'slug' ] ) ? $ _REQU... | Determine if repo is private . |
42,015 | public function http_release_asset_auth ( $ args , $ url ) { $ arr_url = parse_url ( $ url ) ; if ( isset ( $ arr_url [ 'host' ] ) && 'bbuseruploads.s3.amazonaws.com' === $ arr_url [ 'host' ] ) { unset ( $ args [ 'headers' ] [ 'Authorization' ] ) ; } return $ args ; } | Removes Basic Authentication header for Bitbucket Release Assets . Storage in AmazonS3 buckets uses Query String Request Authentication Alternative . |
42,016 | public function upgrader_pre_download ( $ reply , $ package , $ class ) { if ( $ class instanceof \ Plugin_Upgrader && property_exists ( $ class -> skin , 'plugin_info' ) ) { $ headers = $ class -> skin -> plugin_info ; foreach ( self :: $ basic_auth_required as $ git_server ) { $ ghu_header = $ headers [ $ git_server ... | Loads authentication hooks when updating from update - core . php . |
42,017 | public function add_install_settings_fields ( $ type ) { if ( ( empty ( static :: $ options [ 'bitbucket_username' ] ) || empty ( static :: $ options [ 'bitbucket_password' ] ) ) || ( empty ( static :: $ options [ 'bitbucket_server_username' ] ) || empty ( static :: $ options [ 'bitbucket_server_password' ] ) ) ) { add... | Add remote install settings fields . |
42,018 | public function run ( ) { add_action ( 'init' , function ( ) { load_plugin_textdomain ( 'github-updater' ) ; } ) ; define ( 'GITHUB_UPDATER_DIR' , $ this -> dir ) ; require_once $ this -> dir . '/vendor/autoload.php' ; register_activation_hook ( $ this -> file , array ( new Init ( ) , 'rename_on_activation' ) ) ; ( new... | Run the bootstrap . |
42,019 | public function add_endpoints ( $ git , $ endpoint ) { switch ( self :: $ method ) { case 'meta' : case 'translation' : case 'branches' : break ; case 'file' : case 'readme' : $ endpoint = add_query_arg ( 'at' , $ git -> type -> branch , $ endpoint ) ; break ; case 'changes' : $ endpoint = add_query_arg ( [ 'at' => $ g... | Create Bitbucket Server API endpoints . |
42,020 | protected function bbserver_recombine_response ( $ response ) { if ( $ this -> validate_response ( $ response ) ) { return $ response ; } $ remote_info_file = '' ; if ( isset ( $ response -> lines ) ) { foreach ( ( array ) $ response -> lines as $ line ) { $ remote_info_file .= $ line -> text . "\n" ; } } return $ remo... | Combines separate text lines from API response into one string with \ n line endings . Code relying on raw text can now parse it . |
42,021 | public function add_endpoints ( $ git , $ endpoint ) { switch ( $ git :: $ method ) { case 'file' : case 'readme' : case 'meta' : case 'tags' : case 'changes' : case 'translation' : case 'download_link' : break ; case 'branches' : $ endpoint = add_query_arg ( 'per_page' , '100' , $ endpoint ) ; break ; default : break ... | Create Gitea API endpoints . |
42,022 | public function cache ( $ args ) { list ( $ action ) = $ args ; if ( 'delete' === $ action ) { Singleton :: get_instance ( 'CLI_Common' , $ this ) -> delete_all_cached_data ( ) ; WP_CLI :: success ( 'GitHub Updater cache has been cleared.' ) ; } else { WP_CLI :: error ( sprintf ( 'Incorrect command syntax, see %s for p... | Clear GitHub Updater cache . |
42,023 | public function reset_api_key ( ) { delete_site_option ( 'github_updater_api_key' ) ; Singleton :: get_instance ( 'Remote_Management' , $ this ) -> ensure_api_key_is_set ( ) ; $ api_key = get_site_option ( 'github_updater_api_key' ) ; $ api_url = add_query_arg ( [ 'action' => 'github-updater-update' , 'key' => $ api_ke... | Reset GitHub Updater REST API key . |
42,024 | public function run ( ) { $ options = $ this -> get_class_vars ( 'Base' , 'options' ) ; $ db_version = isset ( $ options [ 'db_version' ] ) ? ( int ) $ options [ 'db_version' ] : 6000 ; if ( $ db_version === $ this -> db_version ) { return ; } switch ( $ db_version ) { case $ db_version < $ this -> db_version : $ this ... | Run update check against db_version . |
42,025 | protected function set_installed_apis ( ) { if ( file_exists ( __DIR__ . '/API/Bitbucket_API.php' ) ) { self :: $ installed_apis [ 'bitbucket_api' ] = true ; self :: $ git_servers [ 'bitbucket' ] = 'Bitbucket' ; } else { self :: $ installed_apis [ 'bitbucket_api' ] = false ; } self :: $ installed_apis [ 'bitbucket_serv... | Set boolean for installed API classes . |
42,026 | public function load ( ) { if ( ! apply_filters ( 'github_updater_hide_settings' , false ) ) { Singleton :: get_instance ( 'Settings' , $ this ) -> run ( ) ; } if ( ! Singleton :: get_instance ( 'Init' , $ this ) -> can_update ( ) ) { return false ; } $ upgrade = new GHU_Upgrade ( ) ; $ upgrade -> run ( ) ; add_action ... | Load Plugin Theme and Settings with correct capabiltiies and on selective admin pages . |
42,027 | public function background_update ( ) { add_action ( 'wp_update_plugins' , [ $ this , 'get_meta_plugins' ] ) ; add_action ( 'wp_update_themes' , [ $ this , 'get_meta_themes' ] ) ; add_action ( 'ghu_get_remote_plugin' , [ $ this , 'run_cron_batch' ] , 10 , 1 ) ; add_action ( 'ghu_get_remote_theme' , [ $ this , 'run_cron... | Run background processes . Piggyback on built - in update function to get metadata . Set update transients for remote management . |
42,028 | public function get_remote_repo_meta ( $ repo ) { $ file = 'style.css' ; if ( false !== stripos ( $ repo -> type , 'plugin' ) ) { $ file = basename ( $ repo -> file ) ; } $ repo_api = Singleton :: get_instance ( 'API' , $ this ) -> get_repo_api ( $ repo -> git , $ repo ) ; if ( null === $ repo_api ) { return false ; } ... | Get remote repo meta data for plugins or themes . Calls remote APIs for data . |
42,029 | protected function get_changelog_filename ( $ repo ) { $ changelogs = [ 'CHANGES.md' , 'CHANGELOG.md' , 'changes.md' , 'changelog.md' ] ; $ changes = null ; $ local_files = null ; if ( is_dir ( $ repo -> local_path ) ) { $ local_files = scandir ( $ repo -> local_path , 0 ) ; } $ changes = array_intersect ( ( array ) $ ... | Get filename of changelog and return . |
42,030 | public function remove_hooks ( $ repo_api ) { remove_filter ( 'extra_theme_headers' , [ $ this , 'add_headers' ] ) ; remove_filter ( 'extra_plugin_headers' , [ $ this , 'add_headers' ] ) ; if ( $ repo_api instanceof Bitbucket_API ) { $ this -> remove_authentication_hooks ( ) ; } } | Remove hooks after use . |
42,031 | public function is_duplicate_wp_cron_event ( $ event ) { $ cron = _get_cron_array ( ) ; foreach ( $ cron as $ timestamp => $ cronhooks ) { if ( key ( $ cronhooks ) === $ event ) { $ this -> is_cron_overdue ( $ cron , $ timestamp ) ; return true ; } } return false ; } | Checks if dupicate wp - cron event exists . |
42,032 | public function is_cron_overdue ( $ cron , $ timestamp ) { $ overdue = ( ( time ( ) - $ timestamp ) / HOUR_IN_SECONDS ) > 24 ; if ( $ overdue ) { $ error_msg = esc_html__ ( 'There may be a problem with WP-Cron. A GitHub Updater WP-Cron event is overdue.' , 'github-updater' ) ; $ error = new \ WP_Error ( 'github_updater... | Check to see if wp - cron event is overdue by 24 hours and report error message . |
42,033 | public function upgrader_source_selection ( $ source , $ remote_source , $ upgrader , $ hook_extra = null ) { global $ wp_filesystem ; $ slug = null ; $ repo = null ; $ new_source = null ; $ upgrader_object = null ; if ( $ upgrader instanceof \ Plugin_Upgrader ) { $ upgrader_object = Singleton :: get_instance ( 'Plugin... | Used for renaming of sources to ensure correct directory name . |
42,034 | private function fix_gitlab_release_asset_directory ( $ new_source , $ remote_source , $ upgrader_object , $ slug ) { if ( ( isset ( $ upgrader_object -> config [ $ slug ] -> release_asset ) && $ upgrader_object -> config [ $ slug ] -> release_asset ) && ! empty ( $ upgrader_object -> config [ $ slug ] -> ci_job ) ) { ... | Renaming if using a GitLab Release Asset . It has a different download directory structure . |
42,035 | protected function set_rollback_transient ( $ type , $ repo , $ set_transient = false ) { $ repo_api = Singleton :: get_instance ( 'API' , $ this ) -> get_repo_api ( $ repo -> git , $ repo ) ; $ this -> tag = isset ( $ _GET [ 'rollback' ] ) ? $ _GET [ 'rollback' ] : false ; $ slug = 'plugin' === $ type ? $ repo -> file... | Update transient for rollback or branch switch . |
42,036 | protected function get_repo_parts ( $ repo , $ type ) { $ arr [ 'bool' ] = false ; $ pattern = '/' . strtolower ( $ repo ) . '_/' ; $ type = preg_replace ( $ pattern , '' , $ type ) ; $ repo_types = [ 'GitHub' => 'github_' . $ type , 'Bitbucket' => 'bitbucket_' . $ type , 'GitLab' => 'gitlab_' . $ type , 'Gitea' => 'gi... | Create repo parts . |
42,037 | protected function update_row_enclosure ( $ repo_name , $ type , $ branch_switcher = false ) { global $ wp_version ; $ wp_list_table = _get_list_table ( 'WP_Plugins_List_Table' ) ; $ repo_base = $ repo_name ; $ shiny_classes = ' notice inline notice-warning notice-alt' ; if ( 'plugin' === $ type ) { $ repo_base = dirna... | Return correct update row opening and closing tags for Shiny Updates . |
42,038 | protected function make_branch_switch_row ( $ data ) { $ rollback = empty ( $ this -> config [ $ data [ 'slug' ] ] -> rollback ) ? [ ] : $ this -> config [ $ data [ 'slug' ] ] -> rollback ; printf ( esc_html__ ( 'Current branch is `%1$s`, try %2$sanother version%3$s' , 'github-updater' ) , $ data [ 'branch' ] , '<a hre... | Make branch switch row . |
42,039 | protected function get_update_url ( $ type , $ action , $ repo_name ) { $ update_url = esc_attr ( add_query_arg ( [ 'action' => $ action , $ type => rawurlencode ( $ repo_name ) , ] , self_admin_url ( 'update.php' ) ) ) ; return $ update_url ; } | Generate update URL . |
42,040 | protected function parse_extra_headers ( $ header , $ headers , $ header_parts , $ repo_parts ) { $ hosted_domains = [ 'github.com' , 'bitbucket.org' , 'gitlab.com' ] ; $ theme = null ; $ header [ 'enterprise_uri' ] = null ; $ header [ 'enterprise_api' ] = null ; $ header [ 'languages' ] = null ; $ header [ 'ci_job' ] ... | Parse Enterprise Languages Release Asset and CI Job headers for plugins and themes . |
42,041 | protected function parse_markdown ( $ text ) { static $ markdown = null ; if ( null === $ markdown ) { $ markdown = new Parsedown ( ) ; } return $ markdown -> text ( $ text ) ; } | Parse text into markdown . |
42,042 | public function parse_data ( ) { $ data = [ ] ; foreach ( get_object_vars ( $ this ) as $ key => $ value ) { $ data [ $ key ] = 'contributors' === $ key ? $ this -> create_contributors ( $ value ) : $ value ; } $ data = $ this -> faq_as_h4 ( $ data ) ; $ data = $ this -> readme_section_as_h4 ( 'changelog' , $ data ) ; ... | Return parsed readme . txt as array . |
42,043 | private function create_contributors ( $ users ) { global $ wp_version ; $ contributors = [ ] ; foreach ( ( array ) $ users as $ contributor ) { $ contributors [ $ contributor ] [ 'display_name' ] = $ contributor ; $ contributors [ $ contributor ] [ 'profile' ] = '//profiles.wordpress.org/' . $ contributor ; $ contribu... | Create contributor data . |
42,044 | public function faq_as_h4 ( $ data ) { if ( empty ( $ data [ 'faq' ] ) ) { return $ data ; } unset ( $ data [ 'sections' ] [ 'faq' ] ) ; $ data [ 'sections' ] [ 'faq' ] = '' ; foreach ( $ data [ 'faq' ] as $ question => $ answer ) { $ data [ 'sections' ] [ 'faq' ] .= "<h4>{$question}</h4>\n{$answer}\n" ; } return $ dat... | Converts FAQ from dictionary list to h4 style . |
42,045 | public function readme_section_as_h4 ( $ section , $ data ) { if ( empty ( $ data [ 'sections' ] [ $ section ] ) || false !== strpos ( $ data [ 'sections' ] [ $ section ] , '<h4>' ) ) { return $ data ; } $ pattern = '~<p>=(.*)=</p>~' ; $ replace = '<h4>$1</h4>' ; $ data [ 'sections' ] [ $ section ] = preg_replace ( $ p... | Converts wp . org readme section items to h4 style . |
42,046 | public function feedback ( $ string ) { if ( isset ( $ this -> upgrader -> strings [ $ string ] ) ) { $ string = $ this -> upgrader -> strings [ $ string ] ; } if ( false !== strpos ( $ string , '%' ) ) { $ args = func_get_args ( ) ; $ args = array_splice ( $ args , 1 ) ; if ( $ args ) { $ args = array_map ( 'strip_tag... | Overrides the feedback method . Adds the feedback string to the messages array . |
42,047 | public function plugin_branch_switcher ( $ plugin_file , $ plugin_data ) { if ( empty ( static :: $ options [ 'branch_switch' ] ) ) { return false ; } $ enclosure = $ this -> update_row_enclosure ( $ plugin_file , 'plugin' , true ) ; $ plugin = $ this -> get_repo_slugs ( dirname ( $ plugin_file ) ) ; $ nonced_update_ur... | Add branch switch row to plugins page . |
42,048 | public function plugin_row_meta ( $ links , $ file ) { $ regex_pattern = '/<a href="(.*)">(.*)<\/a>/' ; $ repo = dirname ( $ file ) ; if ( ! isset ( $ links [ 2 ] ) ) { return $ links ; } preg_match ( $ regex_pattern , $ links [ 2 ] , $ matches ) ; if ( array_key_exists ( $ repo , $ this -> config ) ) { if ( null !== $... | Add View details link to plugins page . |
42,049 | public function plugins_api ( $ false , $ action , $ response ) { if ( ! ( 'plugin_information' === $ action ) ) { return $ false ; } $ plugin = isset ( $ this -> config [ $ response -> slug ] ) ? $ this -> config [ $ response -> slug ] : false ; if ( $ this -> waiting_for_background_update ( $ plugin ) ) { return $ fa... | Put changelog in plugins_api return WP . org data as appropriate |
42,050 | public function update_site_transient ( $ transient ) { foreach ( ( array ) $ this -> config as $ plugin ) { if ( $ this -> can_update_repo ( $ plugin ) ) { $ response = [ 'slug' => $ plugin -> slug , 'plugin' => $ plugin -> file , 'new_version' => $ plugin -> remote_version , 'url' => $ plugin -> uri , 'package' => $ ... | Hook into site_transient_update_plugins to update from GitHub . |
42,051 | public static function ratelimit_reset ( $ response , $ repo ) { if ( isset ( $ response [ 'headers' ] [ 'x-ratelimit-reset' ] ) ) { $ reset = ( int ) $ response [ 'headers' ] [ 'x-ratelimit-reset' ] ; $ wait = date ( 'i' , $ reset - time ( ) ) ; static :: $ error_code [ $ repo ] = array_merge ( static :: $ error_code ... | Calculate and store time until rate limit reset . |
42,052 | public function add_settings ( $ auth_required ) { add_settings_section ( 'github_access_token' , esc_html__ ( 'GitHub Personal Access Token' , 'github-updater' ) , [ $ this , 'print_section_github_access_token' ] , 'github_updater_github_install_settings' ) ; add_settings_field ( 'github_access_token' , esc_html__ ( '... | Add settings for GitHub Personal Access Token . |
42,053 | public function save_settings ( $ post_data ) { if ( isset ( $ post_data [ 'option_page' ] ) && 'github_updater_remote_management' === $ post_data [ 'option_page' ] ) { $ options = isset ( $ post_data [ 'github_updater_remote_management' ] ) ? $ post_data [ 'github_updater_remote_management' ] : [ ] ; update_site_optio... | Save Remote Management settings . |
42,054 | public function add_settings_tabs ( ) { $ install_tabs = [ 'github_updater_remote_management' => esc_html__ ( 'Remote Management' , 'github-updater' ) ] ; add_filter ( 'github_updater_add_settings_tabs' , function ( $ tabs ) use ( $ install_tabs ) { return array_merge ( $ tabs , $ install_tabs ) ; } ) ; add_filter ( 'g... | Adds Remote Management tab to Settings page . |
42,055 | public function remote_management_page_init ( ) { register_setting ( 'github_updater_remote_management' , 'github_updater_remote_settings' , [ $ this , 'sanitize' ] ) ; add_settings_section ( 'remote_management' , esc_html__ ( 'Remote Management' , 'github-updater' ) , [ $ this , 'print_section_remote_management' ] , '... | Settings for Remote Management . |
42,056 | public function print_section_remote_management ( ) { if ( empty ( self :: $ api_key ) ) { $ this -> load_options ( ) ; } $ api_url = add_query_arg ( [ 'action' => 'github-updater-update' , 'key' => self :: $ api_key , ] , admin_url ( 'admin-ajax.php' ) ) ; ?> <p> <?php printf ( wp_kses_post ( __ ( 'Please refer to ... | Print the Remote Management text . |
42,057 | public function token_callback_checkbox_remote ( $ args ) { $ checked = isset ( self :: $ options_remote [ $ args [ 'id' ] ] ) ? self :: $ options_remote [ $ args [ 'id' ] ] : null ; ?> <label for=" <?php esc_attr_e ( $ args [ 'id' ] ) ; ?> "> <input type="checkbox" id=" <?php esc_attr_e ( $ args [ 'id' ] ) ; ?> " na... | Get the settings option array and print one of its values . For remote management settings . |
42,058 | public function reset_api_key ( ) { if ( isset ( $ _REQUEST [ 'tab' ] , $ _REQUEST [ 'github_updater_reset_api_key' ] ) && 'github_updater_remote_management' === $ _REQUEST [ 'tab' ] ) { $ _POST = $ _REQUEST ; $ _POST [ '_wp_http_referer' ] = $ _SERVER [ 'HTTP_REFERER' ] ; delete_site_option ( 'github_updater_api_key' ... | Reset RESTful API key . Deleting site option will cause it to be re - created . |
42,059 | public function set_update_transients ( ) { if ( empty ( self :: $ options_remote ) ) { return ; } $ plugin = Singleton :: get_instance ( 'Plugin' , $ this ) ; $ theme = Singleton :: get_instance ( 'Theme' , $ this ) ; add_filter ( 'github_updater_add_admin_pages' , [ $ this , 'extra_admin_pages' ] ) ; add_filter ( 'si... | Set site transients for update_plugins and update_themes for remote management . |
42,060 | public function detachRoles ( $ roles = null ) { if ( ! $ roles ) $ roles = $ this -> roles ( ) -> get ( ) ; foreach ( $ roles as $ role ) { $ this -> detachRole ( $ role ) ; } } | Detach multiple roles from a user |
42,061 | public function scopeWithRole ( $ query , $ role ) { return $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ role ) { $ query -> where ( 'name' , $ role ) ; } ) ; } | Filtering users according to their role |
42,062 | public function hasRole ( $ role , $ requireAll = false ) { if ( $ user = $ this -> user ( ) ) { return $ user -> hasRole ( $ role , $ requireAll ) ; } return false ; } | Checks if the current user has a role by its name |
42,063 | public function can ( $ permission , $ requireAll = false ) { if ( $ user = $ this -> user ( ) ) { return $ user -> can ( $ permission , $ requireAll ) ; } return false ; } | Check if the current user has a permission by its name |
42,064 | public function ability ( $ roles , $ permissions , $ options = [ ] ) { if ( $ user = $ this -> user ( ) ) { return $ user -> ability ( $ roles , $ permissions , $ options ) ; } return false ; } | Check if the current user has a role or permission by its name |
42,065 | public function routeNeedsRole ( $ route , $ roles , $ result = null , $ requireAll = true ) { $ filterName = is_array ( $ roles ) ? implode ( '_' , $ roles ) : $ roles ; $ filterName .= '_' . substr ( md5 ( $ route ) , 0 , 6 ) ; $ closure = function ( ) use ( $ roles , $ result , $ requireAll ) { $ hasRole = $ this ->... | Filters a route for a role or set of roles . |
42,066 | public function routeNeedsPermission ( $ route , $ permissions , $ result = null , $ requireAll = true ) { $ filterName = is_array ( $ permissions ) ? implode ( '_' , $ permissions ) : $ permissions ; $ filterName .= '_' . substr ( md5 ( $ route ) , 0 , 6 ) ; $ closure = function ( ) use ( $ permissions , $ result , $ ... | Filters a route for a permission or set of permissions . |
42,067 | protected function callTerminableMiddleware ( $ response ) { if ( $ this -> shouldSkipMiddleware ( ) ) { return ; } $ response = $ this -> prepareResponse ( $ response ) ; foreach ( $ this -> middleware as $ middleware ) { if ( ! is_string ( $ middleware ) ) { continue ; } $ instance = $ this -> make ( explode ( ':' , ... | Call the terminable middleware . |
42,068 | protected function callControllerAction ( $ routeInfo ) { $ uses = $ routeInfo [ 1 ] [ 'uses' ] ; if ( is_string ( $ uses ) && ! Str :: contains ( $ uses , '@' ) ) { $ uses .= '@__invoke' ; } list ( $ controller , $ method ) = explode ( '@' , $ uses ) ; if ( ! method_exists ( $ instance = $ this -> make ( $ controller ... | Call a controller based route . |
42,069 | protected function callLumenController ( $ instance , $ method , $ routeInfo ) { $ middleware = $ instance -> getMiddlewareForMethod ( $ method ) ; if ( count ( $ middleware ) > 0 ) { return $ this -> callLumenControllerWithMiddleware ( $ instance , $ method , $ routeInfo , $ middleware ) ; } else { return $ this -> ca... | Send the request through a Lumen controller . |
42,070 | protected function callLumenControllerWithMiddleware ( $ instance , $ method , $ routeInfo , $ middleware ) { $ middleware = $ this -> gatherMiddlewareClassNames ( $ middleware ) ; return $ this -> sendThroughPipeline ( $ middleware , function ( ) use ( $ instance , $ method , $ routeInfo ) { return $ this -> callContr... | Send the request through a set of controller middleware . |
42,071 | protected function callControllerCallable ( callable $ callable , array $ parameters = [ ] ) { try { return $ this -> prepareResponse ( $ this -> call ( $ callable , $ parameters ) ) ; } catch ( HttpResponseException $ e ) { return $ e -> getResponse ( ) ; } } | Call a controller callable and return the response . |
42,072 | protected function gatherMiddlewareClassNames ( $ middleware ) { $ middleware = is_string ( $ middleware ) ? explode ( '|' , $ middleware ) : ( array ) $ middleware ; return array_map ( function ( $ name ) { list ( $ name , $ parameters ) = array_pad ( explode ( ':' , $ name , 2 ) , 2 , null ) ; return Arr :: get ( $ t... | Gather the full class names for the middleware short - cut string . |
42,073 | public function routeIs ( ... $ patterns ) { if ( ! Arr :: exists ( $ route = $ this -> route ( ) [ 1 ] , 'as' ) ) { return false ; } foreach ( $ patterns as $ pattern ) { if ( Str :: is ( $ pattern , $ route [ 'as' ] ) ) { return true ; } } return false ; } | Determine if the route name matches a given pattern . |
42,074 | public function bootstrap ( ) { if ( ! class_exists ( DotenvFactory :: class ) ) { $ this -> writeErrorAndDie ( [ 'Unable to load the environment file!' , 'Please install "vlucas/phpdotenv:^3.3".' , ] ) ; } try { $ this -> createDotenv ( ) -> safeLoad ( ) ; } catch ( InvalidFileException $ e ) { $ this -> writeErrorAnd... | Setuup the environment variables . |
42,075 | protected function sendExceptionToHandler ( $ e ) { $ handler = $ this -> resolveExceptionHandler ( ) ; if ( $ e instanceof Error ) { $ e = new FatalThrowableError ( $ e ) ; } $ handler -> report ( $ e ) ; return $ handler -> render ( $ this -> make ( 'request' ) , $ e ) ; } | Send the exception to the handler and return the response . |
42,076 | public function group ( array $ attributes , \ Closure $ callback ) { if ( isset ( $ attributes [ 'middleware' ] ) && is_string ( $ attributes [ 'middleware' ] ) ) { $ attributes [ 'middleware' ] = explode ( '|' , $ attributes [ 'middleware' ] ) ; } $ this -> updateGroupStack ( $ attributes ) ; call_user_func ( $ callb... | Register a set of routes with a set of shared attributes . |
42,077 | protected function mergeGroupAttributes ( array $ action , array $ attributes ) { $ namespace = $ attributes [ 'namespace' ] ?? null ; $ middleware = $ attributes [ 'middleware' ] ?? null ; $ as = $ attributes [ 'as' ] ?? null ; return $ this -> mergeNamespaceGroup ( $ this -> mergeMiddlewareGroup ( $ this -> mergeAsGr... | Merge the group attributes into the action . |
42,078 | protected function mergeNamespaceGroup ( array $ action , $ namespace = null ) { if ( isset ( $ namespace , $ action [ 'uses' ] ) ) { $ action [ 'uses' ] = $ this -> prependGroupNamespace ( $ action [ 'uses' ] , $ namespace ) ; } return $ action ; } | Merge the namespace group into the action . |
42,079 | protected function mergeMiddlewareGroup ( array $ action , $ middleware = null ) { if ( isset ( $ middleware ) ) { if ( isset ( $ action [ 'middleware' ] ) ) { $ action [ 'middleware' ] = array_merge ( $ middleware , $ action [ 'middleware' ] ) ; } else { $ action [ 'middleware' ] = $ middleware ; } } return $ action ;... | Merge the middleware group into the action . |
42,080 | protected function mergeAsGroup ( array $ action , $ as = null ) { if ( isset ( $ as ) && ! empty ( $ as ) ) { if ( isset ( $ action [ 'as' ] ) ) { $ action [ 'as' ] = $ as . '.' . $ action [ 'as' ] ; } else { $ action [ 'as' ] = $ as ; } } return $ action ; } | Merge the as group into the action . |
42,081 | public function to ( $ path , $ extra = [ ] , $ secure = null ) { if ( $ this -> isValidUrl ( $ path ) ) { return $ path ; } $ scheme = $ this -> getSchemeForUrl ( $ secure ) ; $ extra = $ this -> formatParameters ( $ extra ) ; $ tail = implode ( '/' , array_map ( 'rawurlencode' , ( array ) $ extra ) ) ; $ root = $ thi... | Generate a url for the application . |
42,082 | public function assetFrom ( $ root , $ path , $ secure = null ) { $ root = $ this -> getRootUrl ( $ this -> formatScheme ( $ secure ) , $ root ) ; return $ this -> removeIndex ( $ root ) . '/' . trim ( $ path , '/' ) ; } | Generate a URL to an application asset from a root domain such as CDN etc . |
42,083 | protected function prepareRequest ( SymfonyRequest $ request ) { if ( ! $ request instanceof Request ) { $ request = Request :: createFromBase ( $ request ) ; } $ request -> setUserResolver ( function ( $ guard = null ) { return $ this -> make ( 'auth' ) -> guard ( $ guard ) -> user ( ) ; } ) -> setRouteResolver ( func... | Prepare the given request instance for use with the application . |
42,084 | public function loadComponent ( $ config , $ providers , $ return = null ) { $ this -> configure ( $ config ) ; foreach ( ( array ) $ providers as $ provider ) { $ this -> register ( $ provider ) ; } return $ this -> make ( $ return ? : $ config ) ; } | Configure and load the given component and provider . |
42,085 | public function basePath ( $ path = null ) { if ( isset ( $ this -> basePath ) ) { return $ this -> basePath . ( $ path ? '/' . $ path : $ path ) ; } if ( $ this -> runningInConsole ( ) ) { $ this -> basePath = getcwd ( ) ; } else { $ this -> basePath = realpath ( getcwd ( ) . '/../' ) ; } return $ this -> basePath ( $... | Get the base path for the application . |
42,086 | public function getNamespace ( ) { if ( ! is_null ( $ this -> namespace ) ) { return $ this -> namespace ; } $ composer = json_decode ( file_get_contents ( base_path ( 'composer.json' ) ) , true ) ; foreach ( ( array ) data_get ( $ composer , 'autoload.psr-4' ) as $ namespace => $ path ) { foreach ( ( array ) $ path as... | Get the application namespace . |
42,087 | protected function offerPublishing ( ) { if ( $ this -> app -> runningInConsole ( ) ) { $ this -> publishes ( [ base_path ( 'vendor/cmgmyr/messenger/config/config.php' ) => config_path ( 'messenger.php' ) , ] , 'config' ) ; $ this -> publishes ( [ base_path ( 'vendor/cmgmyr/messenger/migrations' ) => base_path ( 'datab... | Setup the resource publishing groups for Messenger . |
42,088 | public function creator ( ) { if ( is_null ( $ this -> creatorCache ) ) { $ firstMessage = $ this -> messages ( ) -> withTrashed ( ) -> oldest ( ) -> first ( ) ; $ this -> creatorCache = $ firstMessage ? $ firstMessage -> user : Models :: user ( ) ; } return $ this -> creatorCache ; } | Returns the user object that created the thread . |
42,089 | public function scopeForUser ( Builder $ query , $ userId ) { $ participantsTable = Models :: table ( 'participants' ) ; $ threadsTable = Models :: table ( 'threads' ) ; return $ query -> join ( $ participantsTable , $ this -> getQualifiedKeyName ( ) , '=' , $ participantsTable . '.thread_id' ) -> where ( $ participant... | Returns threads that the user is associated with . |
42,090 | public function scopeForUserWithNewMessages ( Builder $ query , $ userId ) { $ participantTable = Models :: table ( 'participants' ) ; $ threadsTable = Models :: table ( 'threads' ) ; return $ query -> join ( $ participantTable , $ this -> getQualifiedKeyName ( ) , '=' , $ participantTable . '.thread_id' ) -> where ( $... | Returns threads with new messages that the user is associated with . |
42,091 | public function scopeBetween ( Builder $ query , array $ participants ) { return $ query -> whereHas ( 'participants' , function ( Builder $ q ) use ( $ participants ) { $ q -> whereIn ( 'user_id' , $ participants ) -> select ( $ this -> getConnection ( ) -> raw ( 'DISTINCT(thread_id)' ) ) -> groupBy ( 'thread_id' ) ->... | Returns threads between given user ids . |
42,092 | public function addParticipant ( $ userId ) { $ userIds = is_array ( $ userId ) ? $ userId : ( array ) func_get_args ( ) ; collect ( $ userIds ) -> each ( function ( $ userId ) { Models :: participant ( ) -> firstOrCreate ( [ 'user_id' => $ userId , 'thread_id' => $ this -> id , ] ) ; } ) ; } | Add users to thread as participants . |
42,093 | public function removeParticipant ( $ userId ) { $ userIds = is_array ( $ userId ) ? $ userId : ( array ) func_get_args ( ) ; Models :: participant ( ) -> where ( 'thread_id' , $ this -> id ) -> whereIn ( 'user_id' , $ userIds ) -> delete ( ) ; } | Remove participants from thread . |
42,094 | public function activateAllParticipants ( ) { $ participants = $ this -> participants ( ) -> withTrashed ( ) -> get ( ) ; foreach ( $ participants as $ participant ) { $ participant -> restore ( ) ; } } | Restores all participants within a thread that has a new message . |
42,095 | public function participantsString ( $ userId = null , $ columns = [ 'name' ] ) { $ participantsTable = Models :: table ( 'participants' ) ; $ usersTable = Models :: table ( 'users' ) ; $ userPrimaryKey = Models :: user ( ) -> getKeyName ( ) ; $ selectString = $ this -> createSelectString ( $ columns ) ; $ participantN... | Generates a string of participant information . |
42,096 | public function hasParticipant ( $ userId ) { $ participants = $ this -> participants ( ) -> where ( 'user_id' , '=' , $ userId ) ; if ( $ participants -> count ( ) > 0 ) { return true ; } return false ; } | Checks to see if a user is a current participant of the thread . |
42,097 | public function userUnreadMessages ( $ userId ) { $ messages = $ this -> messages ( ) -> get ( ) ; try { $ participant = $ this -> getParticipantFromUser ( $ userId ) ; } catch ( ModelNotFoundException $ e ) { return collect ( ) ; } if ( ! $ participant -> last_read ) { return $ messages ; } return $ messages -> filter... | Returns array of unread messages in thread for given user . |
42,098 | protected function getLogLevel ( $ logLevel ) { switch ( $ logLevel ) { case Logger :: DEBUG : return Severity :: debug ( ) ; case Logger :: INFO : return Severity :: info ( ) ; case Logger :: NOTICE : return Severity :: info ( ) ; case Logger :: WARNING : return Severity :: warning ( ) ; case Logger :: ERROR : return ... | Translates Monolog log levels to Sentry Severity . |
42,099 | public function subscribe ( ) { foreach ( static :: $ eventHandlerMap as $ eventName => $ handler ) { $ this -> events -> listen ( $ eventName , [ $ this , $ handler ] ) ; } } | Attach all event handlers . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.