| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Data\Base; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Data\Manager; |
| 5 | -use Elementor\Plugin; | |
| 6 | 5 | use WP_REST_Controller; |
| 7 | 6 | use WP_REST_Server; |
| 8 | 7 | |
| 9 | 8 | abstract class Controller extends WP_REST_Controller { |
| @@ -24,15 +23,13 @@ | ||
| 24 | 23 | /** |
| 25 | 24 | * Controller constructor. |
| 26 | 25 | * |
| 27 | 26 | * Register endpoints on 'rest_api_init'. |
| 27 | + * | |
| 28 | 28 | */ |
| 29 | 29 | public function __construct() { |
| 30 | 30 | // TODO: Controllers and endpoints can have common interface. |
| 31 | 31 | |
| 32 | - // TODO: Uncomment when native 3rd plugins uses V2. | |
| 33 | - // $this->deprecated(); | |
| 34 | - | |
| 35 | 32 | $this->namespace = Manager::ROOT_NAMESPACE . '/v' . Manager::VERSION; |
| 36 | 33 | $this->rest_base = Manager::REST_BASE . $this->get_name(); |
| 37 | 34 | |
| 38 | 35 | add_action( 'rest_api_init', function () { |
| @@ -188,9 +185,9 @@ | ||
| 188 | 185 | protected function register_internal_endpoints() { |
| 189 | 186 | register_rest_route( $this->get_namespace(), '/' . $this->get_rest_base(), [ |
| 190 | 187 | [ |
| 191 | 188 | 'methods' => WP_REST_Server::READABLE, |
| 192 | - 'callback' => [ $this, 'get_items' ], | |
| 189 | + 'callback' => array( $this, 'get_items' ), | |
| 193 | 190 | 'args' => [], |
| 194 | 191 | 'permission_callback' => function ( $request ) { |
| 195 | 192 | return $this->get_permission_callback( $request ); |
| 196 | 193 | }, |
| @@ -303,9 +300,9 @@ | ||
| 303 | 300 | * Get permission callback. |
| 304 | 301 | * |
| 305 | 302 | * Default controller permission callback. |
| 306 | 303 | * By default endpoint will inherit the permission callback from the controller. |
| 307 | - * By default permission is `current_user_can( 'manage_options' );`. | |
| 304 | + * By default permission is `current_user_can( 'administrator' );`. | |
| 308 | 305 | * |
| 309 | 306 | * @param \WP_REST_Request $request |
| 310 | 307 | * |
| 311 | 308 | * @return bool |
| @@ -318,28 +315,10 @@ | ||
| 318 | 315 | case 'UPDATE': |
| 319 | 316 | case 'PUT': |
| 320 | 317 | case 'DELETE': |
| 321 | 318 | case 'PATCH': |
| 322 | - return current_user_can( 'manage_options' ); | |
| 319 | + return current_user_can( 'administrator' ); | |
| 323 | 320 | } |
| 324 | 321 | |
| 325 | 322 | return false; |
| 326 | - } | |
| 327 | - | |
| 328 | - private static $notify_deprecated = true; | |
| 329 | - | |
| 330 | - private function deprecated() { | |
| 331 | - add_action( 'elementor/init', function () { | |
| 332 | - if ( ! self::$notify_deprecated ) { | |
| 333 | - return; | |
| 334 | - } | |
| 335 | - | |
| 336 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( | |
| 337 | - 'Elementor\Data\Manager', | |
| 338 | - '3.5.0', | |
| 339 | - 'Elementor\Data\V2\Manager' | |
| 340 | - ); | |
| 341 | - | |
| 342 | - self::$notify_deprecated = false; | |
| 343 | - } ); | |
| 344 | 323 | } |
| 345 | 324 | } |