| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Ai\SitePlannerConnect; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Just a simple rest api to validate new Site Planner Connect feature exists. |
| 11 |
*/ |
| 12 |
class Wp_Rest_Api { |
| 13 |
|
| 14 |
public function register(): void { |
| 15 |
register_rest_route('elementor-ai/v1', 'permissions', [ |
| 16 |
[ |
| 17 |
'methods' => \WP_REST_Server::READABLE, |
| 18 |
'permission_callback' => function () { |
| 19 |
return current_user_can( 'manage_options' ); |
| 20 |
}, |
| 21 |
'callback' => function () { |
| 22 |
try { |
| 23 |
wp_send_json_success( [ |
| 24 |
'site_planner_connect' => true, |
| 25 |
] ); |
| 26 |
} catch ( \Exception $e ) { |
| 27 |
wp_send_json_error( [ |
| 28 |
'message' => $e->getMessage(), |
| 29 |
] ); |
| 30 |
} |
| 31 |
}, |
| 32 |
], |
| 33 |
] ); |
| 34 |
} |
| 35 |
} |
| 36 |
|