コード例 #1
0
ファイル: wp-settings.php プロジェクト: riobahtiar/WordPress
// Check if we're in WP_DEBUG mode.
wp_debug_mode();
/**
 * Filters whether to enable loading of the advanced-cache.php drop-in.
 *
 * This filter runs before it can be used by plugins. It is designed for non-web
 * run-times. If false is returned, advance-cache.php will never be loaded.
 *
 * @since 4.6.0
 *
 * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
 *                                    Default true.
 */
if (WP_CACHE && apply_filters('enable_loading_advanced_cache_dropin', true)) {
    // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
    _backup_plugin_globals();
    WP_DEBUG ? include WP_CONTENT_DIR . '/advanced-cache.php' : @(include WP_CONTENT_DIR . '/advanced-cache.php');
    _restore_plugin_globals();
}
// Define WP_LANG_DIR if not set.
wp_set_lang_dir();
// Load early WordPress files.
require ABSPATH . WPINC . '/compat.php';
require ABSPATH . WPINC . '/functions.php';
require ABSPATH . WPINC . '/class-wp.php';
require ABSPATH . WPINC . '/class-wp-error.php';
require ABSPATH . WPINC . '/pomo/mo.php';
// Include the wpdb class and, if present, a db.php database drop-in.
global $wpdb;
require_wp_db();
// Set the database table prefix and the format specifiers for database table columns.
コード例 #2
0
ファイル: plugin.php プロジェクト: aaronjorbin/WordPress
/**
 * Safely restores backed up global variables used for actions and filters.
 *
 * @since 4.6.0
 * @access private
 *
 * @global array $wp_filter         Stores all filters and actions.
 * @global array $wp_actions        Stores the amount of times an action was triggered.
 * @global array $merged_filters    Merges the filter hooks using this function.
 * @global array $wp_current_filter Stores the list of current filters with the current one last.
 * @staticvar array $backup_globals Backed up globals.
 */
function _restore_plugin_globals()
{
    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
    $backup_globals = _backup_plugin_globals(false);
    if (empty($wp_filter)) {
        $wp_filter = $backup_globals['backup_wp_filter'];
    } else {
        $added_filters = $wp_filter;
        $wp_filter = $backup_globals['backup_wp_filter'];
        foreach ($added_filters as $tag => $callback_groups) {
            // Loop through callback groups.
            foreach ($callback_groups as $priority => $callbacks) {
                // Loop through callbacks.
                foreach ($callbacks as $cb) {
                    add_filter($tag, $cb['function'], $priority, $cb['accepted_args']);
                }
            }
        }
    }
    if (empty($wp_actions)) {
        $wp_actions = $backup_globals['backup_wp_actions'];
    } else {
        $run_actions = $wp_actions;
        $wp_actions = $backup_globals['backup_wp_actions'];
        foreach ($run_actions as $action => $count) {
            if (!isset($wp_actions[$action])) {
                $wp_actions[$action] = 0;
            }
            $wp_actions[$action] += $count;
        }
    }
    if ($merged_filters !== $backup_globals['backup_merged_filters']) {
        $merged_filters = array_merge_recursive($merged_filters, $backup_globals['backup_merged_filters']);
    }
    if ($wp_current_filter !== $backup_globals['backup_wp_current_filter']) {
        $wp_current_filter = array_merge_recursive($wp_current_filter, $backup_globals['backup_wp_current_filter']);
    }
}
コード例 #3
0
ファイル: wp-settings.php プロジェクト: aaronjorbin/WordPress
// Check if we're in WP_DEBUG mode.
wp_debug_mode();
/**
 * Filters whether to enable loading of the advanced-cache.php drop-in.
 *
 * This filter runs before it can be used by plugins. It is designed for non-web
 * run-times. If false is returned, advanced-cache.php will never be loaded.
 *
 * @since 4.6.0
 *
 * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
 *                                    Default true.
 */
if (WP_CACHE && apply_filters('enable_loading_advanced_cache_dropin', true)) {
    // For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
    _backup_plugin_globals(true);
    WP_DEBUG ? include WP_CONTENT_DIR . '/advanced-cache.php' : @(include WP_CONTENT_DIR . '/advanced-cache.php');
    _restore_plugin_globals();
}
// Define WP_LANG_DIR if not set.
wp_set_lang_dir();
// Load early WordPress files.
require ABSPATH . WPINC . '/compat.php';
require ABSPATH . WPINC . '/functions.php';
require ABSPATH . WPINC . '/class-wp.php';
require ABSPATH . WPINC . '/class-wp-error.php';
require ABSPATH . WPINC . '/pomo/mo.php';
// Include the wpdb class and, if present, a db.php database drop-in.
global $wpdb;
require_wp_db();
// Set the database table prefix and the format specifiers for database table columns.
コード例 #4
0
ファイル: actions.php プロジェクト: pbearne/contrib2core
 /**
  * @ticket 36819
  */
 function test_restore_plugin_globals_includes_additions()
 {
     global $wp_filter;
     $original_filter = $wp_filter;
     $backup = _backup_plugin_globals();
     $a = new MockAction();
     $tag = rand_str();
     add_action($tag, array(&$a, 'action'));
     $this->assertNotEquals($GLOBALS['wp_filter'], $original_filter);
     _restore_plugin_globals();
     $this->assertNotEquals($GLOBALS['wp_filter'], $original_filter);
 }
コード例 #5
0
ファイル: plugin.php プロジェクト: pjsong/WordPress
/**
 * Safely restore backed up global variables used for actions and filters.
 *
 * @since 4.6.0
 * @access private
 *
 * @global array $wp_filter         Stores all filters and actions.
 * @global array $wp_actions        Stores the amount of times an action was triggered.
 * @global array $merged_filters    Merges the filter hooks using this function.
 * @global array $wp_current_filter Stores the list of current filters with the current one last.
 * @staticvar array $backup_globals Backed up globals.
 */
function _restore_plugin_globals()
{
    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
    $backup_globals = _backup_plugin_globals();
    if ($wp_filter !== $backup_globals['backup_wp_filter']) {
        $wp_filter = array_merge_recursive($wp_filter, $backup_globals['backup_wp_filter']);
    }
    if ($wp_actions !== $backup_globals['backup_wp_actions']) {
        $wp_actions = array_merge_recursive($wp_actions, $backup_globals['backup_wp_actions']);
    }
    if ($merged_filters !== $backup_globals['backup_merged_filters']) {
        $merged_filters = array_merge_recursive($merged_filters, $backup_globals['backup_merged_filters']);
    }
    if ($wp_current_filter !== $backup_globals['backup_wp_current_filter']) {
        $wp_current_filter = array_merge_recursive($wp_current_filter, $backup_globals['backup_wp_current_filter']);
    }
}
コード例 #6
0
ファイル: actions.php プロジェクト: aaronjorbin/WordPress
 /**
  * @ticket 36819
  */
 function test_applied_actions_are_counted_after_restore()
 {
     global $wp_actions;
     $action_name = 'this_is_a_fake_action_name';
     $this->assertArrayNotHasKey($action_name, $wp_actions);
     do_action($action_name);
     $this->assertEquals(1, $wp_actions[$action_name]);
     _backup_plugin_globals(true);
     do_action($action_name);
     _restore_plugin_globals();
     $this->assertEquals(2, $wp_actions[$action_name]);
 }