PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.0-beta1
Elementor Website Builder – more than just a page builder v3.34.0-beta1
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 / modules / variables / module.php

module.php in Elementor Website Builder – more than just a page builder 3.34.0-beta1, at modules/variables/module.php

81 lines 2.4 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\Variables;
4
5 use Elementor\Core\Base\Module as BaseModule;
6 use Elementor\Core\Experiments\Manager as ExperimentsManager;
7 use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule;
8 use Elementor\Modules\Variables\Classes\Variable_Types_Registry;
9 use Elementor\Plugin;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 class Module extends BaseModule {
16 const MODULE_NAME = 'e-variables';
17 const EXPERIMENT_NAME = 'e_variables';
18 const EXPERIMENT_MANAGER_NAME = 'e_variables_manager';
19
20 private Variable_Types_Registry $variable_types_registry;
21
22 public function get_name() {
23 return self::MODULE_NAME;
24 }
25
26 public static function get_experimental_data(): array {
27 return [
28 'name' => self::EXPERIMENT_NAME,
29 'title' => esc_html__( 'Variables', 'elementor' ),
30 'description' => esc_html__( 'Enable variables. (For this feature to work - Atomic Widgets must be active)', 'elementor' ),
31 'hidden' => true,
32 'default' => ExperimentsManager::STATE_ACTIVE,
33 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA,
34 ];
35 }
36
37 private function hooks() {
38 return new Hooks();
39 }
40
41 public function __construct() {
42 parent::__construct();
43
44 if ( ! $this->is_experiment_active() ) {
45 return;
46 }
47 $this->register_features();
48
49 $this->hooks()->register();
50
51 add_action( 'init', [ $this, 'init_variable_types_registry' ] );
52 }
53
54 private function register_features() {
55 Plugin::$instance->experiments->add_feature([
56 'name' => self::EXPERIMENT_MANAGER_NAME,
57 'title' => esc_html__( 'Variables Manager', 'elementor' ),
58 'description' => esc_html__( 'Enable variables manager. (For this feature to work - Variables must be active)', 'elementor' ),
59 'hidden' => true,
60 'default' => ExperimentsManager::STATE_ACTIVE,
61 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA,
62 ]);
63 }
64
65 private function is_experiment_active(): bool {
66 return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME )
67 && Plugin::$instance->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME );
68 }
69
70 public function init_variable_types_registry(): void {
71 $this->variable_types_registry = new Variable_Types_Registry();
72
73 do_action( 'elementor/variables/register', $this->variable_types_registry );
74 }
75
76
77 public function get_variable_types_registry(): Variable_Types_Registry {
78 return $this->variable_types_registry;
79 }
80 }
81