wp/wp-admin/admin-post.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    11 /** We are located in WordPress Administration Screens */
    11 /** We are located in WordPress Administration Screens */
    12 if ( ! defined( 'WP_ADMIN' ) ) {
    12 if ( ! defined( 'WP_ADMIN' ) ) {
    13 	define( 'WP_ADMIN', true );
    13 	define( 'WP_ADMIN', true );
    14 }
    14 }
    15 
    15 
    16 if ( defined('ABSPATH') )
    16 if ( defined( 'ABSPATH' ) ) {
    17 	require_once(ABSPATH . 'wp-load.php');
    17 	require_once( ABSPATH . 'wp-load.php' );
    18 else
    18 } else {
    19 	require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
    19 	require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
       
    20 }
    20 
    21 
    21 /** Allow for cross-domain requests (from the front end). */
    22 /** Allow for cross-domain requests (from the front end). */
    22 send_origin_headers();
    23 send_origin_headers();
    23 
    24 
    24 require_once(ABSPATH . 'wp-admin/includes/admin.php');
    25 require_once( ABSPATH . 'wp-admin/includes/admin.php' );
    25 
    26 
    26 nocache_headers();
    27 nocache_headers();
    27 
    28 
    28 /** This action is documented in wp-admin/admin.php */
    29 /** This action is documented in wp-admin/admin.php */
    29 do_action( 'admin_init' );
    30 do_action( 'admin_init' );
    30 
    31 
    31 $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
    32 $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
    32 
    33 
    33 if ( ! wp_validate_auth_cookie() ) {
    34 if ( ! is_user_logged_in() ) {
    34 	if ( empty( $action ) ) {
    35 	if ( empty( $action ) ) {
    35 		/**
    36 		/**
    36 		 * Fires on a non-authenticated admin post request where no action was supplied.
    37 		 * Fires on a non-authenticated admin post request where no action is supplied.
    37 		 *
    38 		 *
    38 		 * @since 2.6.0
    39 		 * @since 2.6.0
    39 		 */
    40 		 */
    40 		do_action( 'admin_post_nopriv' );
    41 		do_action( 'admin_post_nopriv' );
    41 	} else {
    42 	} else {
    50 		do_action( "admin_post_nopriv_{$action}" );
    51 		do_action( "admin_post_nopriv_{$action}" );
    51 	}
    52 	}
    52 } else {
    53 } else {
    53 	if ( empty( $action ) ) {
    54 	if ( empty( $action ) ) {
    54 		/**
    55 		/**
    55 		 * Fires on an authenticated admin post request where no action was supplied.
    56 		 * Fires on an authenticated admin post request where no action is supplied.
    56 		 *
    57 		 *
    57 		 * @since 2.6.0
    58 		 * @since 2.6.0
    58 		 */
    59 		 */
    59 		do_action( 'admin_post' );
    60 		do_action( 'admin_post' );
    60 	} else {
    61 	} else {