[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 /** Load WordPress Bootstrap */ 17 require_once dirname( __DIR__ ) . '/wp-load.php'; 18 19 /** Allow for cross-domain requests (from the front end). */ 20 send_origin_headers(); 21 22 require_once ABSPATH . 'wp-admin/includes/admin.php'; 23 24 nocache_headers(); 25 26 /** This action is documented in wp-admin/admin.php */ 27 do_action( 'admin_init' ); 28 29 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; 30 31 // Reject invalid parameters. 32 if ( ! is_scalar( $action ) ) { 33 wp_die( '', 400 ); 34 } 35 36 if ( ! is_user_logged_in() ) { 37 if ( empty( $action ) ) { 38 /** 39 * Fires on a non-authenticated admin post request where no action is supplied. 40 * 41 * @since 2.6.0 42 */ 43 do_action( 'admin_post_nopriv' ); 44 } else { 45 // If no action is registered, return a Bad Request response. 46 if ( ! has_action( "admin_post_nopriv_{$action}" ) ) { 47 wp_die( '', 400 ); 48 } 49 50 /** 51 * Fires on a non-authenticated admin post request for the given action. 52 * 53 * The dynamic portion of the hook name, `$action`, refers to the given 54 * request action. 55 * 56 * @since 2.6.0 57 */ 58 do_action( "admin_post_nopriv_{$action}" ); 59 } 60 } else { 61 if ( empty( $action ) ) { 62 /** 63 * Fires on an authenticated admin post request where no action is supplied. 64 * 65 * @since 2.6.0 66 */ 67 do_action( 'admin_post' ); 68 } else { 69 // If no action is registered, return a Bad Request response. 70 if ( ! has_action( "admin_post_{$action}" ) ) { 71 wp_die( '', 400 ); 72 } 73 74 /** 75 * Fires on an authenticated admin post request for the given action. 76 * 77 * The dynamic portion of the hook name, `$action`, refers to the given 78 * request action. 79 * 80 * @since 2.6.0 81 */ 82 do_action( "admin_post_{$action}" ); 83 } 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Tue Jan 21 08:20:01 2025 | Cross-referenced by PHPXref |