Skip to content

Commit e2dc62f

Browse files
committed
fix: ajax routes action parameter issue
1 parent c55ffb1 commit e2dc62f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

includes/Core/Util/Route.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,36 @@ public static function post($hook, $invokeable)
2626

2727
public static function request($method, $hook, $invokeable)
2828
{
29-
if ((isset($_SERVER['REQUEST_METHOD']) && sanitize_text_field($_SERVER['REQUEST_METHOD']) != $method) || !isset($_REQUEST['action']) || (isset($_REQUEST['action']) && strpos(sanitize_text_field($_REQUEST['action']), $hook) === false)) {
29+
$action = $_REQUEST['action'] ?? $_POST['action'] ?? $_GET['action'];
30+
31+
if (
32+
(isset($_SERVER['REQUEST_METHOD']) && sanitize_text_field($_SERVER['REQUEST_METHOD']) != $method)
33+
|| empty($action)
34+
|| (!empty($action) && strpos(sanitize_text_field($action), $hook) === false)
35+
) {
3036
if (static::$_no_auth) {
3137
static::$_no_auth = false;
3238
}
39+
3340
if (static::$_ignore_token) {
3441
static::$_ignore_token = false;
3542
}
3643

3744
return;
3845
}
46+
3947
if (static::$_ignore_token) {
4048
static::$_ignore_token = false;
4149
static::$_invokeable[static::$_prefix . $hook][$method . '_ignore_token'] = true;
4250
}
51+
4352
static::$_invokeable[static::$_prefix . $hook][$method] = $invokeable;
53+
4454
Hooks::add('wp_ajax_' . static::$_prefix . $hook, [__CLASS__, 'action']);
55+
4556
if (static::$_no_auth) {
4657
static::$_no_auth = false;
58+
4759
Hooks::add('wp_ajax_nopriv_' . static::$_prefix . $hook, [__CLASS__, 'action']);
4860
}
4961
}

0 commit comments

Comments
 (0)