author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
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 |
|
9 | 16 |
if ( defined( 'ABSPATH' ) ) { |
16 | 17 |
require_once ABSPATH . 'wp-load.php'; |
9 | 18 |
} else { |
16 | 19 |
require_once dirname( __DIR__ ) . '/wp-load.php'; |
9 | 20 |
} |
0 | 21 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
/** Allow for cross-domain requests (from the front end). */ |
0 | 23 |
send_origin_headers(); |
24 |
||
16 | 25 |
require_once ABSPATH . 'wp-admin/includes/admin.php'; |
0 | 26 |
|
27 |
nocache_headers(); |
|
28 |
||
29 |
/** This action is documented in wp-admin/admin.php */ |
|
30 |
do_action( 'admin_init' ); |
|
31 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
$action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
19 | 33 |
|
34 |
// Reject invalid parameters. |
|
35 |
if ( ! is_scalar( $action ) ) { |
|
36 |
wp_die( '', 400 ); |
|
37 |
} |
|
0 | 38 |
|
9 | 39 |
if ( ! is_user_logged_in() ) { |
5 | 40 |
if ( empty( $action ) ) { |
41 |
/** |
|
9 | 42 |
* Fires on a non-authenticated admin post request where no action is supplied. |
5 | 43 |
* |
44 |
* @since 2.6.0 |
|
45 |
*/ |
|
46 |
do_action( 'admin_post_nopriv' ); |
|
47 |
} else { |
|
19 | 48 |
// If no action is registered, return a Bad Request response. |
49 |
if ( ! has_action( "admin_post_nopriv_{$action}" ) ) { |
|
50 |
wp_die( '', 400 ); |
|
51 |
} |
|
52 |
||
5 | 53 |
/** |
54 |
* Fires on a non-authenticated admin post request for the given action. |
|
55 |
* |
|
56 |
* The dynamic portion of the hook name, `$action`, refers to the given |
|
57 |
* request action. |
|
58 |
* |
|
59 |
* @since 2.6.0 |
|
60 |
*/ |
|
61 |
do_action( "admin_post_nopriv_{$action}" ); |
|
62 |
} |
|
63 |
} else { |
|
64 |
if ( empty( $action ) ) { |
|
65 |
/** |
|
9 | 66 |
* Fires on an authenticated admin post request where no action is supplied. |
5 | 67 |
* |
68 |
* @since 2.6.0 |
|
69 |
*/ |
|
70 |
do_action( 'admin_post' ); |
|
71 |
} else { |
|
19 | 72 |
// If no action is registered, return a Bad Request response. |
73 |
if ( ! has_action( "admin_post_{$action}" ) ) { |
|
74 |
wp_die( '', 400 ); |
|
75 |
} |
|
76 |
||
5 | 77 |
/** |
78 |
* Fires on an authenticated admin post request for the given action. |
|
79 |
* |
|
80 |
* The dynamic portion of the hook name, `$action`, refers to the given |
|
81 |
* request action. |
|
82 |
* |
|
83 |
* @since 2.6.0 |
|
84 |
*/ |
|
85 |
do_action( "admin_post_{$action}" ); |
|
86 |
} |
|
87 |
} |