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