__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace WP_Statistics\Components;
class Ajax
{
/**
* Registers an Ajax action with WordPress.
*
* @param string $action The name of the action to register.
* @param callable $callback The function to call when the action is triggered.
* @param bool $public Whether to register the action as public (i.e. accessible via non-logged-in users).
*
* @since 1.0.0
*/
public static function register($action, $callback, $public = true)
{
add_action('wp_ajax_wp_statistics_' . $action, $callback);
if ($public) {
add_action('wp_ajax_nopriv_wp_statistics_' . $action, $callback);
}
}
/**
* Sends a JSON response back to an Ajax request.
*
* @param bool $success Whether the request was successful.
* @param string $status The status of the request (e.g. "success", "error", "warning").
* @param string $message Optional. The message to send back to the client.
* @param mixed $data Optional. The data to send back to the client.
* @param int $code Optional. The HTTP status code to output. Default null.
*/
public static function send($success, $status, $message = null, $data = null, $code = null)
{
$response = [
'success' => (bool) $success,
'status' => $status
];
if ($message !== null) {
$response['message'] = $message;
}
if ($data !== null) {
$response['data'] = $data;
}
wp_send_json($response, $code);
}
/**
* Sends a JSON response back to an Ajax request, indicating success.
*
* @param string|null $message Optional. The message to send back to the client.
* @param mixed|null $data Optional. The data to send back to the client.
* @param int|null $code Optional. The HTTP status code to output. Default 200.
*/
public static function success($message = null, $data = null, $code = 200)
{
self::send(true, 'success', $message, $data, $code);
}
/**
* Sends a JSON response back to an Ajax request, indicating failure.
*
* @param string $message The message to send back to the client.
* @param mixed|null $data Optional. The data to send back to the client.
* @param int|null $code Optional. The HTTP status code to output. Default 400.
*/
public static function error($message, $data = null, $code = 400)
{
self::send(false, 'error', $message, $data, $code);
}
}| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Ajax.php | File | 2.48 KB | 0644 |
|
| AssetNameObfuscator.php | File | 10.15 KB | 0644 |
|
| Assets.php | File | 6.77 KB | 0644 |
|
| DateRange.php | File | 18.3 KB | 0644 |
|
| DateTime.php | File | 6.08 KB | 0644 |
|
| Encryptor.php | File | 3.4 KB | 0644 |
|
| Event.php | File | 2.68 KB | 0644 |
|
| RemoteRequest.php | File | 6.16 KB | 0644 |
|
| Singleton.php | File | 602 B | 0644 |
|
| SystemCleaner.php | File | 841 B | 0644 |
|
| View.php | File | 1.53 KB | 0644 |
|