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