PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.3
Elementor Website Builder – more than just a page builder v3.0.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | data/base/controller.php +4 -58 4.2.13.0.3 View file →
@@ -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 () {
@@ -138,41 +135,8 @@
138 135 return $this->get_controller_index();
139 136 }
140 137
141 138 /**
142 - * Creates multiple items.
143 - *
144 - * @param \WP_REST_Request $request Full data about the request.
145 - *
146 - * @return \WP_Error|\WP_REST_Response Response object on success, or WP_Error object on failure.
147 - */
148 - public function create_items( $request ) {
149 - return new \WP_Error( 'invalid-method', sprintf( "Method '%s' not implemented. Must be overridden in subclass.", __METHOD__ ), [ 'status' => 405 ] );
150 - }
151 -
152 - /**
153 - * Updates multiple items.
154 - *
155 - * @param \WP_REST_Request $request Full data about the request.
156 - *
157 - * @return \WP_Error|\WP_REST_Response Response object on success, or WP_Error object on failure.
158 - */
159 - public function update_items( $request ) {
160 - return new \WP_Error( 'invalid-method', sprintf( "Method '%s' not implemented. Must be overridden in subclass.", __METHOD__ ), [ 'status' => 405 ] );
161 - }
162 -
163 - /**
164 - * Delete multiple items.
165 - *
166 - * @param \WP_REST_Request $request Full data about the request.
167 - *
168 - * @return \WP_Error|\WP_REST_Response Response object on success, or WP_Error object on failure.
169 - */
170 - public function delete_items( $request ) {
171 - return new \WP_Error( 'invalid-method', sprintf( "Method '%s' not implemented. Must be overridden in subclass.", __METHOD__ ), [ 'status' => 405 ] );
172 - }
173 -
174 - /**
175 139 * Register endpoints.
176 140 */
177 141 abstract public function register_endpoints();
178 142
@@ -188,9 +152,9 @@
188 152 protected function register_internal_endpoints() {
189 153 register_rest_route( $this->get_namespace(), '/' . $this->get_rest_base(), [
190 154 [
191 155 'methods' => WP_REST_Server::READABLE,
192 - 'callback' => [ $this, 'get_items' ],
156 + 'callback' => array( $this, 'get_items' ),
193 157 'args' => [],
194 158 'permission_callback' => function ( $request ) {
195 159 return $this->get_permission_callback( $request );
196 160 },
@@ -303,9 +267,9 @@
303 267 * Get permission callback.
304 268 *
305 269 * Default controller permission callback.
306 270 * By default endpoint will inherit the permission callback from the controller.
307 - * By default permission is `current_user_can( 'manage_options' );`.
271 + * By default permission is `current_user_can( 'administrator' );`.
308 272 *
309 273 * @param \WP_REST_Request $request
310 274 *
311 275 * @return bool
@@ -318,28 +282,10 @@
318 282 case 'UPDATE':
319 283 case 'PUT':
320 284 case 'DELETE':
321 285 case 'PATCH':
322 - return current_user_can( 'manage_options' );
286 + return current_user_can( 'administrator' );
323 287 }
324 288
325 289 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 290 }
345 291 }