/** * Filters whether to attempt to perform the multisite DB upgrade routine. * * In single site, the user would be redirected to wp-admin/upgrade.php. * In multisite, the DB upgrade routine is automatically fired, but only * when this filter returns true. * * If the network is 50 sites or less, it will run every time. Otherwise, * it will throttle itself to reduce load. * * @since MU (3.0.0) * * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. */ if ( apply_filters( 'do_mu_upgrade', true ) ) { $c = get_blog_count();
/* * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: * attempt to do no more than threshold value, with some +/- allowed. */ if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) === 1 ) ) { require_once ABSPATH . WPINC . '/http.php'; $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1', ) ); /** This action is documented in wp-admin/network/upgrade.php */ do_action( 'after_mu_upgrade', $response ); unset( $response ); } unset( $c ); } }
/** * $pagenow is set in vars.php. * $wp_importers is sometimes set in wp-admin/includes/import.php. * The remaining variables are imported as globals elsewhere, declared as globals here. * * @global string $pagenow The filename of the current screen. * @global array $wp_importers * @global string $hook_suffix * @global string $plugin_page * @global string $typenow The post type of the current screen. * @global string $taxnow The taxonomy of the current screen. */ global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
/** * Fires as an admin screen or script is being initialized. * * Note, this does not just run on user-facing admin screens. * It runs on admin-ajax.php and admin-post.php as well. * * This is roughly analogous to the more general {@see 'init'} hook, which fires earlier. * * @since 2.5.0 */ do_action( 'admin_init' );
// Handle plugin admin pages. if ( isset( $plugin_page ) ) { if ( $page_hook ) { /** * Fires before a particular screen is loaded. * * The load-* hook fires in a number of contexts. This hook is for plugin screens * where a callback is provided when the screen is registered. * * The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin * page information including: * 1. The page type. If the plugin page is registered as a submenu page, such as for * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. * 2. A separator of '_page_'. * 3. The plugin basename minus the file extension. * * Together, the three parts form the `$page_hook`. Citing the example above, * the hook name used would be 'load-settings_page_pluginbasename'. * * @see get_plugin_page_hook() * * @since 2.1.0 */ do_action( "load-{$page_hook}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores if ( ! isset( $_GET['noheader'] ) ) { require_once ABSPATH . 'wp-admin/admin-header.php'; }
/** * Used to call the registered callback for a plugin screen. * * This hook uses a dynamic hook name, `$page_hook`, which refers to a mixture of plugin * page information including: * 1. The page type. If the plugin page is registered as a submenu page, such as for * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. * 2. A separator of '_page_'. * 3. The plugin basename minus the file extension. * * Together, the three parts form the `$page_hook`. Citing the example above, * the hook name used would be 'settings_page_pluginbasename'. * * @see get_plugin_page_hook() * * @since 1.5.0 */ do_action( $page_hook ); } else { if ( validate_file( $plugin_page ) ) { wp_die( __( 'Invalid plugin page.' ) ); }
/** * Fires before a particular screen is loaded. * * The load-* hook fires in a number of contexts. This hook is for plugin screens * where the file to load is directly included, rather than the use of a function. * * The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename. * * @see plugin_basename() * * @since 1.5.0 */ do_action( "load-{$plugin_page}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/** * Filters whether to filter imported data through kses on import. * * Multisite uses this hook to filter all data through kses by default, * as a super administrator may be assisting an untrusted user. * * @since 3.1.0 * * @param bool $force Whether to force data to be filtered through kses. Default false. */ if ( apply_filters( 'force_filtered_html_on_import', false ) ) { kses_init_filters(); // Always filter imported data with kses on multisite. }
// Make sure rules are flushed. flush_rewrite_rules( false );
exit; } else { /** * Fires before a particular screen is loaded. * * The load-* hook fires in a number of contexts. This hook is for core screens. * * The dynamic portion of the hook name, `$pagenow`, is a global variable * referring to the filename of the current screen, such as 'admin.php', * 'post-new.php' etc. A complete hook for the latter would be * 'load-post-new.php'. * * @since 2.1.0 */ do_action( "load-{$pagenow}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/* * The following hooks are fired to ensure backward compatibility. * In all other cases, 'load-' . $pagenow should be used instead. */ if ( 'page' === $typenow ) { if ( 'post-new.php' === $pagenow ) { do_action( 'load-page-new.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } elseif ( 'post.php' === $pagenow ) { do_action( 'load-page.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } } elseif ( 'edit-tags.php' === $pagenow ) { if ( 'category' === $taxnow ) { do_action( 'load-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } elseif ( 'link_category' === $taxnow ) { do_action( 'load-edit-link-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } } elseif ( 'term.php' === $pagenow ) { do_action( 'load-edit-tags.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } }
/** * Fires when an 'action' request variable is sent. * * The dynamic portion of the hook name, `$action`, refers to * the action derived from the `GET` or `POST` request. * * @since 2.6.0 */ do_action( "admin_action_{$action}" ); }