Make WordPress Core

Changeset 25747


Ignore:
Timestamp:
10/09/2013 09:00:41 PM (11 years ago)
Author:
nacin
Message:

Hook documentation for wp-admin/admin.php.

props DrewAPicture for initial patch.
fixes #25442.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/admin.php

    r23563 r25747  
    3737
    3838    /**
    39      * Runs on the next page load after successful upgrade
    40      *
    41      * @since 2.8
    42      */
    43     do_action('after_db_upgrade');
     39     * Fires on the next page load after a successful DB upgrade.
     40     *
     41     * @since 2.8.0
     42     */
     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    /**
     50     * Filter whether to attempt to perform the multisite DB upgrade routine.
     51     *
     52     * In single site, the user would be redirected to wp-admin/upgrade.php.
     53     * In multisite, it is automatically fired, but only when this filter
     54     * returns true.
     55     *
     56     * If the network is 50 sites or less, it will run every time. Otherwise,
     57     * it will throttle itself to reduce load.
     58     *
     59     * @since 3.0.0
     60     *
     61     * @param bool true Whether to perform the Multisite upgrade routine. Default true.
     62     */
    4863    } elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    49         /**
    50          * On really small MU installs run the upgrader every time,
    51          * else run it less often to reduce load.
    52          *
    53          * @since 2.8.4b
    54          */
    5564        $c = get_blog_count();
    5665        // If 50 or fewer sites, run every time. Else, run "about ten percent" of the time. Shh, don't check that math.
     
    5867            require_once( ABSPATH . WPINC . '/http.php' );
    5968            $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
     69            /**
     70             * Fires after the multisite DB upgrade is complete.
     71             *
     72             * @since 3.0.0
     73             *
     74             * @param array|WP_Error $response The upgrade response array or WP_Error on failure.
     75             */
    6076            do_action( 'after_mu_upgrade', $response );
    6177            unset($response);
     
    104120    require(ABSPATH . 'wp-admin/menu.php');
    105121
    106 if ( current_user_can( 'manage_options' ) )
     122if ( current_user_can( 'manage_options' ) ) {
     123    /**
     124     * Filter the maximum memory limit available for administration screens.
     125     *
     126     * This only applies to administrators, who may require more memory for tasks like updates.
     127     * Memory limits when processing images (uploaded or edited by users of any role) are
     128     * handled separately.
     129     *
     130     * The WP_MAX_MEMORY_LIMIT constant specifically defines the maximum memory limit available
     131     * when in the administration back-end. The default is 256M, or 256 megabytes of memory.
     132     *
     133     * @since 3.0.0
     134     *
     135     * @param string 'WP_MAX_MEMORY_LIMIT' The maximum WordPress memory limit. Default 256M.
     136     */
    107137    @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
    108 
    109 do_action('admin_init');
     138}
     139
     140/**
     141 * Fires as an admin screen or script is being initialized.
     142 *
     143 * Note, this does not just run on user-facing admin screens.
     144 * It runs on admin-ajax.php and admin-post.php as well.
     145 *
     146 * This is roughly analgous to the more general 'init' hook, which fires earlier.
     147 *
     148 * @since 2.5.0
     149 */
     150do_action( 'admin_init' );
    110151
    111152if ( isset($plugin_page) ) {
     
    143184if ( isset($plugin_page) ) {
    144185    if ( $page_hook ) {
    145         do_action('load-' . $page_hook);
     186        /**
     187         * Fires before a particular screen is loaded.
     188         *
     189         * The load-* hook fires in a number of contexts. This hook is for plugin screens
     190         * where a callback is provided when the screen is registered.
     191         *
     192         * The dynamic portion of the hook name, $page_hook, refers to a mixture of plugin
     193         * page information including:
     194         * 1. The page type. If the plugin page is registered as a submenu page, such as for
     195         *    Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'.
     196         * 2. A separator of '_page_'.
     197         * 3. The plugin basename minus the file extension.
     198         *
     199         * Together, the three parts form the $page_hook. Citing the example above,
     200         * the hook name used would be 'load-settings_page_pluginbasename'.
     201         *
     202         * @see get_plugin_page_hook()
     203         *
     204         * @since 2.1.0
     205         */
     206        do_action( 'load-' . $page_hook );
    146207        if (! isset($_GET['noheader']))
    147208            require_once(ABSPATH . 'wp-admin/admin-header.php');
    148209
    149         do_action($page_hook);
     210        /**
     211         * Used to call the registered callback for a plugin screen.
     212         *
     213         * @access private
     214         *
     215         * @since 1.5.0
     216         */
     217        do_action( $page_hook );
    150218    } else {
    151219        if ( validate_file($plugin_page) )
     
    155223            wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
    156224
    157         do_action('load-' . $plugin_page);
     225        /**
     226         * Fires before a particular screen is loaded.
     227         *
     228         * The load-* hook fires in a number of contexts. This hook is for plugin screens
     229         * where the file to load is directly included, rather than the use of a function.
     230         *
     231         * The dynamic portion of the hook name, $plugin_page, refers to the plugin basename.
     232         *
     233         * @see plugin_basename()
     234         *
     235         * @since 1.5.0
     236         */
     237        do_action( 'load-' . $plugin_page );
    158238
    159239        if ( !isset($_GET['noheader']))
     
    186266    }
    187267
     268    /**
     269     * Fires before an importer screen is loaded.
     270     *
     271     * The dynamic portion of the hook name, $importer, refers to the importer slug.
     272     *
     273     * @since 3.5.0
     274     */
    188275    do_action( 'load-importer-' . $importer );
    189276
     
    199286    define('WP_IMPORTING', true);
    200287
     288    /**
     289     * Whether to filter imported data through kses on import.
     290     *
     291     * Multisite uses this hook to filter all data through kses by default,
     292     * as a super administrator may be assisting an untrusted user.
     293     *
     294     * @since 3.1.0
     295     *
     296     * @param bool false Whether to force data to be filtered through kses. Default false.
     297     */
    201298    if ( apply_filters( 'force_filtered_html_on_import', false ) )
    202299        kses_init_filters();  // Always filter imported data with kses on multisite.
     
    211308    exit();
    212309} else {
    213     do_action("load-$pagenow");
     310    /**
     311     * Fires before a particular screen is loaded.
     312     *
     313     * The load-* hook fires in a number of contexts. This hook is for core screens.
     314     *
     315     * The dynamic portion of the hook name, $pagenow, is a global variable
     316     * referring to the filename of the current page, such as 'admin.php',
     317     * 'post-new.php' etc. A complete hook for the latter would be 'load-post-new.php'.
     318     *
     319     * @since 2.1.0
     320     */
     321    do_action( 'load-' . $pagenow );
    214322    // Backwards compatibility with old load-page-new.php, load-page.php,
    215323    // and load-categories.php actions.
     
    227335}
    228336
    229 if ( !empty($_REQUEST['action']) )
    230     do_action('admin_action_' . $_REQUEST['action']);
     337if ( ! empty( $_REQUEST['action'] ) ) {
     338    /**
     339     * Fires when an 'action' request variable is sent.
     340     *
     341     * The dynamic portion of the hook name, $_REQUEST['action'],
     342     * refers to the action derived from the GET or POST request.
     343     *
     344     * @since 2.6.0
     345     */
     346    do_action( 'admin_action_' . $_REQUEST['action'] );
     347}
Note: See TracChangeset for help on using the changeset viewer.