| @@ -2,23 +2,21 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Variables; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 6 | +use Elementor\Core\Experiments\Manager as ExperimentsManager; | |
| 6 | 7 | use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule; |
| 7 | 8 | use Elementor\Modules\Variables\Classes\Variable_Types_Registry; |
| 8 | -use Elementor\Modules\Variables\ImportExportCustomization\Import_Export_Customization; | |
| 9 | -use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type; | |
| 10 | -use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type; | |
| 11 | -use Elementor\Modules\Variables\Storage\Constants; | |
| 12 | 9 | use Elementor\Plugin; |
| 13 | 10 | |
| 14 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | - exit; | |
| 12 | + exit; // Exit if accessed directly. | |
| 16 | 13 | } |
| 17 | 14 | |
| 18 | 15 | class Module extends BaseModule { |
| 19 | 16 | const MODULE_NAME = 'e-variables'; |
| 20 | - const EXPERIMENT_NAME = AtomicWidgetsModule::EXPERIMENT_NAME; | |
| 17 | + const EXPERIMENT_NAME = 'e_variables'; | |
| 18 | + const EXPERIMENT_MANAGER_NAME = 'e_variables_manager'; | |
| 21 | 19 | |
| 22 | 20 | private Variable_Types_Registry $variable_types_registry; |
| 23 | 21 | |
| 24 | 22 | public function get_name() { |
| @@ -24,8 +22,19 @@ | ||
| 24 | 22 | public function get_name() { |
| 25 | 23 | return self::MODULE_NAME; |
| 26 | 24 | } |
| 27 | 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 | + | |
| 28 | 37 | private function hooks() { |
| 29 | 38 | return new Hooks(); |
| 30 | 39 | } |
| 31 | 40 | |
| @@ -34,20 +43,29 @@ | ||
| 34 | 43 | |
| 35 | 44 | if ( ! $this->is_experiment_active() ) { |
| 36 | 45 | return; |
| 37 | 46 | } |
| 47 | + $this->register_features(); | |
| 38 | 48 | |
| 39 | 49 | $this->hooks()->register(); |
| 40 | 50 | |
| 41 | - ( new Import_Export_Customization() )->register_hooks(); | |
| 51 | + add_action( 'init', [ $this, 'init_variable_types_registry' ] ); | |
| 52 | + } | |
| 42 | 53 | |
| 43 | - add_action( 'init', [ $this, 'init_variable_types_registry' ] ); | |
| 44 | - add_filter( 'elementor/kit/meta_to_preserve_on_kit_import', [ $this, 'add_meta_to_preserve_on_kit_import' ] ); | |
| 45 | - add_action( 'elementor/editor/before_enqueue_scripts', fn () => $this->enqueue_editor_scripts() ); | |
| 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_INACTIVE, | |
| 61 | + 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA, | |
| 62 | + ]); | |
| 46 | 63 | } |
| 47 | 64 | |
| 48 | 65 | private function is_experiment_active(): bool { |
| 49 | - return Plugin::$instance->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME ); | |
| 66 | + return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) | |
| 67 | + && Plugin::$instance->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME ); | |
| 50 | 68 | } |
| 51 | 69 | |
| 52 | 70 | public function init_variable_types_registry(): void { |
| 53 | 71 | $this->variable_types_registry = new Variable_Types_Registry(); |
| @@ -57,28 +75,6 @@ | ||
| 57 | 75 | |
| 58 | 76 | |
| 59 | 77 | public function get_variable_types_registry(): Variable_Types_Registry { |
| 60 | 78 | return $this->variable_types_registry; |
| 61 | - } | |
| 62 | - | |
| 63 | - private function get_quota_config(): array { | |
| 64 | - return [ | |
| 65 | - Color_Variable_Prop_Type::get_key() => 100000, | |
| 66 | - Font_Variable_Prop_Type::get_key() => 100000, | |
| 67 | - ]; | |
| 68 | - } | |
| 69 | - | |
| 70 | - public function enqueue_editor_scripts() { | |
| 71 | - | |
| 72 | - wp_add_inline_script( | |
| 73 | - 'elementor-common', | |
| 74 | - 'window.ElementorVariablesQuotaConfig = ' . wp_json_encode( $this->get_quota_config() ) . ';', | |
| 75 | - 'before' | |
| 76 | - ); | |
| 77 | - } | |
| 78 | - | |
| 79 | - public function add_meta_to_preserve_on_kit_import( array $meta_keys ): array { | |
| 80 | - return array_merge( $meta_keys, [ | |
| 81 | - Constants::VARIABLES_META_KEY, | |
| 82 | - ] ); | |
| 83 | 79 | } |
| 84 | 80 | } |