| 1 |
<?php |
| 2 |
namespace HelloPlus\Modules\Admin\Classes\Rest; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
use HelloPlus\Modules\Admin\Module; |
| 9 |
|
| 10 |
class Whats_New { |
| 11 |
public function get_notifications() { |
| 12 |
/** |
| 13 |
* @var \HelloPlus\Modules\Admin\Components\Notificator $notifications_component |
| 14 |
*/ |
| 15 |
$notifications_component = Module::instance()->get_component( 'Notificator' ); |
| 16 |
return $notifications_component->get_notifications_by_conditions( true ); |
| 17 |
} |
| 18 |
|
| 19 |
public function rest_api_init() { |
| 20 |
register_rest_route( |
| 21 |
'elementor-hello-plus/v1', |
| 22 |
'/whats-new', |
| 23 |
[ |
| 24 |
'methods' => \WP_REST_Server::READABLE, |
| 25 |
'callback' => [ $this, 'get_notifications' ], |
| 26 |
'permission_callback' => function () { |
| 27 |
return current_user_can( 'manage_options' ); |
| 28 |
}, |
| 29 |
] |
| 30 |
); |
| 31 |
} |
| 32 |
|
| 33 |
public function __construct() { |
| 34 |
add_action( 'rest_api_init', [ $this, 'rest_api_init' ] ); |
| 35 |
} |
| 36 |
} |
| 37 |
|