PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-dev3
Elementor Website Builder – more than just a page builder v4.1.0-dev3
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
elementor / app / modules / kit-library / data / kits / controller.php

controller.php in Elementor Website Builder – more than just a page builder 4.1.0-dev3, at app/modules/kit-library/data/kits/controller.php

66 lines 1.5 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;
3
4 use Elementor\App\Modules\KitLibrary\Data\Base_Controller;
5 use Elementor\Data\V2\Base\Exceptions\Error_404;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 class Controller extends Base_Controller {
12
13 public function get_name() {
14 return 'kits';
15 }
16
17 public function get_items( $request ) {
18 $data = $this->get_repository()->get_all( $request->get_param( 'force' ) );
19
20 return [
21 'data' => $data->values(),
22 ];
23 }
24
25 public function get_item( $request ) {
26 $data = $this->get_repository()->find( $request->get_param( 'id' ) );
27
28 if ( ! $data ) {
29 return new Error_404( esc_html__( 'Kit not exists.', 'elementor' ), 'kit_not_exists' );
30 }
31
32 return [
33 'data' => $data,
34 ];
35 }
36
37 public function get_collection_params() {
38 return [
39 'force' => [
40 'description' => 'Force an API request and skip the cache.',
41 'required' => false,
42 'default' => false,
43 'type' => 'boolean',
44 ],
45 ];
46 }
47
48 public function register_endpoints() {
49 $this->index_endpoint->register_item_route( \WP_REST_Server::READABLE, [
50 'id' => [
51 'description' => 'Unique identifier for the object.',
52 'type' => 'string',
53 'required' => true,
54 ],
55 'id_arg_type_regex' => '[\w]+',
56 ] );
57
58 $this->register_endpoint( new Endpoints\Download_Link( $this ) );
59 $this->register_endpoint( new Endpoints\Favorites( $this ) );
60 }
61
62 public function get_permission_callback( $request ) {
63 return current_user_can( 'manage_options' );
64 }
65 }
66