admin-post.php (1671B)
1 <?php 2 /** 3 * WordPress Generic Request (POST/GET) Handler 4 * 5 * Intended for form submission handling in themes and plugins. 6 * 7 * @package WordPress 8 * @subpackage Administration 9 */ 10 11 /** We are located in WordPress Administration Screens */ 12 if ( ! defined( 'WP_ADMIN' ) ) { 13 define( 'WP_ADMIN', true ); 14 } 15 16 if ( defined( 'ABSPATH' ) ) { 17 require_once ABSPATH . 'wp-load.php'; 18 } else { 19 require_once dirname( __DIR__ ) . '/wp-load.php'; 20 } 21 22 /** Allow for cross-domain requests (from the front end). */ 23 send_origin_headers(); 24 25 require_once ABSPATH . 'wp-admin/includes/admin.php'; 26 27 nocache_headers(); 28 29 /** This action is documented in wp-admin/admin.php */ 30 do_action( 'admin_init' ); 31 32 $action = empty( $_REQUEST['action'] ) ? '' : $_REQUEST['action']; 33 34 if ( ! is_user_logged_in() ) { 35 if ( empty( $action ) ) { 36 /** 37 * Fires on a non-authenticated admin post request where no action is supplied. 38 * 39 * @since 2.6.0 40 */ 41 do_action( 'admin_post_nopriv' ); 42 } else { 43 /** 44 * Fires on a non-authenticated admin post request for the given action. 45 * 46 * The dynamic portion of the hook name, `$action`, refers to the given 47 * request action. 48 * 49 * @since 2.6.0 50 */ 51 do_action( "admin_post_nopriv_{$action}" ); 52 } 53 } else { 54 if ( empty( $action ) ) { 55 /** 56 * Fires on an authenticated admin post request where no action is supplied. 57 * 58 * @since 2.6.0 59 */ 60 do_action( 'admin_post' ); 61 } else { 62 /** 63 * Fires on an authenticated admin post request for the given action. 64 * 65 * The dynamic portion of the hook name, `$action`, refers to the given 66 * request action. 67 * 68 * @since 2.6.0 69 */ 70 do_action( "admin_post_{$action}" ); 71 } 72 }