wp/wp-admin/admin-post.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
     7  * @package WordPress
     7  * @package WordPress
     8  * @subpackage Administration
     8  * @subpackage Administration
     9  */
     9  */
    10 
    10 
    11 /** We are located in WordPress Administration Screens */
    11 /** We are located in WordPress Administration Screens */
    12 define('WP_ADMIN', true);
    12 if ( ! defined( 'WP_ADMIN' ) ) {
       
    13 	define( 'WP_ADMIN', true );
       
    14 }
    13 
    15 
    14 if ( defined('ABSPATH') )
    16 if ( defined('ABSPATH') )
    15 	require_once(ABSPATH . 'wp-load.php');
    17 	require_once(ABSPATH . 'wp-load.php');
    16 else
    18 else
    17 	require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    19 	require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    24 nocache_headers();
    26 nocache_headers();
    25 
    27 
    26 /** This action is documented in wp-admin/admin.php */
    28 /** This action is documented in wp-admin/admin.php */
    27 do_action( 'admin_init' );
    29 do_action( 'admin_init' );
    28 
    30 
    29 $action = 'admin_post';
    31 $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
    30 
    32 
    31 if ( !wp_validate_auth_cookie() )
    33 if ( ! wp_validate_auth_cookie() ) {
    32 	$action .= '_nopriv';
    34 	if ( empty( $action ) ) {
    33 
    35 		/**
    34 if ( !empty($_REQUEST['action']) )
    36 		 * Fires on a non-authenticated admin post request where no action was supplied.
    35 	$action .= '_' . $_REQUEST['action'];
    37 		 *
    36 
    38 		 * @since 2.6.0
    37 /**
    39 		 */
    38  * Fires the requested handler action.
    40 		do_action( 'admin_post_nopriv' );
    39  *
    41 	} else {
    40  * admin_post_nopriv_{$_REQUEST['action']} is called for not-logged-in users.
    42 		/**
    41  * admin_post_{$_REQUEST['action']} is called for logged-in users.
    43 		 * Fires on a non-authenticated admin post request for the given action.
    42  *
    44 		 *
    43  * @since 2.6.0
    45 		 * The dynamic portion of the hook name, `$action`, refers to the given
    44  */
    46 		 * request action.
    45 do_action( $action );
    47 		 *
       
    48 		 * @since 2.6.0
       
    49 		 */
       
    50 		do_action( "admin_post_nopriv_{$action}" );
       
    51 	}
       
    52 } else {
       
    53 	if ( empty( $action ) ) {
       
    54 		/**
       
    55 		 * Fires on an authenticated admin post request where no action was supplied.
       
    56 		 *
       
    57 		 * @since 2.6.0
       
    58 		 */
       
    59 		do_action( 'admin_post' );
       
    60 	} else {
       
    61 		/**
       
    62 		 * Fires on an authenticated admin post request for the given action.
       
    63 		 *
       
    64 		 * The dynamic portion of the hook name, `$action`, refers to the given
       
    65 		 * request action.
       
    66 		 *
       
    67 		 * @since 2.6.0
       
    68 		 */
       
    69 		do_action( "admin_post_{$action}" );
       
    70 	}
       
    71 }