PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.2
Elementor Website Builder – more than just a page builder v4.2.2
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 / import-export-customization / runners / export.php

export.php in Elementor Website Builder – more than just a page builder 4.2.2, at modules/variables/import-export-customization/runners/export.php

77 lines 1.9 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\ImportExportCustomization\Runners;
4
5 use Elementor\App\Modules\ImportExportCustomization\Runners\Export\Export_Runner_Base;
6 use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
7 use Elementor\Modules\Variables\ImportExportCustomization\Import_Export_Customization;
8 use Elementor\Modules\Variables\Module as Variables_Module;
9 use Elementor\Modules\Variables\Storage\Variables_Repository;
10 use Elementor\Plugin;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 class Export extends Export_Runner_Base {
17 public static function get_name(): string {
18 return 'global-variables';
19 }
20
21 public function should_export( array $data ): bool {
22 return (
23 isset( $data['include'] ) &&
24 in_array( 'settings', $data['include'], true ) &&
25 $this->is_variables_enabled( $data )
26 );
27 }
28
29 private function is_variables_enabled( array $data ): bool {
30 if ( ! $this->is_feature_active() ) {
31 return false;
32 }
33
34 if ( isset( $data['customization']['settings']['variables'] ) ) {
35 return (bool) $data['customization']['settings']['variables'];
36 }
37
38 return true;
39 }
40
41 private function is_feature_active(): bool {
42 return Plugin::$instance->experiments->is_feature_active( Variables_Module::EXPERIMENT_NAME )
43 && Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_NAME );
44 }
45
46 public function export( array $data ): array {
47 $kit = Plugin::$instance->kits_manager->get_active_kit();
48
49 if ( ! $kit ) {
50 return [
51 'manifest' => [],
52 'files' => [],
53 ];
54 }
55
56 $repository = new Variables_Repository( $kit );
57 $collection = $repository->load();
58
59 $variables_data = $collection->serialize();
60
61 if ( empty( $variables_data['data'] ) ) {
62 return [
63 'manifest' => [],
64 'files' => [],
65 ];
66 }
67
68 return [
69 'files' => [
70 'path' => Import_Export_Customization::FILE_NAME,
71 'data' => $variables_data,
72 ],
73 'manifest' => [],
74 ];
75 }
76 }
77