/** * Set up the filters to skip the loaded plugins */ private function setup_skip_plugins_filters() { $wp_cli_filter_active_plugins = function ($plugins) { $skipped_plugins = WP_CLI::get_runner()->config['skip-plugins']; if (true === $skipped_plugins) { return array(); } if (!is_array($plugins)) { return $plugins; } foreach ($plugins as $key => $plugin) { if (Utils\is_plugin_skipped($plugin)) { unset($plugins[$key]); } } return array_values($plugins); }; $hooks = array('pre_site_option_active_sitewide_plugins', 'site_option_active_sitewide_plugins', 'pre_option_active_plugins', 'option_active_plugins'); foreach ($hooks as $hook) { $this->add_wp_hook($hook, $wp_cli_filter_active_plugins, 999); } $this->add_wp_hook('plugins_loaded', function () use($hooks, $wp_cli_filter_active_plugins) { foreach ($hooks as $hook) { remove_filter($hook, $wp_cli_filter_active_plugins, 999); } }, 0); }
} // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies(). wp_cookie_constants(); // Define and enforce our SSL constants wp_ssl_constants(); // Create common globals. // require( ABSPATH . WPINC . '/vars.php' ); // Make taxonomies and posts available to plugins and themes. // @plugin authors: warning: these get registered again on the init hook. create_initial_taxonomies(); create_initial_post_types(); // Register the default theme directory root register_theme_directory(get_theme_root()); // Load active plugins. foreach (wp_get_active_and_valid_plugins() as $plugin) { if (!Utils\is_plugin_skipped($plugin)) { if ($symlinked_plugins_supported) { wp_register_plugin_realpath($plugin); } include_once $plugin; } } unset($plugin, $symlinked_plugins_supported); // Load pluggable functions. require ABSPATH . WPINC . '/pluggable.php'; require ABSPATH . WPINC . '/pluggable-deprecated.php'; // Set internal encoding. wp_set_internal_encoding(); // Run wp_cache_postload() if object cache is enabled and the function exists. if (WP_CACHE && function_exists('wp_cache_postload')) { wp_cache_postload();
/** * Set up the filters to skip the loaded plugins */ private function setup_skip_plugins_filters() { $wp_cli_filter_active_plugins = function ($plugins) { $skipped_plugins = WP_CLI::get_runner()->config['skip-plugins']; if (true === $skipped_plugins) { return array(); } if (!is_array($plugins)) { return $plugins; } foreach ($plugins as $a => $b) { // active_sitewide_plugins stores plugin name as the key if (false !== strpos(current_filter(), 'active_sitewide_plugins') && Utils\is_plugin_skipped($a)) { unset($plugins[$a]); // active_plugins stores plugin name as the value } else { if (false !== strpos(current_filter(), 'active_plugins') && Utils\is_plugin_skipped($b)) { unset($plugins[$a]); } } } // Reindex because active_plugins expects a numeric index if (false !== strpos(current_filter(), 'active_plugins')) { $plugins = array_values($plugins); } return $plugins; }; $hooks = array('pre_site_option_active_sitewide_plugins', 'site_option_active_sitewide_plugins', 'pre_option_active_plugins', 'option_active_plugins'); foreach ($hooks as $hook) { WP_CLI::add_wp_hook($hook, $wp_cli_filter_active_plugins, 999); } WP_CLI::add_wp_hook('plugins_loaded', function () use($hooks, $wp_cli_filter_active_plugins) { foreach ($hooks as $hook) { remove_filter($hook, $wp_cli_filter_active_plugins, 999); } }, 0); }