Example #1
0
 /**
  * @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);
 }
Example #2
0
/**
 * 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.
$GLOBALS['table_prefix'] = $table_prefix;
wp_set_wpdb_vars();
Example #3
0
 /**
  * @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]);
 }