| @@ -1,29 +1,20 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Variables; |
| 4 | 4 | |
| 5 | -use Elementor\Modules\Variables\Adapters\Prop_Type_Adapter; | |
| 6 | -use Elementor\Modules\Variables\Classes\Variable_Types_Registry; | |
| 7 | -use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type; | |
| 8 | -use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type; | |
| 9 | -use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type; | |
| 10 | -use Elementor\Modules\Variables\Services\Batch_Operations\Batch_Processor; | |
| 11 | -use Elementor\Modules\Variables\Services\Variables_Service; | |
| 12 | -use Elementor\Modules\Variables\Storage\Variables_Repository; | |
| 13 | -use Elementor\Modules\Variables\Utils\Template_Library_Variables; | |
| 14 | 5 | use Elementor\Plugin; |
| 15 | 6 | use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 16 | 7 | use Elementor\Modules\Variables\Classes\CSS_Renderer as Variables_CSS_Renderer; |
| 17 | 8 | use Elementor\Modules\Variables\Classes\Fonts; |
| 18 | 9 | use Elementor\Modules\Variables\Classes\Rest_Api as Variables_API; |
| 10 | +use Elementor\Modules\Variables\Storage\Repository as Variables_Repository; | |
| 19 | 11 | use Elementor\Modules\Variables\Classes\Style_Schema; |
| 20 | -use Elementor\Modules\Variables\Classes\Size_Style_Schema; | |
| 21 | 12 | use Elementor\Modules\Variables\Classes\Style_Transformers; |
| 22 | 13 | use Elementor\Modules\Variables\Classes\Variables; |
| 23 | 14 | |
| 24 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 25 | - exit; | |
| 16 | + exit; // Exit if accessed directly. | |
| 26 | 17 | } |
| 27 | 18 | |
| 28 | 19 | class Hooks { |
| 29 | 20 | const PACKAGES = [ |
| @@ -31,30 +22,17 @@ | ||
| 31 | 22 | ]; |
| 32 | 23 | |
| 33 | 24 | public function register() { |
| 34 | 25 | $this->register_styles_transformers() |
| 26 | + ->register_packages() | |
| 27 | + ->filter_for_style_schema() | |
| 35 | 28 | ->register_css_renderer() |
| 36 | - ->register_packages() | |
| 37 | 29 | ->register_fonts() |
| 38 | - ->register_api_endpoints() | |
| 39 | - ->filter_for_style_schema() | |
| 40 | - ->register_variable_types() | |
| 41 | - ->register_template_library_import(); | |
| 30 | + ->register_api_endpoints(); | |
| 42 | 31 | |
| 43 | 32 | return $this; |
| 44 | 33 | } |
| 45 | 34 | |
| 46 | - private function register_variable_types() { | |
| 47 | - add_action( 'elementor/variables/register', function ( Variable_Types_Registry $registry ) { | |
| 48 | - $registry->register( Color_Variable_Prop_Type::get_key(), new Color_Variable_Prop_Type() ); | |
| 49 | - $registry->register( Font_Variable_Prop_Type::get_key(), new Font_Variable_Prop_Type() ); | |
| 50 | - $registry->register( Prop_Type_Adapter::GLOBAL_CUSTOM_SIZE_VARIABLE_KEY, new Size_Variable_Prop_Type() ); | |
| 51 | - $registry->register( Size_Variable_Prop_Type::get_key(), new Size_Variable_Prop_Type() ); | |
| 52 | - } ); | |
| 53 | - | |
| 54 | - return $this; | |
| 55 | - } | |
| 56 | - | |
| 57 | 35 | private function register_packages() { |
| 58 | 36 | add_filter( 'elementor/editor/v2/packages', function ( $packages ) { |
| 59 | 37 | return array_merge( $packages, self::PACKAGES ); |
| 60 | 38 | } ); |
| @@ -63,9 +41,9 @@ | ||
| 63 | 41 | } |
| 64 | 42 | |
| 65 | 43 | private function register_styles_transformers() { |
| 66 | 44 | add_action( 'elementor/atomic-widgets/styles/transformers/register', function ( $registry ) { |
| 67 | - Variables::init( $this->variables_service() ); | |
| 45 | + Variables::init( $this->variables_repository() ); | |
| 68 | 46 | ( new Style_Transformers() )->append_to( $registry ); |
| 69 | 47 | } ); |
| 70 | 48 | |
| 71 | 49 | return $this; |
| @@ -75,17 +53,13 @@ | ||
| 75 | 53 | add_filter( 'elementor/atomic-widgets/styles/schema', function ( array $schema ) { |
| 76 | 54 | return ( new Style_Schema() )->augment( $schema ); |
| 77 | 55 | } ); |
| 78 | 56 | |
| 79 | - add_filter( 'elementor/atomic-widgets/styles/schema', function ( array $schema ) { | |
| 80 | - return ( new Size_Style_Schema() )->augment( $schema ); | |
| 81 | - } ); | |
| 82 | - | |
| 83 | 57 | return $this; |
| 84 | 58 | } |
| 85 | 59 | |
| 86 | 60 | private function css_renderer() { |
| 87 | - return new Variables_CSS_Renderer( $this->variables_service() ); | |
| 61 | + return new Variables_CSS_Renderer( $this->variables_repository() ); | |
| 88 | 62 | } |
| 89 | 63 | |
| 90 | 64 | private function register_css_renderer() { |
| 91 | 65 | add_action( 'elementor/css-file/post/parse', function ( Post_CSS $post_css ) { |
| @@ -101,9 +75,9 @@ | ||
| 101 | 75 | return $this; |
| 102 | 76 | } |
| 103 | 77 | |
| 104 | 78 | private function fonts() { |
| 105 | - return new Fonts( $this->variables_service() ); | |
| 79 | + return new Fonts( $this->variables_repository() ); | |
| 106 | 80 | } |
| 107 | 81 | |
| 108 | 82 | private function register_fonts() { |
| 109 | 83 | add_action( 'elementor/css-file/post/parse', function ( $post_css ) { |
| @@ -113,9 +87,9 @@ | ||
| 113 | 87 | return $this; |
| 114 | 88 | } |
| 115 | 89 | |
| 116 | 90 | private function rest_api() { |
| 117 | - return new Variables_API( $this->variables_service() ); | |
| 91 | + return new Variables_API( $this->variables_repository() ); | |
| 118 | 92 | } |
| 119 | 93 | |
| 120 | 94 | private function register_api_endpoints() { |
| 121 | 95 | add_action( 'rest_api_init', function () { |
| @@ -124,44 +98,10 @@ | ||
| 124 | 98 | |
| 125 | 99 | return $this; |
| 126 | 100 | } |
| 127 | 101 | |
| 128 | - private function variables_service() { | |
| 129 | - $repository = new Variables_Repository( | |
| 102 | + private function variables_repository() { | |
| 103 | + return new Variables_Repository( | |
| 130 | 104 | Plugin::$instance->kits_manager->get_active_kit() |
| 131 | 105 | ); |
| 132 | - | |
| 133 | - return new Variables_Service( $repository, new Batch_Processor() ); | |
| 134 | - } | |
| 135 | - | |
| 136 | - private function register_template_library_import() { | |
| 137 | - add_filter( | |
| 138 | - 'elementor/template_library/export/build_snapshots', | |
| 139 | - [ Template_Library_Variables::class, 'add_variables_snapshot' ], | |
| 140 | - 20, | |
| 141 | - 4 | |
| 142 | - ); | |
| 143 | - | |
| 144 | - add_filter( | |
| 145 | - 'elementor/template_library/get_data/extract_snapshots', | |
| 146 | - [ Template_Library_Variables::class, 'extract_variables_from_data' ], | |
| 147 | - 10, | |
| 148 | - 3 | |
| 149 | - ); | |
| 150 | - | |
| 151 | - add_filter( | |
| 152 | - 'elementor/template_library/import/process_content', | |
| 153 | - [ Template_Library_Variables::class, 'process_variables_import' ], | |
| 154 | - 10, | |
| 155 | - 3 | |
| 156 | - ); | |
| 157 | - | |
| 158 | - add_filter( | |
| 159 | - 'elementor/global_classes/import/transform_snapshot', | |
| 160 | - [ Template_Library_Variables::class, 'transform_variables_in_classes_snapshot' ], | |
| 161 | - 10, | |
| 162 | - 4 | |
| 163 | - ); | |
| 164 | - | |
| 165 | - return $this; | |
| 166 | 106 | } |
| 167 | 107 | } |