Make WordPress Core


Ignore:
Timestamp:
05/08/2014 10:26:07 AM (10 years ago)
Author:
DrewAPicture
Message:

Convert and rename the $action hook in wp-admin/admin-post to two dynamic hook sets.

  • admin_post_nopriv{$request_action} is fired for logged-out users
  • admin_post{$request_action} is fired for logged-in users

Props Otto42, DrewAPicture.
See #26869.

File:
1 edited

Legend:

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

    r25868 r28349  
    2727do_action( 'admin_init' );
    2828
    29 $action = 'admin_post';
     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  * admin_post_nopriv_{$_REQUEST['action']} is called for not-logged-in users.
    41  * admin_post_{$_REQUEST['action']} is called for logged-in users.
    42  *
    43  * @since 2.6.0
    44  */
    45 do_action( $action );
     31if ( ! wp_validate_auth_cookie() ) {
     32    /**
     33     * Fires the requested handler action for logged-out users.
     34     *
     35     * The dynamic portion of the hook name, $action, refers to the handler action.
     36     *
     37     * @since 2.6.0
     38     */
     39    do_action( "admin_post_nopriv{$action}" );
     40} else {
     41    /**
     42     * Fires the requested handler action for logged-in users.
     43     *
     44     * The dynamic portion of the hook name, $action, refers to the handler action.
     45     *
     46     * @since 2.6.0
     47     */
     48    do_action( "admin_post{$action}" );
     49}
Note: See TracChangeset for help on using the changeset viewer.