| 1 |
<?php |
| 2 |
|
| 3 |
namespace Cookiez\Modules\Settings\Classes; |
| 4 |
|
| 5 |
use Cookiez\Classes\Rest\Route; |
| 6 |
use WP_REST_Response; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class Route_Base |
| 14 |
*/ |
| 15 |
class Route_Base extends Route { |
| 16 |
protected bool $override = false; |
| 17 |
protected $auth = true; |
| 18 |
protected string $path = ''; |
| 19 |
public function get_methods(): array { |
| 20 |
return []; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_endpoint(): string { |
| 24 |
return 'settings/' . $this->get_path(); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_path(): string { |
| 28 |
return $this->path; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_name(): string { |
| 32 |
return ''; |
| 33 |
} |
| 34 |
|
| 35 |
public function get_permission_callback( \WP_REST_Request $request ): bool { |
| 36 |
$valid = $this->permission_callback( $request ); |
| 37 |
|
| 38 |
return $valid && user_can( $this->current_user_id, 'manage_options' ); |
| 39 |
} |
| 40 |
} |
| 41 |
|