WordPress.org

Make WordPress Core

Changeset 28394


Ignore:
Timestamp:
05/13/2014 07:23:35 AM (4 years ago)
Author:
DrewAPicture
Message:

Properly split and document the admin_post* actions into the following four hooks:

  • admin_post_nopriv – for logged-out requests lacking a supplied action
  • `admin_post_nopriv_$action – for logged-out requests with a supplied action
  • admin_post – for logged-in requests lacking a supplied action
  • admin_post_$action – for logged-in requests with a supplied action

See [28349], [28350], [28351].
See #26869.

File:
1 edited

Legend:

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

    r28351 r28394  
    2727do_action( 'admin_init' );
    2828
    29 $action = '';
     29$action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
    3030
    31 if ( !wp_validate_auth_cookie() )
    32     $action .= '_nopriv';
    33 
    34 if ( !empty($_REQUEST['action']) )
    35     $action .= '_' . $_REQUEST['action'];
    36 
    37 /**
    38  * Fires the requested handler action.
    39  *
    40  * The dynamic portion of the hook name, $action, refers to a combination
    41  * of whether the user is logged-in or not, and the requested handler action.
    42  *
    43  * If the user is logged-out, '_nopriv' will be affixed to the
    44  * base "admin_post" hook name. If a handler action was passed, that action
    45  * will also be affixed.
    46  *
    47  * For example:
    48  * Hook combinations fired for logged-out users:
    49  * `admin_post_nopriv_{$action}` and `admin_post_nopriv` (no action supplied).
    50  *
    51  * Hook combinations fired for logged-in users:
    52  * `admin_post_{$action}` and `admin_post` (no action supplied).
    53  *
    54  * @since 2.6.0
    55  */
    56 do_action( "admin_post{$action}" );
     31if ( ! wp_validate_auth_cookie() ) {
     32    if ( empty( $action ) ) {
     33        /**
     34         * Fires on a non-authenticated admin post request where no action was supplied.
     35         *
     36         * @since 2.6.0
     37         */
     38        do_action( 'admin_post_nopriv' );
     39    } else {
     40        /**
     41         * Fires on a non-authenticated admin post request for the given action.
     42         *
     43         * The dynamic portion of the hook name, $action, refers to the given
     44         * request action.
     45         *
     46         * @since 2.6.0
     47         */
     48        do_action( "admin_post_nopriv_{$action}" );
     49    }
     50} else {
     51    if ( empty( $action ) ) {
     52        /**
     53         * Fires on an authenticated admin post request where no action was supplied.
     54         *
     55         * @since 2.6.0
     56         */
     57        do_action( 'admin_post' );
     58    } else {
     59        /**
     60         * Fires on an authenticated admin post request for the given action.
     61         *
     62         * The dynamic portion of the hook name, $action, refers to the given
     63         * request action.
     64         *
     65         * @since 2.6.0
     66         */
     67        do_action( "admin_post_{$action}" );
     68    }
     69}
Note: See TracChangeset for help on using the changeset viewer.