| 1 |
<?php |
| 2 |
|
| 3 |
if (!function_exists('add_action')) { |
| 4 |
function add_action($hookName, $callback, $priority = 10, $acceptedArgs = 1) |
| 5 |
{ |
| 6 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['actions'][$hookName][] = [ |
| 7 |
'callback' => $callback, |
| 8 |
'priority' => $priority, |
| 9 |
'accepted_args' => $acceptedArgs, |
| 10 |
]; |
| 11 |
|
| 12 |
return true; |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
if (!function_exists('did_action')) { |
| 17 |
function did_action($hookName) |
| 18 |
{ |
| 19 |
return $GLOBALS['sync_basalam_jobs_runner_test_state']['did_actions'][$hookName] ?? 0; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
if (!function_exists('wp_doing_ajax')) { |
| 24 |
function wp_doing_ajax() |
| 25 |
{ |
| 26 |
return $GLOBALS['sync_basalam_jobs_runner_test_state']['doing_ajax'] ?? false; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
if (!function_exists('wp_unslash')) { |
| 31 |
function wp_unslash($value) |
| 32 |
{ |
| 33 |
return is_string($value) ? stripslashes($value) : $value; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
if (!function_exists('sanitize_key')) { |
| 38 |
function sanitize_key($key) |
| 39 |
{ |
| 40 |
return preg_replace('/[^a-z0-9_\-]/', '', strtolower((string) $key)); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
if (!function_exists('get_transient')) { |
| 45 |
function get_transient($transient) |
| 46 |
{ |
| 47 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'get_transient'; |
| 48 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['transient_reads'][] = $transient; |
| 49 |
|
| 50 |
return $GLOBALS['sync_basalam_jobs_runner_test_state']['transients'][$transient] ?? false; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
if (!function_exists('set_transient')) { |
| 55 |
function set_transient($transient, $value, $expiration = 0) |
| 56 |
{ |
| 57 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'set_transient'; |
| 58 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['transient_writes'][] = [ |
| 59 |
'name' => $transient, |
| 60 |
'value' => $value, |
| 61 |
'expiration' => $expiration, |
| 62 |
]; |
| 63 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['transients'][$transient] = $value; |
| 64 |
|
| 65 |
return true; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
if (!function_exists('admin_url')) { |
| 70 |
function admin_url($path = '') |
| 71 |
{ |
| 72 |
return 'https://example.test/wp-admin/' . ltrim($path, '/'); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
if (!function_exists('add_query_arg')) { |
| 77 |
function add_query_arg($key, $value, $url) |
| 78 |
{ |
| 79 |
$separator = strpos($url, '?') === false ? '?' : '&'; |
| 80 |
|
| 81 |
return $url . $separator . rawurlencode((string) $key) . '=' . rawurlencode((string) $value); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
if (!function_exists('esc_url_raw')) { |
| 86 |
function esc_url_raw($url) |
| 87 |
{ |
| 88 |
return $url; |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
if (!function_exists('wp_create_nonce')) { |
| 93 |
function wp_create_nonce($action = -1) |
| 94 |
{ |
| 95 |
return 'test-nonce-for-' . $action; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
if (!function_exists('apply_filters')) { |
| 100 |
function apply_filters($hookName, $value) |
| 101 |
{ |
| 102 |
return $GLOBALS['sync_basalam_jobs_runner_test_state']['filter_values'][$hookName] ?? $value; |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
if (!function_exists('wp_remote_post')) { |
| 107 |
function wp_remote_post($url, $args = []) |
| 108 |
{ |
| 109 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['events'][] = 'remote_post'; |
| 110 |
$GLOBALS['sync_basalam_jobs_runner_test_state']['remote_requests'][] = [ |
| 111 |
'url' => $url, |
| 112 |
'args' => $args, |
| 113 |
]; |
| 114 |
|
| 115 |
return ['response' => ['code' => 200]]; |
| 116 |
} |
| 117 |
} |
| 118 |
|