2008-07-11 20:24:35 +00:00
|
|
|
<?php
|
2008-08-11 20:26:31 +00:00
|
|
|
/**
|
2013-09-22 05:18:09 +00:00
|
|
|
* WordPress Generic Request (POST/GET) Handler
|
|
|
|
*
|
|
|
|
* Intended for form submission handling in themes and plugins.
|
2008-08-11 20:26:31 +00:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
2011-04-28 15:24:49 +00:00
|
|
|
/** We are located in WordPress Administration Screens */
|
2014-05-18 20:42:16 +00:00
|
|
|
if ( ! defined( 'WP_ADMIN' ) ) {
|
|
|
|
define( 'WP_ADMIN', true );
|
|
|
|
}
|
2008-07-11 20:24:35 +00:00
|
|
|
|
2017-11-30 23:11:00 +00:00
|
|
|
if ( defined( 'ABSPATH' ) ) {
|
2020-02-06 06:33:11 +00:00
|
|
|
require_once ABSPATH . 'wp-load.php';
|
2017-11-30 23:11:00 +00:00
|
|
|
} else {
|
2020-02-06 06:33:11 +00:00
|
|
|
require_once dirname( __DIR__ ) . '/wp-load.php';
|
2017-11-30 23:11:00 +00:00
|
|
|
}
|
2008-07-11 20:24:35 +00:00
|
|
|
|
2016-02-25 12:53:27 +00:00
|
|
|
/** Allow for cross-domain requests (from the front end). */
|
2013-08-16 19:59:08 +00:00
|
|
|
send_origin_headers();
|
|
|
|
|
2020-02-06 06:33:11 +00:00
|
|
|
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
2008-07-11 20:24:35 +00:00
|
|
|
|
|
|
|
nocache_headers();
|
|
|
|
|
2013-10-24 22:59:20 +00:00
|
|
|
/** This action is documented in wp-admin/admin.php */
|
2013-09-23 23:48:09 +00:00
|
|
|
do_action( 'admin_init' );
|
2008-07-11 20:24:35 +00:00
|
|
|
|
2022-03-02 15:00:11 +00:00
|
|
|
$action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
|
|
|
|
|
|
|
// Reject invalid parameters.
|
|
|
|
if ( ! is_scalar( $action ) ) {
|
|
|
|
wp_die( '', 400 );
|
|
|
|
}
|
2014-05-08 10:47:15 +00:00
|
|
|
|
2019-01-16 05:41:50 +00:00
|
|
|
if ( ! is_user_logged_in() ) {
|
2014-05-13 07:24:15 +00:00
|
|
|
if ( empty( $action ) ) {
|
|
|
|
/**
|
2018-12-19 07:42:49 +00:00
|
|
|
* Fires on a non-authenticated admin post request where no action is supplied.
|
2014-05-13 07:24:15 +00:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*/
|
|
|
|
do_action( 'admin_post_nopriv' );
|
|
|
|
} else {
|
2022-03-02 15:00:11 +00:00
|
|
|
// If no action is registered, return a Bad Request response.
|
|
|
|
if ( ! has_action( "admin_post_nopriv_{$action}" ) ) {
|
|
|
|
wp_die( '', 400 );
|
|
|
|
}
|
|
|
|
|
2014-05-13 07:24:15 +00:00
|
|
|
/**
|
|
|
|
* Fires on a non-authenticated admin post request for the given action.
|
|
|
|
*
|
2014-11-30 11:42:24 +00:00
|
|
|
* The dynamic portion of the hook name, `$action`, refers to the given
|
2014-05-13 07:24:15 +00:00
|
|
|
* request action.
|
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*/
|
|
|
|
do_action( "admin_post_nopriv_{$action}" );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( empty( $action ) ) {
|
|
|
|
/**
|
2018-12-19 07:42:49 +00:00
|
|
|
* Fires on an authenticated admin post request where no action is supplied.
|
2014-05-13 07:24:15 +00:00
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*/
|
|
|
|
do_action( 'admin_post' );
|
|
|
|
} else {
|
2022-03-02 15:00:11 +00:00
|
|
|
// If no action is registered, return a Bad Request response.
|
|
|
|
if ( ! has_action( "admin_post_{$action}" ) ) {
|
|
|
|
wp_die( '', 400 );
|
|
|
|
}
|
|
|
|
|
2014-05-13 07:24:15 +00:00
|
|
|
/**
|
|
|
|
* Fires on an authenticated admin post request for the given action.
|
|
|
|
*
|
2014-11-30 11:42:24 +00:00
|
|
|
* The dynamic portion of the hook name, `$action`, refers to the given
|
2014-05-13 07:24:15 +00:00
|
|
|
* request action.
|
|
|
|
*
|
|
|
|
* @since 2.6.0
|
|
|
|
*/
|
|
|
|
do_action( "admin_post_{$action}" );
|
|
|
|
}
|
|
|
|
}
|