PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 / modules / mcp / abilities / global-variables-resource-ability.php

global-variables-resource-ability.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/mcp/abilities/global-variables-resource-ability.php

59 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Mcp\Abilities;
4
5 use Elementor\Modules\Variables\Services\Batch_Operations\Batch_Processor;
6 use Elementor\Modules\Variables\Services\Variables_Service;
7 use Elementor\Modules\Variables\Storage\Variables_Repository;
8 use Elementor\Plugin;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 class Global_Variables_Resource_Ability extends Abstract_Ability {
15 const URI = 'elementor://global-variables';
16
17 protected function get_ability_id(): string {
18 return 'elementor/global-variables-resource';
19 }
20
21 protected function get_definition(): Ability_Definition {
22 return new Ability_Definition(
23 __( 'Global Variables', 'elementor' ),
24 __( 'Design tokens (colors, fonts, sizes) from the active kit; check before styling with variables.', 'elementor' ),
25 'elementor',
26 [ 'type' => 'string' ],
27 [
28 'mcp' => [
29 'type' => 'resource',
30 'uri' => self::URI,
31 'public' => true,
32 'mimeType' => 'application/json',
33 'description' => __( 'Design tokens (colors, fonts, sizes) from the active kit; check before styling with variables.', 'elementor' ),
34 ],
35 ],
36 fn() => current_user_can( 'edit_posts' )
37 );
38 }
39
40 public function execute( $input = [] ) {
41 $kit = Plugin::$instance->kits_manager->get_active_kit();
42
43 $variables_service = new Variables_Service(
44 new Variables_Repository( $kit ),
45 new Batch_Processor()
46 );
47
48 $variables_payload = $variables_service->load();
49
50 $data = $variables_payload['data'] ?? [];
51
52 return wp_json_encode( [
53 'variables' => (object) $data,
54 'total' => count( $data ),
55 'watermark' => $variables_payload['watermark'] ?? null,
56 ] );
57 }
58 }
59