| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 2.1.22 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2024 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Notices; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
class Ajax |
| 20 |
{ |
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
add_action('wp_ajax_firebox_get_notices', [$this, 'get_notices']); |
| 24 |
add_action('wp_ajax_nopriv_firebox_get_notices', [$this, 'get_notices']); |
| 25 |
|
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Get Notices. |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
public function get_notices() |
| 35 |
{ |
| 36 |
if (!current_user_can('manage_options')) |
| 37 |
{ |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
$nonce = isset($_GET['nonce']) ? sanitize_text_field($_GET['nonce']) : ''; |
| 42 |
|
| 43 |
// verify nonce |
| 44 |
if (!$verify = wp_verify_nonce($nonce, 'firebox_notices')) |
| 45 |
{ |
| 46 |
return false; |
| 47 |
} |
| 48 |
|
| 49 |
$exclude = isset($_GET['exclude']) ? sanitize_text_field($_GET['exclude']) : ''; |
| 50 |
$exclude = array_filter(explode(',', $exclude)); |
| 51 |
|
| 52 |
$notices = \FireBox\Core\Notices\Notices::getInstance([ |
| 53 |
'exclude' => $exclude |
| 54 |
])->getNotices(); |
| 55 |
|
| 56 |
echo wp_json_encode([ |
| 57 |
'error' => false, |
| 58 |
'notices' => $notices |
| 59 |
]); |
| 60 |
wp_die(); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
} |