author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 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 */ |
|
5 | 12 |
if ( ! defined( 'WP_ADMIN' ) ) { |
13 |
define( 'WP_ADMIN', true ); |
|
14 |
} |
|
0 | 15 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
16 |
/** Load WordPress Bootstrap */ |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
17 |
require_once dirname( __DIR__ ) . '/wp-load.php'; |
0 | 18 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
/** Allow for cross-domain requests (from the front end). */ |
0 | 20 |
send_origin_headers(); |
21 |
||
16 | 22 |
require_once ABSPATH . 'wp-admin/includes/admin.php'; |
0 | 23 |
|
24 |
nocache_headers(); |
|
25 |
||
26 |
/** This action is documented in wp-admin/admin.php */ |
|
27 |
do_action( 'admin_init' ); |
|
28 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
29 |
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
19 | 30 |
|
31 |
// Reject invalid parameters. |
|
32 |
if ( ! is_scalar( $action ) ) { |
|
33 |
wp_die( '', 400 ); |
|
34 |
} |
|
0 | 35 |
|
9 | 36 |
if ( ! is_user_logged_in() ) { |
5 | 37 |
if ( empty( $action ) ) { |
38 |
/** |
|
9 | 39 |
* Fires on a non-authenticated admin post request where no action is supplied. |
5 | 40 |
* |
41 |
* @since 2.6.0 |
|
42 |
*/ |
|
43 |
do_action( 'admin_post_nopriv' ); |
|
44 |
} else { |
|
19 | 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 |
||
5 | 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 |
/** |
|
9 | 63 |
* Fires on an authenticated admin post request where no action is supplied. |
5 | 64 |
* |
65 |
* @since 2.6.0 |
|
66 |
*/ |
|
67 |
do_action( 'admin_post' ); |
|
68 |
} else { |
|
19 | 69 |
// If no action is registered, return a Bad Request response. |
70 |
if ( ! has_action( "admin_post_{$action}" ) ) { |
|
71 |
wp_die( '', 400 ); |
|
72 |
} |
|
73 |
||
5 | 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 |
} |