HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/wp-content/plugins/affiliatex/includes/helpers/ResponseHelper.php
<?php

namespace AffiliateX\Helpers;

defined('ABSPATH') or exit;

/**
 * Response helper for API and AJAX responses
 * 
 * @package AffiliateX
 */
trait ResponseHelper{

    /**
     * Send json success message to API and AJAX responses
     *
     * @param string $message
     * @param array $data
     * @return void
     */
    private function send_json_success(string $message, array $data = []) : void
    {
        wp_send_json_success(array_merge(
            ['message' => $message],
            $data
        ));
    }

    /**
     * Send json success with plain data to API and AJAX responses
     *
     * @param array $data
     * @return void
     */
    private function send_json_plain_success(array $data = []) : void
    {
        wp_send_json_success($data);
    }

    /**
     * Send json error message to API and AJAX responses
     *
     * @param string $message
     * @param array $data
     * @return void
     */
    private function send_json_error(string $message, array $data = []) : void
    {
        wp_send_json_error(array_merge(
            ['message' => $message],
            $data
        ));
    }

    /**
     * Send json error with plain data to API and AJAX responses
     *
     * @param array $data
     * @return void
     */
    private function send_json_plain_error(array $data = []) : void
    {
        wp_send_json_error($data);
    }
}