<?php

namespace CodeConfig\EAW\Ajax;

use CodeConfig\EAW\Utils\Helpers;

defined('ABSPATH') || exit('No direct script access allowed');

class Category
{
    public static function get()
    {
        check_ajax_referer('ccpeaw', 'eaw_nonce');

        $category_id = intval(wp_unslash($_POST['categoryId'] ?? 0));

        $category = Helpers::getCategory($category_id);

        return wp_send_json_success([
            'success' => true,
            'data'    => $category
        ]);
    }
}
