当前位置: 首页>>代码示例>>PHP>>正文


PHP blc_get_configuration函数代码示例

本文整理汇总了PHP中blc_get_configuration函数的典型用法代码示例。如果您正苦于以下问题:PHP blc_get_configuration函数的具体用法?PHP blc_get_configuration怎么用?PHP blc_get_configuration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了blc_get_configuration函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * Class "constructor". Can't use an actual constructor due to how PHP4 handles object references.
  * 
  * Specifically, this class is a singleton. The function needs to pass $this to several other 
  * functions (to set up hooks), which will store the reference for later use. However, it appears 
  * that in PHP4 the actual value of $this is thrown away right after the constructor finishes, and
  * `new` returns a *copy* of $this. The result is that getInstance() won't be returning a ref.
  * to the same object as is used for hook callbacks. And that's horrible.   
  * 
  * Sets up hooks that monitor added/modified/deleted posts and registers
  * virtual modules for all post types.
  *
  * @return void
  */
 function init()
 {
     $this->plugin_conf = blc_get_configuration();
     if (isset($this->plugin_conf->options['enabled_post_statuses'])) {
         $this->enabled_post_statuses = $this->plugin_conf->options['enabled_post_statuses'];
     }
     //Register a virtual container module for each enabled post type
     $module_manager = blcModuleManager::getInstance();
     $post_types = get_post_types(array(), 'objects');
     $exceptions = array('revision', 'nav_menu_item', 'attachment');
     foreach ($post_types as $data) {
         $post_type = $data->name;
         if (in_array($post_type, $exceptions)) {
             continue;
         }
         $module_manager->register_virtual_module($post_type, array('Name' => $data->labels->name, 'ModuleCategory' => 'container', 'ModuleContext' => 'all', 'ModuleClassName' => 'blcAnyPostContainerManager'));
     }
     //These hooks update the synch & instance records when posts are added, deleted or modified.
     add_action('delete_post', array(&$this, 'post_deleted'));
     add_action('save_post', array(&$this, 'post_saved'));
     //We also treat post trashing/untrashing as delete/save.
     add_action('trash_post', array(&$this, 'post_deleted'));
     add_action('untrash_post', array(&$this, 'post_saved'));
     //Highlight and nofollow broken links in posts & pages
     if ($this->plugin_conf->options['mark_broken_links'] || $this->plugin_conf->options['nofollow_broken_links']) {
         add_filter('the_content', array(&$this, 'hook_the_content'));
         if ($this->plugin_conf->options['mark_broken_links'] && !empty($this->plugin_conf->options['broken_link_css'])) {
             add_action('wp_head', array(&$this, 'hook_wp_head'));
         }
     }
 }
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:45,代码来源:any-post.php

示例2: blc_display_survey_notice

/**
* Display a notice asking the user to take the Broken Link Checker user survey.
*
* @return void
*/
function blc_display_survey_notice()
{
    //Only people who can actually use the plugin will see the notice
    if (!current_user_can('manage_links')) {
        return;
    }
    if (!empty($_GET['dismiss-blc-survey'])) {
        //The user has chosen to hide the survey notice
        $blc_config = blc_get_configuration();
        $blc_config->options['hide_surveyio_notice'] = true;
        $blc_config->save_options();
        return;
    }
    $survey_url = 'http://survey.io/survey/7fbf0';
    $msg = sprintf('<strong>Help improve Broken Link Checker - <a href="%s" target="_blank" title="This link will open in a new window" id="blc-take-survey-link">take a user feedback survey!</a></strong>
		 <br><a href="%s">Hide this notice</a>', $survey_url, esc_attr(add_query_arg('dismiss-blc-survey', 1)));
    echo '<div id="update-nag" class="blc-survey-notice" style="text-align: left; padding-left: 10px;">' . $msg . '</div>';
    //Auto-hide the notice after the user clicks the survey link
    ?>
	<script type="text/javascript">
	jQuery(function($){
		$('#blc-take-survey-link').click(function(){
			$('.blc-survey-notice').hide('fast');
			$.get('<?php 
    echo esc_js(add_query_arg('dismiss-blc-survey', 1, admin_url()));
    ?>
');
		});
	});
	</script>
	<?php 
}
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:37,代码来源:survey.php

示例3: upgrade_database

 /**
  * Create and/or upgrade the plugin's database tables.
  *
  * @return bool
  */
 public static function upgrade_database()
 {
     global $wpdb, $blclog;
     $conf = blc_get_configuration();
     $current = $conf->options['current_db_version'];
     if ($current != 0 && $current < 4) {
         //The 4th DB version makes a lot of backwards-incompatible changes to the main
         //BLC tables, so instead of upgrading we just throw them away and recreate.
         if (!blcDatabaseUpgrader::drop_tables()) {
             return false;
         }
         $current = 0;
     }
     //Create/update the plugin's tables
     if (!blcDatabaseUpgrader::make_schema_current()) {
         return false;
     }
     if ($current != 0) {
         if ($current < 5) {
             blcDatabaseUpgrader::upgrade_095();
         }
     }
     $conf->options['current_db_version'] = BLC_DATABASE_VERSION;
     $conf->save_options();
     $blclog->info('Database successfully upgraded.');
     return true;
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:32,代码来源:db-upgrade.php

示例4: blc_got_unsynched_items

 /**
  * Notify the link checker that there are unsynched items 
  * that might contain links (e.g. a new or edited post).
  *
  * @return void
  */
 function blc_got_unsynched_items()
 {
     $conf = blc_get_configuration();
     if (!$conf->options['need_resynch']) {
         $conf->options['need_resynch'] = true;
         $conf->save_options();
     }
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:14,代码来源:init.php

示例5: init

 /**
  * Class "constructor".
  * 
  * @param array $default_active_modules An array of module ids specifying which modules are active by default.
  * @return void
  */
 function init($default_active_modules = null)
 {
     $this->module_dir = realpath(dirname(__FILE__) . '/../modules');
     $this->plugin_conf = blc_get_configuration();
     $this->default_active_modules = $default_active_modules;
     $this->loaded = array();
     $this->instances = array();
     add_filter('extra_plugin_headers', array(&$this, 'inject_module_headers'));
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:15,代码来源:module-manager.php

示例6: save_settings

 function save_settings()
 {
     $information = array();
     $information['result'] = 'NOTCHANGE';
     $new_check_threshold = intval($_POST['check_threshold']);
     if ($new_check_threshold > 0) {
         $conf = blc_get_configuration();
         $conf->options['check_threshold'] = $new_check_threshold;
         if ($conf->save_options()) {
             $information['result'] = 'SUCCESS';
         }
     }
     return $information;
 }
开发者ID:HasClass0,项目名称:mainwp-child,代码行数:14,代码来源:MainWPChildLinksChecker.class.php

示例7: check

 /**
  * Check a FileServe link.
  *
  * See the FileServe API documentation for details:
  * http://app.fileserve.com/api/download/
  *
  * @param string $url File URL.
  * @return array
  */
 function check($url)
 {
     $result = array('final_url' => $url, 'redirect_count' => 0, 'timeout' => false, 'broken' => false, 'log' => sprintf("<em>(%s)</em>\n\n", __('Using FileServe API', 'broken-link-checker')), 'result_hash' => '', 'status_code' => '', 'status_text' => '');
     //We know the URL will match because ModuleCheckerUrlPattern matched.
     preg_match('@^http://(?:www\\.)?fileserve\\.com/file/([\\w\\d]+?)(?:/|$|[?#])@i', $url, $matches);
     $file_id = $matches[1];
     $conf = blc_get_configuration();
     $args = array('timeout' => $conf->options['timeout'], 'body' => array('shorten' => $file_id));
     $start = microtime_float();
     $response = wp_remote_post($this->fileserve_api_url, $args);
     $result['request_duration'] = microtime_float() - $start;
     $error_code = 0;
     if (is_wp_error($response)) {
         $result['log'] .= "Error : " . $response->get_error_message();
         $result['broken'] = true;
         $result['http_code'] = 0;
     } else {
         $result['http_code'] = intval($response['response']['code']);
         if ($result['http_code'] == 200) {
             //In this case, the HTTP code returned by is not meaningful in itself,
             //so we won't store it or display it to the user.
             $result['http_code'] = 0;
             $json = json_decode($response['body'], false);
             if (isset($json->error_code)) {
                 $error_code = intval($json->error_code);
             }
             $failure_codes = array(310 => 'Invalid request', 403 => 'Not premium', 404 => 'Invalid link', 601 => 'Limited free download', 602 => 'Number of concurrent download exceeded', 603 => 'Too many invalid capcha', 605 => 'Expired premium', 606 => 'Invalid file ID', 607 => 'File not available', 608 => 'File not available');
             if (array_key_exists($error_code, $failure_codes)) {
                 $result['broken'] = true;
                 $result['status_code'] = BLC_LINK_STATUS_ERROR;
                 $result['status_text'] = __('Not Found', 'broken-link-checker');
                 $result['log'] .= sprintf(__('FileServe : %d %s', 'broken-link-checker') . "\n", $error_code, $failure_codes[$error_code]);
             } else {
                 $result['status_code'] = BLC_LINK_STATUS_OK;
                 $result['status_text'] = _x('OK', 'link status', 'broken-link-checker');
             }
             //$result['log'] .= "API response :\n" . htmlspecialchars(print_r((array)$json, true));
             $result['log'] .= "API response :\n<code>" . htmlspecialchars($response['body']) . "</code>\n";
         } else {
             //Unexpected error.
             $result['log'] .= $response['body'];
             $result['broken'] = true;
         }
     }
     //Generate the result hash (used for detecting false positives)
     $result['result_hash'] = implode('|', array('fileserve', $result['http_code'], $result['broken'] ? 'broken' : '0', $result['timeout'] ? 'timeout' : '0', $error_code));
     return $result;
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:57,代码来源:fileserve.php

示例8: __construct

 function __construct()
 {
     //Init. the available native filters.
     $this->native_filters = array('all' => array('params' => array('where_expr' => '1'), 'name' => __('All', 'broken-link-checker'), 'heading' => __('Detected Links', 'broken-link-checker'), 'heading_zero' => __('No links found (yet)', 'broken-link-checker'), 'native' => true), 'broken' => array('params' => array('where_expr' => '( broken = 1 )', 's_include_dismissed' => false), 'name' => __('Broken', 'broken-link-checker'), 'heading' => __('Broken Links', 'broken-link-checker'), 'heading_zero' => __('No broken links found', 'broken-link-checker'), 'native' => true), 'warnings' => array('params' => array('where_expr' => '( warning = 1 )', 's_include_dismissed' => false), 'name' => _x('Warnings', 'filter name', 'broken-link-checker'), 'heading' => __('Warnings', 'filter heading', 'broken-link-checker'), 'heading_zero' => __('No warnings found', 'broken-link-checker'), 'native' => true), 'redirects' => array('params' => array('where_expr' => '( redirect_count > 0 )', 's_include_dismissed' => false), 'name' => __('Redirects', 'broken-link-checker'), 'heading' => __('Redirected Links', 'broken-link-checker'), 'heading_zero' => __('No redirects found', 'broken-link-checker'), 'native' => true), 'dismissed' => array('params' => array('where_expr' => '( dismissed = 1 )'), 'name' => __('Dismissed', 'broken-link-checker'), 'heading' => __('Dismissed Links', 'broken-link-checker'), 'heading_zero' => __('No dismissed links found', 'broken-link-checker'), 'native' => true));
     //The user can turn off warnings. In that case, all errors will show up in the "broken" filter instead.
     $conf = blc_get_configuration();
     if (!$conf->get('warnings_enabled')) {
         unset($this->native_filters['warnings']);
     }
     //Create the special "search" filter
     $this->search_filter = array('name' => __('Search', 'broken-link-checker'), 'heading' => __('Search Results', 'broken-link-checker'), 'heading_zero' => __('No links found for your query', 'broken-link-checker'), 'params' => array(), 'use_url_params' => true, 'hidden' => true);
     //These search arguments may be passed via the URL if the filter's 'use_url_params' field is set to True.
     //They map to the fields of the search form on the Tools -> Broken Links page. Only these arguments
     //can be used in user-defined filters.
     $this->valid_url_params = array('s_link_text', 's_link_url', 's_parser_type', 's_container_type', 's_link_type', 's_http_code', 's_filter');
 }
开发者ID:idies,项目名称:escience-2016-wp,代码行数:16,代码来源:link-query.php

示例9: save_settings

 function save_settings()
 {
     $information = array();
     $information['result'] = 'NOTCHANGE';
     $new_check_threshold = intval($_POST['check_threshold']);
     if (update_option('mainwp_child_blc_max_number_of_links', intval($_POST['max_number_of_links']))) {
         $information['result'] = 'SUCCESS';
     }
     if ($new_check_threshold > 0) {
         $conf = blc_get_configuration();
         $conf->options['check_threshold'] = $new_check_threshold;
         if ($conf->save_options()) {
             $information['result'] = 'SUCCESS';
         }
     }
     return $information;
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:17,代码来源:MainWPChildLinksChecker.class.php

示例10: unlink_callback

 /**
  * blcHTMLLink::unlink_callback()
  *
  * @access private
  * 
  * @param array $link
  * @param array $params
  * @return string
  */
 function unlink_callback($link, $params)
 {
     //Skip links that don't match the specified URL
     if ($link['href'] != $params['old_url']) {
         return $link['#raw'];
     }
     $config = blc_get_configuration();
     if ($config->options['mark_removed_links']) {
         //Leave only the anchor text + the removed_link CSS class
         return sprintf('<span class="removed_link" title="%s">%s</span>', esc_attr($link['href']), $link['#link_text']);
     } else {
         //Just the anchor text
         return $link['#link_text'];
     }
 }
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:24,代码来源:html_link.php

示例11: decide_warning_state

 /**
  * Decide whether the result of the latest check means that the link is really broken
  * or should just be reported as a warning.
  *
  * @param array $check_results
  * @return array
  */
 private function decide_warning_state($check_results)
 {
     if (!$check_results['broken'] && !$check_results['warning']) {
         //Nothing to do, this is a working link.
         return $check_results;
     }
     $configuration = blc_get_configuration();
     if (!$configuration->get('warnings_enabled', true)) {
         //The user wants all failures to be reported as "broken", regardless of severity.
         if ($check_results['warning']) {
             $check_results['broken'] = true;
             $check_results['warning'] = false;
         }
         return $check_results;
     }
     $warning_reason = null;
     $failure_count = $this->check_count;
     $failure_duration = $this->first_failure != 0 ? time() - $this->first_failure : 0;
     //These could be configurable, but lets put that off until someone actually asks for it.
     $duration_threshold = 24 * 3600;
     $count_threshold = 3;
     //We can't just use ($check_results['status_code'] == 'warning' because some "warning" problems are not
     //temporary. For example, region-restricted YouTube videos use the "warning" status code.
     $maybe_temporary_error = false;
     //Some basic heuristics to determine if this failure might be temporary.
     //----------------------------------------------------------------------
     if ($check_results['timeout']) {
         $maybe_temporary_error = true;
         $warning_reason = 'Timeouts are sometimes caused by high server load or other temporary issues.';
     }
     $error_code = isset($check_results['error_code']) ? $check_results['error_code'] : '';
     if ($error_code === 'connection_failed') {
         $maybe_temporary_error = true;
         $warning_reason = 'Connection failures are sometimes caused by high server load or other temporary issues.';
     }
     $http_code = intval($check_results['http_code']);
     $temporary_http_errors = array(408, 420, 429, 502, 503, 504, 509, 520, 522, 524);
     if (in_array($http_code, $temporary_http_errors)) {
         $maybe_temporary_error = true;
         if (in_array($http_code, array(502, 503, 504, 509))) {
             $warning_reason = sprintf('HTTP error %d usually means that the site is down due to high server load or a configuration problem. ' . 'This error is often temporary and will go away after while.', $http_code);
         } else {
             $warning_reason = 'This HTTP error is often temporary.';
         }
     }
     //----------------------------------------------------------------------
     //Attempt to detect false positives.
     $suspected_false_positive = false;
     //A "403 Forbidden" error on an internal link usually means something on the site is blocking automated
     //requests. Possible culprits include hotlink protection rules in .htaccess, badly configured IDS, and so on.
     $is_internal_link = $this->is_internal_to_domain();
     if ($is_internal_link && $http_code == 403) {
         $suspected_false_positive = true;
         $warning_reason = 'This might be a false positive. Make sure the link is not password-protected, ' . 'and that your server is not set up to block automated requests.';
     }
     //Some hosting providers turn off loopback connections. This causes all internal links to be reported as broken.
     if ($is_internal_link && in_array($error_code, array('connection_failed', 'couldnt_resolve_host'))) {
         $suspected_false_positive = true;
         $warning_reason = 'This is probably a false positive. ';
         if ($error_code === 'connection_failed') {
             $warning_reason .= 'The plugin could not connect to your site. That usually means that your ' . 'hosting provider has disabled loopback connections.';
         } elseif ($error_code === 'couldnt_resolve_host') {
             $warning_reason .= 'The plugin could not connect to your site because DNS resolution failed. ' . 'This could mean DNS is configured incorrectly on your server.';
         }
     }
     //----------------------------------------------------------------------
     //Temporary problems and suspected false positives start out as warnings. False positives stay that way
     //indefinitely because they are usually caused by bugs and server configuration issues, not temporary downtime.
     if ($maybe_temporary_error && $failure_count < $count_threshold || $suspected_false_positive) {
         $check_results['warning'] = true;
         $check_results['broken'] = false;
     }
     //Upgrade temporary warnings to "broken" after X consecutive failures or Y hours, whichever comes first.
     $threshold_reached = $failure_count >= $count_threshold || $failure_duration >= $duration_threshold;
     if ($check_results['warning']) {
         if ($maybe_temporary_error && $threshold_reached && !$suspected_false_positive) {
             $check_results['warning'] = false;
             $check_results['broken'] = true;
         }
     }
     if (!empty($warning_reason) && $check_results['warning']) {
         $formatted_reason = "\n==========\n" . 'Severity: Warning' . "\n" . 'Reason: ' . trim($warning_reason) . "\n==========\n";
         $check_results['log'] .= $formatted_reason;
     }
     return $check_results;
 }
开发者ID:ManageWP,项目名称:broken-link-checker,代码行数:93,代码来源:links.php

示例12: head

 /**
  * Perform a HEAD request to the specified URL.
  * 
  * Note : 
  * 
  * Since the MediaFire checker works by parsing the "Location" header, redirect following
  * _must_ be disabled. This can become a problem on servers where WP is forced to fall back
  * on using WP_Http_Fopen which ignores the 'redirection' flag. WP_Http_Fsockopen would work, 
  * but it has the lowest priority of all transports. 
  * 
  * Alas, there is no way to reliably influence which transport is chosen - the WP_Http::_getTransport
  * function caches the available choices, so plugins can disable individual transports only during
  * its first run. Therefore, we must pick the best transport manually.
  * 
  * @param string $url
  * @return array|WP_Error
  */
 function head($url)
 {
     //Only consider transports that allow redirection to be disabled.
     $args = array();
     if (class_exists('WP_Http_ExtHttp') && true === WP_Http_ExtHttp::test($args)) {
         $transport = new WP_Http_ExtHttp();
     } else {
         if (class_exists('WP_Http_Curl') && true === WP_Http_Curl::test($args)) {
             $transport = new WP_Http_Curl();
         } else {
             if (class_exists('WP_Http_Curl') && true === WP_Http_Fsockopen::test($args)) {
                 $transport = new WP_Http_Fsockopen();
             } else {
                 return new WP_Error('no_suitable_transport', "No suitable HTTP transport found. Please upgrade to a more recent version of PHP or install the CURL extension.");
             }
         }
     }
     $conf = blc_get_configuration();
     $args = array('timeout' => $conf->options['timeout'], 'redirection' => 0, 'method' => 'HEAD');
     return $transport->request($url, $args);
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:38,代码来源:mediafire.php

示例13: hook_wp_head

 /**
  * A hook for the 'wp_head' action. Outputs the user-defined broken link CSS.
  *
  * @return void
  */
 function hook_wp_head()
 {
     $conf = blc_get_configuration();
     echo '<style type="text/css">', $conf->options['broken_link_css'], '</style>';
 }
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:10,代码来源:post.php

示例14: show_warnings_section_notice

        /**
         * Show an admin notice that explains what the "Warnings" section under "Tools -> Broken Links" does.
         * The user can hide the notice.
         */
        public function show_warnings_section_notice()
        {
            $is_warnings_section = isset($_GET['filter_id']) && $_GET['filter_id'] === 'warnings' && isset($_GET['page']) && $_GET['page'] === 'view-broken-links';
            if (!($is_warnings_section && current_user_can('edit_others_posts'))) {
                return;
            }
            //Let the user hide the notice.
            $conf = blc_get_configuration();
            $notice_name = 'show_warnings_section_hint';
            if (isset($_GET[$notice_name]) && is_numeric($_GET[$notice_name])) {
                $conf->set($notice_name, (bool) $_GET[$notice_name]);
                $conf->save_options();
            }
            if (!$conf->get($notice_name, true)) {
                return;
            }
            printf('<div class="updated">
					<p>%1$s</p>
					<p>
						<a href="%2$s">%3$s</a> |
						<a href="%4$s">%5$s</a>
					<p>
				</div>', __('The "Warnings" page lists problems that are probably temporary or suspected to be false positives.<br> Warnings that persist for a long time will usually be reclassified as broken links.', 'broken-link-checker'), esc_attr(add_query_arg($notice_name, '0')), _x('Hide notice', 'admin notice under Tools - Broken links - Warnings', 'broken-link-checker'), esc_attr(admin_url('options-general.php?page=link-checker-settings#blc_warning_settings')), _x('Change warning settings', 'a link from the admin notice under Tools - Broken links - Warnings', 'broken-link-checker'));
        }
开发者ID:ManageWP,项目名称:broken-link-checker,代码行数:28,代码来源:core.php

示例15: check_files

 /**
  * Check the status of one or more MegaUpload files.
  * 
  * The MegaUpload API that is used in this function isn't documented anywhere.
  * The input and output data formats were reverse-engineered by sniffing the
  * HTTP requests made by the "Mega Manager" tool. 
  * 
  * @param array|string $file_ids
  * @return array|WP_Error
  */
 function check_files($file_ids)
 {
     if (is_string($file_ids)) {
         $file_ids = array($file_ids);
     }
     //The API expects input in this format : id0=file1id&id1=file2id&...
     $request_ids = array();
     $counter = 0;
     foreach ($file_ids as $file_id) {
         $id = 'id' . $counter;
         $request_ids[$id] = $file_id;
         $counter++;
     }
     $conf = blc_get_configuration();
     $args = array('timeout' => $conf->options['timeout'], 'body' => $request_ids);
     //Submit the request
     $rez = wp_remote_post('http://www.megaupload.com/mgr_linkcheck.php', $args);
     if (is_wp_error($rez)) {
         return $rez;
     }
     if ($rez['response']['code'] == 200 && !empty($rez['body'])) {
         $api_results = $this->parse_api_response($rez['body']);
         $results = array();
         //Resort the results by real file IDs
         foreach ($api_results as $id => $file_info) {
             if (!array_key_exists($id, $request_ids)) {
                 continue;
             }
             $results[$request_ids[$id]] = $file_info;
         }
         return $results;
     } else {
         return new WP_Error('megaupload_api_error', "MegaUpload API Error", $rez);
     }
 }
开发者ID:ahsaeldin,项目名称:projects,代码行数:45,代码来源:megaupload.php


注:本文中的blc_get_configuration函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。