: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
foreach ( $active_plugins as $plugin ) {
if ( ! validate_file( $plugin ) // $plugin must validate as file.
&& str_ends_with( $plugin, '.php' ) // $plugin must end with '.php'.
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.
// Not already included as a network plugin.
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) )
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
* Remove plugins from the list of active plugins when we're on an endpoint
* that should be protected against WSODs and the plugin is paused.
if ( wp_is_recovery_mode() ) {
$plugins = wp_skip_paused_plugins( $plugins );
* Filters a given list of plugins, removing any paused plugins from it.
* @global WP_Paused_Extensions_Storage $_paused_plugins
* @param string[] $plugins Array of absolute plugin main file paths.
* @return string[] Filtered array of plugins, without any paused plugins.
function wp_skip_paused_plugins( array $plugins ) {
$paused_plugins = wp_paused_plugins()->get_all();
if ( empty( $paused_plugins ) ) {
foreach ( $plugins as $index => $plugin ) {
list( $plugin ) = explode( '/', plugin_basename( $plugin ) );
if ( array_key_exists( $plugin, $paused_plugins ) ) {
unset( $plugins[ $index ] );
// Store list of paused plugins for displaying an admin notice.
$GLOBALS['_paused_plugins'][ $plugin ] = $paused_plugins[ $plugin ];
* Retrieves an array of active and valid themes.
* While upgrading or installing WordPress, no themes are returned.
* @global string $pagenow The filename of the current screen.
* @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
* @global string $wp_template_path Path to current theme's template directory.
* @return string[] Array of absolute paths to theme directories.
function wp_get_active_and_valid_themes() {
global $pagenow, $wp_stylesheet_path, $wp_template_path;
if ( wp_installing() && 'wp-activate.php' !== $pagenow ) {
if ( is_child_theme() ) {
$themes[] = $wp_stylesheet_path;
$themes[] = $wp_template_path;
* Remove themes from the list of active themes when we're on an endpoint
* that should be protected against WSODs and the theme is paused.
if ( wp_is_recovery_mode() ) {
$themes = wp_skip_paused_themes( $themes );
// If no active and valid themes exist, skip loading themes.
if ( empty( $themes ) ) {
add_filter( 'wp_using_themes', '__return_false' );
* Filters a given list of themes, removing any paused themes from it.
* @global WP_Paused_Extensions_Storage $_paused_themes
* @param string[] $themes Array of absolute theme directory paths.
* @return string[] Filtered array of absolute paths to themes, without any paused themes.
function wp_skip_paused_themes( array $themes ) {
$paused_themes = wp_paused_themes()->get_all();
if ( empty( $paused_themes ) ) {
foreach ( $themes as $index => $theme ) {
$theme = basename( $theme );
if ( array_key_exists( $theme, $paused_themes ) ) {
unset( $themes[ $index ] );
// Store list of paused themes for displaying an admin notice.
$GLOBALS['_paused_themes'][ $theme ] = $paused_themes[ $theme ];
* Determines whether WordPress is in Recovery Mode.
* In this mode, plugins or themes that cause WSODs will be paused.
function wp_is_recovery_mode() {
return wp_recovery_mode()->is_active();
* Determines whether we are currently on an endpoint that should be protected against WSODs.
* @global string $pagenow The filename of the current screen.
* @return bool True if the current endpoint should be protected.
function is_protected_endpoint() {
if ( isset( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) {
// Protect the admin backend.
if ( is_admin() && ! wp_doing_ajax() ) {
// Protect Ajax actions that could help resolve a fatal error should be available.
if ( is_protected_ajax_action() ) {
* Filters whether the current request is against a protected endpoint.
* This filter is only fired when an endpoint is requested which is not already protected by
* WordPress core. As such, it exclusively allows providing further protected endpoints in
* addition to the admin backend, login pages and protected Ajax actions.
* @param bool $is_protected_endpoint Whether the currently requested endpoint is protected.
return (bool) apply_filters( 'is_protected_endpoint', false );
* Determines whether we are currently handling an Ajax action that should be protected against WSODs.
* @return bool True if the current Ajax action should be protected.
function is_protected_ajax_action() {
if ( ! wp_doing_ajax() ) {
if ( ! isset( $_REQUEST['action'] ) ) {
$actions_to_protect = array(
'edit-theme-plugin-file', // Saving changes in the core code editor.
'heartbeat', // Keep the heart beating.
'install-plugin', // Installing a new plugin.
'install-theme', // Installing a new theme.
'search-plugins', // Searching in the list of plugins.
'search-install-plugins', // Searching for a plugin in the plugin install screen.
'update-plugin', // Update an existing plugin.
'update-theme', // Update an existing theme.
'activate-plugin', // Activating an existing plugin.
* Filters the array of protected Ajax actions.
* This filter is only fired when doing Ajax and the Ajax request has an 'action' property.
* @param string[] $actions_to_protect Array of strings with Ajax actions to protect.
$actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect );
if ( ! in_array( $_REQUEST['action'], $actions_to_protect, true ) ) {
* Sets internal encoding.
* In most cases the default internal encoding is latin1, which is
* of no use, since we want to use the `mb_` functions for `utf-8` strings.
function wp_set_internal_encoding() {
if ( function_exists( 'mb_internal_encoding' ) ) {
$charset = get_option( 'blog_charset' );
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
if ( ! $charset || ! @mb_internal_encoding( $charset ) ) {
mb_internal_encoding( 'UTF-8' );
* Adds magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`.
* Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`,
* `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly.
function wp_magic_quotes() {
$_GET = add_magic_quotes( $_GET );
$_POST = add_magic_quotes( $_POST );
$_COOKIE = add_magic_quotes( $_COOKIE );
$_SERVER = add_magic_quotes( $_SERVER );
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );
* Runs just before PHP shuts down execution.
function shutdown_action_hook() {
* Fires just before PHP shuts down execution.
* @param object $input_object The object to clone.
* @return object The cloned object.
function wp_clone( $input_object ) {
// Use parens for clone to accommodate PHP 4. See #17880.
return clone( $input_object );
* Determines whether the current request is for the login screen.
* @return bool True if inside WordPress login screen, false otherwise.
return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME'] );
* Determines whether the current request is for an administrative interface page.
* Does not check if the user is an administrator; use current_user_can()
* for checking roles and capabilities.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Screen $current_screen WordPress current screen object.
* @return bool True if inside WordPress administration interface, false otherwise.
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin();
} elseif ( defined( 'WP_ADMIN' ) ) {
* Determines whether the current request is for a site's administrative interface.
* Does not check if the user is an administrator; use current_user_can()
* for checking roles and capabilities.
* @global WP_Screen $current_screen WordPress current screen object.
* @return bool True if inside WordPress site administration pages.
function is_blog_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin( 'site' );
} elseif ( defined( 'WP_BLOG_ADMIN' ) ) {
* Determines whether the current request is for the network administrative interface.
* e.g. `/wp-admin/network/`
* Does not check if the user is an administrator; use current_user_can()
* for checking roles and capabilities.
* Does not check if the site is a Multisite network; use is_multisite()
* for checking if Multisite is enabled.
* @global WP_Screen $current_screen WordPress current screen object.
* @return bool True if inside WordPress network administration pages.
function is_network_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin( 'network' );
} elseif ( defined( 'WP_NETWORK_ADMIN' ) ) {
* Determines whether the current request is for a user admin screen.
* Does not check if the user is an administrator; use current_user_can()
* for checking roles and capabilities.
* @global WP_Screen $current_screen WordPress current screen object.
* @return bool True if inside WordPress user administration pages.
function is_user_admin() {
if ( isset( $GLOBALS['current_screen'] ) ) {
return $GLOBALS['current_screen']->in_admin( 'user' );
} elseif ( defined( 'WP_USER_ADMIN' ) ) {
* Determines whether Multisite is enabled.
* @return bool True if Multisite is enabled, false otherwise.
function is_multisite() {
if ( defined( 'MULTISITE' ) ) {
if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
* Retrieves the current site ID.
function get_current_blog_id() {
return absint( $blog_id );
* Retrieves the current network ID.
* @return int The ID of the current network.
function get_current_network_id() {
if ( ! is_multisite() ) {
$current_network = get_network();
if ( ! isset( $current_network->id ) ) {
return get_main_network_id();
return absint( $current_network->id );
* Attempts an early load of translations.
* Used for errors encountered during the initial loading process, before
* the locale has been properly detected and loaded.
* Designed for unusual load sequences (like setup-config.php) or for when
* the script will then terminate with an error, otherwise there is a risk
* that a file can be double-included.
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
* @global WP_Locale $wp_locale WordPress date and time locale object.
function wp_load_translations_early() {
global $wp_textdomain_registry, $wp_locale;
if ( function_exists( 'did_action' ) && did_action( 'init' ) ) {
// We need $wp_local_package.
require ABSPATH . WPINC . '/version.php';