PluginProbe
Elementor Website Builder – more than just a page builder / 3.16.0-dev2
Elementor Website Builder – more than just a page builder v3.16.0-dev2
4.3.0-beta3 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 All 452 releases
elementor / app / modules / kit-library / data / kits / endpoints / favorites.php

favorites.php in Elementor Website Builder – more than just a page builder 3.16.0-dev2, at app/modules/kit-library/data/kits/endpoints/favorites.php

51 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\App\Modules\KitLibrary\Data\Kits\Endpoints;
3
4 use Elementor\App\Modules\KitLibrary\Data\Kits\Controller;
5 use Elementor\Data\V2\Base\Endpoint;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * @property Controller $controller
13 */
14 class Favorites extends Endpoint {
15 public function get_name() {
16 return 'favorites';
17 }
18
19 public function get_format() {
20 return 'kits/favorites/{id}';
21 }
22
23 protected function register() {
24 $args = [
25 'id_arg_type_regex' => '[\w]+',
26 ];
27
28 $this->register_item_route( \WP_REST_Server::CREATABLE, $args );
29 $this->register_item_route( \WP_REST_Server::DELETABLE, $args );
30 }
31
32 public function create_item( $id, $request ) {
33 $repository = $this->controller->get_repository();
34 $kit = $repository->add_to_favorites( $id );
35
36 return [
37 'data' => $kit,
38 ];
39 }
40
41 public function delete_item( $id, $request ) {
42 $repository = $this->controller->get_repository();
43
44 $kit = $repository->remove_from_favorites( $id );
45
46 return [
47 'data' => $kit,
48 ];
49 }
50 }
51