| @@ -4,28 +4,18 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 6 | 6 | use Elementor\Core\Experiments\Manager as ExperimentsManager; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule; |
| 8 | -use Elementor\Modules\Variables\Classes\Variable_Types_Registry; | |
| 9 | -use Elementor\Modules\Variables\ImportExportCustomization\Import_Export_Customization; | |
| 10 | -use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type; | |
| 11 | -use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type; | |
| 12 | -use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type; | |
| 13 | -use Elementor\Modules\Variables\Storage\Constants; | |
| 14 | 8 | use Elementor\Plugin; |
| 15 | -use Elementor\Utils; | |
| 16 | 9 | |
| 17 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | - exit; | |
| 11 | + exit; // Exit if accessed directly. | |
| 19 | 12 | } |
| 20 | 13 | |
| 21 | 14 | class Module extends BaseModule { |
| 22 | 15 | const MODULE_NAME = 'e-variables'; |
| 23 | 16 | const EXPERIMENT_NAME = 'e_variables'; |
| 24 | - const EXPERIMENT_MANAGER_NAME = 'e_variables_manager'; | |
| 25 | 17 | |
| 26 | - private Variable_Types_Registry $variable_types_registry; | |
| 27 | - | |
| 28 | 18 | public function get_name() { |
| 29 | 19 | return self::MODULE_NAME; |
| 30 | 20 | } |
| 31 | 21 | |
| @@ -34,9 +24,9 @@ | ||
| 34 | 24 | 'name' => self::EXPERIMENT_NAME, |
| 35 | 25 | 'title' => esc_html__( 'Variables', 'elementor' ), |
| 36 | 26 | 'description' => esc_html__( 'Enable variables. (For this feature to work - Atomic Widgets must be active)', 'elementor' ), |
| 37 | 27 | 'hidden' => true, |
| 38 | - 'default' => ExperimentsManager::STATE_ACTIVE, | |
| 28 | + 'default' => ExperimentsManager::STATE_INACTIVE, | |
| 39 | 29 | 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA, |
| 40 | 30 | ]; |
| 41 | 31 | } |
| 42 | 32 | |
| @@ -49,64 +39,13 @@ | ||
| 49 | 39 | |
| 50 | 40 | if ( ! $this->is_experiment_active() ) { |
| 51 | 41 | return; |
| 52 | 42 | } |
| 53 | - $this->register_features(); | |
| 54 | 43 | |
| 55 | 44 | $this->hooks()->register(); |
| 56 | - | |
| 57 | - ( new Import_Export_Customization() )->register_hooks(); | |
| 58 | - | |
| 59 | - add_action( 'init', [ $this, 'init_variable_types_registry' ] ); | |
| 60 | - add_filter( 'elementor/kit/meta_to_preserve_on_kit_import', [ $this, 'add_meta_to_preserve_on_kit_import' ] ); | |
| 61 | - add_action( 'elementor/editor/before_enqueue_scripts', fn () => $this->enqueue_editor_scripts() ); | |
| 62 | 45 | } |
| 63 | 46 | |
| 64 | - private function register_features() { | |
| 65 | - Plugin::$instance->experiments->add_feature([ | |
| 66 | - 'name' => self::EXPERIMENT_MANAGER_NAME, | |
| 67 | - 'title' => esc_html__( 'Variables Manager', 'elementor' ), | |
| 68 | - 'description' => esc_html__( 'Enable variables manager. (For this feature to work - Variables must be active)', 'elementor' ), | |
| 69 | - 'hidden' => true, | |
| 70 | - 'default' => ExperimentsManager::STATE_ACTIVE, | |
| 71 | - 'release_status' => ExperimentsManager::RELEASE_STATUS_ALPHA, | |
| 72 | - ]); | |
| 73 | - } | |
| 74 | - | |
| 75 | 47 | private function is_experiment_active(): bool { |
| 76 | 48 | return Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ) |
| 77 | 49 | && Plugin::$instance->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME ); |
| 78 | - } | |
| 79 | - | |
| 80 | - public function init_variable_types_registry(): void { | |
| 81 | - $this->variable_types_registry = new Variable_Types_Registry(); | |
| 82 | - | |
| 83 | - do_action( 'elementor/variables/register', $this->variable_types_registry ); | |
| 84 | - } | |
| 85 | - | |
| 86 | - | |
| 87 | - public function get_variable_types_registry(): Variable_Types_Registry { | |
| 88 | - return $this->variable_types_registry; | |
| 89 | - } | |
| 90 | - | |
| 91 | - private function get_quota_config(): array { | |
| 92 | - return [ | |
| 93 | - Color_Variable_Prop_Type::get_key() => 100000, | |
| 94 | - Font_Variable_Prop_Type::get_key() => 100000, | |
| 95 | - ]; | |
| 96 | - } | |
| 97 | - | |
| 98 | - public function enqueue_editor_scripts() { | |
| 99 | - | |
| 100 | - wp_add_inline_script( | |
| 101 | - 'elementor-common', | |
| 102 | - 'window.ElementorVariablesQuotaConfig = ' . wp_json_encode( $this->get_quota_config() ) . ';', | |
| 103 | - 'before' | |
| 104 | - ); | |
| 105 | - } | |
| 106 | - | |
| 107 | - public function add_meta_to_preserve_on_kit_import( array $meta_keys ): array { | |
| 108 | - return array_merge( $meta_keys, [ | |
| 109 | - Constants::VARIABLES_META_KEY, | |
| 110 | - ] ); | |
| 111 | 50 | } |
| 112 | 51 | } |