Make WordPress Core

Ticket #25442: 25442.2.diff

File 25442.2.diff, 6.5 KB (added by DrewAPicture, 12 years ago)

Second pass

  • src/wp-admin/admin.php

     
    3636        update_option( 'db_upgraded',  false );
    3737
    3838        /**
    39          * Runs on the next page load after successful upgrade
     39         * Fires on the next page load after successful upgrade.
    4040         *
    41          * @since 2.8
     41         * @since 2.8.0
    4242         */
    43         do_action('after_db_upgrade');
     43        do_action( 'after_db_upgrade' );
    4444} elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) {
    4545        if ( !is_multisite() ) {
    4646                wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
    4747                exit;
     48        /**
     49         * Filter whether to perform the Multisite upgrade routine.
     50         *
     51         * @since 3.0.0
     52         *
     53         * @param bool true Whether to perform the Multisite upgrade routine. Default true.
     54         */
    4855        } elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    4956                /**
    5057                 * On really small MU installs run the upgrader every time,
     
    5764                if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
    5865                        require_once( ABSPATH . WPINC . '/http.php' );
    5966                        $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
     67                        /**
     68                         * Fires after the Multisite upgrade is complete.
     69                         *
     70                         * @since 3.0.0
     71                         *
     72                         * @param array|WP_Error $response The upgrade response array or WP_Error on failure.
     73                         */
    6074                        do_action( 'after_mu_upgrade', $response );
    6175                        unset($response);
    6276                }
     
    103117else
    104118        require(ABSPATH . 'wp-admin/menu.php');
    105119
    106 if ( current_user_can( 'manage_options' ) )
     120if ( current_user_can( 'manage_options' ) ) {
     121        /**
     122         * Filter the maximum memory limit available for administration screens.
     123         *
     124         * The WP_MAX_MEMORY_LIMIT constant specifically defines the maximum memory limit available
     125         * when in the administration back-end. The default is 256M, or 256 megabytes of memory.
     126         *
     127         * @since 3.0.0
     128         *
     129         * @param string 'WP_MAX_MEMORY_LIMIT' The maximum WordPress memory limit. Default 256M.
     130         */
    107131        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
     132}
    108133
    109 do_action('admin_init');
     134/**
     135 * Fires at the beginning of any admin page, before the page is rendered.
     136 *
     137 * @since 2.5.0
     138 */
     139do_action( 'admin_init' );
    110140
    111141if ( isset($plugin_page) ) {
    112142        if ( !empty($typenow) )
     
    142172// Handle plugin admin pages.
    143173if ( isset($plugin_page) ) {
    144174        if ( $page_hook ) {
    145                 do_action('load-' . $page_hook);
     175                /**
     176                 * Fires before a plugin page is loaded where $page_hook is not empty.
     177                 *
     178                 * The dynamic portion of the hook name, $page_hook, refers to a mixture of plugin
     179                 * page information including:
     180                 * 1. The page type. If the plugin page is registered as a submenu page, such as for
     181                 *    Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'.
     182                 * 2. A separator of '_page_'.
     183                 * 3. The plugin basename minus the file extension.
     184                 *
     185                 * Together, the three parts form the $page_hook. Citing the example above,
     186                 * the hook name used would be 'load-settings_page_pluginbasename'.
     187                 *
     188                 * @see get_plugin_page_hook()
     189                 *
     190                 * @since 2.1.0
     191                 */
     192                do_action( 'load-' . $page_hook );
    146193                if (! isset($_GET['noheader']))
    147194                        require_once(ABSPATH . 'wp-admin/admin-header.php');
    148195
    149                 do_action($page_hook);
     196                /**
     197                 * Fires after the admin header is loaded for a plugin page where $page_hook is not empty.
     198                 *
     199                 * The dynamic hook name, $page_hook, refers to a mixture of plugin page information including:
     200                 * 1. The page type. If the plugin page is registered as a submenu page, such as for Settings,
     201                 *    the page type would be 'settings'. Otherwise the type is 'toplevel'.
     202                 * 2. A separator of '_page_'.
     203                 * 3. The plugin basename minus the file extension.
     204                 *
     205                 * Together, the three parts form the $page_hook. Citing the example above,
     206                 * the hook name used would be 'load-settings_page_pluginbasename'.
     207                 *
     208                 * @since 1.5.0
     209                 */
     210                do_action( $page_hook );
    150211        } else {
    151212                if ( validate_file($plugin_page) )
    152213                        wp_die(__('Invalid plugin page'));
     
    154215                if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) )
    155216                        wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
    156217
    157                 do_action('load-' . $plugin_page);
     218                /**
     219                 * Fires before a plugin page is loaded where $page_hook is empty.
     220                 *
     221                 * The dynamic portion of the hook name, $plugin_page, refers to the plugin basename.
     222                 *
     223                 * @see plugin_basename()
     224                 *
     225                 * @since 1.5.0
     226                 */
     227                do_action( 'load-' . $plugin_page );
    158228
    159229                if ( !isset($_GET['noheader']))
    160230                        require_once(ABSPATH . 'wp-admin/admin-header.php');
     
    185255                exit;
    186256        }
    187257
     258        /**
     259         * Fires before an importer page is loaded.
     260         *
     261         * The dynamic portion of the hook name, $importer, refers to the importer slug.
     262         *
     263         * @since 3.5.0
     264         */
    188265        do_action( 'load-importer-' . $importer );
    189266
    190267        $parent_file = 'tools.php';
     
    198275
    199276        define('WP_IMPORTING', true);
    200277
     278        /**
     279         * Whether to filter imported data through kses on import.
     280         *
     281         * In Multisite, imported data is filtered through kses by default
     282         * by filtering on this hook and returning true.
     283         *
     284         * @since 3.1.0
     285         *
     286         * @param bool false Whether to force data to be filtered through kses. Default false.
     287         */
    201288        if ( apply_filters( 'force_filtered_html_on_import', false ) )
    202289                kses_init_filters();  // Always filter imported data with kses on multisite.
    203290
     
    210297
    211298        exit();
    212299} else {
    213         do_action("load-$pagenow");
     300        /**
     301         * Fires before an admin page is loaded.
     302         *
     303         * The dynamic portion of the hook name, $pagenow, is a global variable
     304         * referring to the filename of the current page, such as 'admin.php',
     305         * 'post-new.php' etc. A complete hook for the latter would be 'load-post-new.php'.
     306         *
     307         * @since 2.1.0
     308         */
     309        do_action( 'load-' . $pagenow );
    214310        // Backwards compatibility with old load-page-new.php, load-page.php,
    215311        // and load-categories.php actions.
    216312        if ( $typenow == 'page' ) {
     
    226322        }
    227323}
    228324
    229 if ( !empty($_REQUEST['action']) )
     325if ( !empty($_REQUEST['action']) ) {
     326        /**
     327         * Fires before the page loads for the requested action.
     328         *
     329         * The dynamic portion of the hook name, $_REQUEST['action'], refers to the action
     330         * derived from the $_REQUEST super global passed to admin.php.
     331         *
     332         * @since 2.6.0
     333         */
    230334        do_action('admin_action_' . $_REQUEST['action']);
     335}