summaryrefslogtreecommitdiffstats
path: root/wp-admin/admin-post.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
commita415c29efee45520ae252d2aa28f1083a521cd7b (patch)
treef4ade4b6668ecc0765de7e1424f7c1427ad433ff /wp-admin/admin-post.php
parentInitial commit. (diff)
downloadwordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.tar.xz
wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.zip
Adding upstream version 6.4.3+dfsg1.upstream/6.4.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-admin/admin-post.php')
-rw-r--r--wp-admin/admin-post.php87
1 files changed, 87 insertions, 0 deletions
diff --git a/wp-admin/admin-post.php b/wp-admin/admin-post.php
new file mode 100644
index 0000000..e71f5cd
--- /dev/null
+++ b/wp-admin/admin-post.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * WordPress Generic Request (POST/GET) Handler
+ *
+ * Intended for form submission handling in themes and plugins.
+ *
+ * @package WordPress
+ * @subpackage Administration
+ */
+
+/** We are located in WordPress Administration Screens */
+if ( ! defined( 'WP_ADMIN' ) ) {
+ define( 'WP_ADMIN', true );
+}
+
+if ( defined( 'ABSPATH' ) ) {
+ require_once ABSPATH . 'wp-load.php';
+} else {
+ require_once dirname( __DIR__ ) . '/wp-load.php';
+}
+
+/** Allow for cross-domain requests (from the front end). */
+send_origin_headers();
+
+require_once ABSPATH . 'wp-admin/includes/admin.php';
+
+nocache_headers();
+
+/** This action is documented in wp-admin/admin.php */
+do_action( 'admin_init' );
+
+$action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
+
+// Reject invalid parameters.
+if ( ! is_scalar( $action ) ) {
+ wp_die( '', 400 );
+}
+
+if ( ! is_user_logged_in() ) {
+ if ( empty( $action ) ) {
+ /**
+ * Fires on a non-authenticated admin post request where no action is supplied.
+ *
+ * @since 2.6.0
+ */
+ do_action( 'admin_post_nopriv' );
+ } else {
+ // If no action is registered, return a Bad Request response.
+ if ( ! has_action( "admin_post_nopriv_{$action}" ) ) {
+ wp_die( '', 400 );
+ }
+
+ /**
+ * Fires on a non-authenticated admin post request for the given action.
+ *
+ * The dynamic portion of the hook name, `$action`, refers to the given
+ * request action.
+ *
+ * @since 2.6.0
+ */
+ do_action( "admin_post_nopriv_{$action}" );
+ }
+} else {
+ if ( empty( $action ) ) {
+ /**
+ * Fires on an authenticated admin post request where no action is supplied.
+ *
+ * @since 2.6.0
+ */
+ do_action( 'admin_post' );
+ } else {
+ // If no action is registered, return a Bad Request response.
+ if ( ! has_action( "admin_post_{$action}" ) ) {
+ wp_die( '', 400 );
+ }
+
+ /**
+ * Fires on an authenticated admin post request for the given action.
+ *
+ * The dynamic portion of the hook name, `$action`, refers to the given
+ * request action.
+ *
+ * @since 2.6.0
+ */
+ do_action( "admin_post_{$action}" );
+ }
+}