wp/wp-admin/admin-post.php
changeset 19 3d72ae0968f4
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    27 nocache_headers();
    27 nocache_headers();
    28 
    28 
    29 /** This action is documented in wp-admin/admin.php */
    29 /** This action is documented in wp-admin/admin.php */
    30 do_action( 'admin_init' );
    30 do_action( 'admin_init' );
    31 
    31 
    32 $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action'];
    32 $action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
       
    33 
       
    34 // Reject invalid parameters.
       
    35 if ( ! is_scalar( $action ) ) {
       
    36 	wp_die( '', 400 );
       
    37 }
    33 
    38 
    34 if ( ! is_user_logged_in() ) {
    39 if ( ! is_user_logged_in() ) {
    35 	if ( empty( $action ) ) {
    40 	if ( empty( $action ) ) {
    36 		/**
    41 		/**
    37 		 * Fires on a non-authenticated admin post request where no action is supplied.
    42 		 * Fires on a non-authenticated admin post request where no action is supplied.
    38 		 *
    43 		 *
    39 		 * @since 2.6.0
    44 		 * @since 2.6.0
    40 		 */
    45 		 */
    41 		do_action( 'admin_post_nopriv' );
    46 		do_action( 'admin_post_nopriv' );
    42 	} else {
    47 	} else {
       
    48 		// If no action is registered, return a Bad Request response.
       
    49 		if ( ! has_action( "admin_post_nopriv_{$action}" ) ) {
       
    50 			wp_die( '', 400 );
       
    51 		}
       
    52 
    43 		/**
    53 		/**
    44 		 * Fires on a non-authenticated admin post request for the given action.
    54 		 * Fires on a non-authenticated admin post request for the given action.
    45 		 *
    55 		 *
    46 		 * The dynamic portion of the hook name, `$action`, refers to the given
    56 		 * The dynamic portion of the hook name, `$action`, refers to the given
    47 		 * request action.
    57 		 * request action.
    57 		 *
    67 		 *
    58 		 * @since 2.6.0
    68 		 * @since 2.6.0
    59 		 */
    69 		 */
    60 		do_action( 'admin_post' );
    70 		do_action( 'admin_post' );
    61 	} else {
    71 	} else {
       
    72 		// If no action is registered, return a Bad Request response.
       
    73 		if ( ! has_action( "admin_post_{$action}" ) ) {
       
    74 			wp_die( '', 400 );
       
    75 		}
       
    76 
    62 		/**
    77 		/**
    63 		 * Fires on an authenticated admin post request for the given action.
    78 		 * Fires on an authenticated admin post request for the given action.
    64 		 *
    79 		 *
    65 		 * The dynamic portion of the hook name, `$action`, refers to the given
    80 		 * The dynamic portion of the hook name, `$action`, refers to the given
    66 		 * request action.
    81 		 * request action.