PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.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 / app / modules / import-export-customization / runners / export / site-settings.php

site-settings.php in Elementor Website Builder – more than just a page builder 3.32.2, at app/modules/import-export-customization/runners/export/site-settings.php

131 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\App\Modules\ImportExportCustomization\Runners\Export;
3
4 use Elementor\Plugin;
5
6 class Site_Settings extends Export_Runner_Base {
7 const ALLOWED_SETTINGS = [
8 'theme',
9 'globalColors',
10 'globalFonts',
11 'themeStyleSettings',
12 'generalSettings',
13 'experiments',
14 ];
15
16 public static function get_name(): string {
17 return 'site-settings';
18 }
19
20 public function should_export( array $data ) {
21 return (
22 isset( $data['include'] ) &&
23 in_array( 'settings', $data['include'], true )
24 );
25 }
26
27 public function export( array $data ) {
28 $customization = $data['customization']['settings'] ?? null;
29 if ( $customization ) {
30 return $this->export_customization( $data, $customization );
31 }
32
33 return $this->export_all( $data );
34 }
35
36 private function export_all( $data, $include_theme = true ) {
37 $kit = Plugin::$instance->kits_manager->get_active_kit();
38 $kit_data = $kit->get_export_data();
39
40 $excluded_kit_settings_keys = [
41 'site_name',
42 'site_description',
43 'site_logo',
44 'site_favicon',
45 ];
46
47 foreach ( $excluded_kit_settings_keys as $setting_key ) {
48 unset( $kit_data['settings'][ $setting_key ] );
49 }
50
51 if ( $include_theme ) {
52 $theme_data = $this->export_theme();
53
54 if ( $theme_data ) {
55 $kit_data['theme'] = $theme_data;
56 $manifest_data['theme'] = $theme_data;
57 }
58 }
59
60 $experiments_data = $this->export_experiments();
61
62 if ( $experiments_data ) {
63 $kit_data['experiments'] = $experiments_data;
64 $manifest_data['experiments'] = array_keys( $experiments_data );
65 }
66
67 $manifest_data['site-settings'] = array_fill_keys( self::ALLOWED_SETTINGS, true );
68
69 if ( ! $include_theme ) {
70 $manifest_data['site-settings']['theme'] = false;
71 }
72
73 return [
74 'files' => [
75 'path' => 'site-settings',
76 'data' => $kit_data,
77 ],
78 'manifest' => [
79 $manifest_data,
80 ],
81 ];
82 }
83
84 private function export_customization( $data, $customization ) {
85 $result = apply_filters( 'elementor/import-export-customization/export/site-settings/customization', null, $data, $customization, $this );
86
87 if ( is_array( $result ) ) {
88 return $result;
89 }
90
91 return $this->export_all( $data, ! empty( $customization['theme'] ) );
92 }
93
94 public function export_theme() {
95 $theme = wp_get_theme();
96
97 if ( empty( $theme ) || empty( $theme->get( 'ThemeURI' ) ) ) {
98 return null;
99 }
100
101 $theme_data['name'] = $theme->get( 'Name' );
102 $theme_data['theme_uri'] = $theme->get( 'ThemeURI' );
103 $theme_data['version'] = $theme->get( 'Version' );
104 $theme_data['slug'] = $theme->get_stylesheet();
105
106 return $theme_data;
107 }
108
109 public function export_experiments() {
110 $features = Plugin::$instance->experiments->get_features();
111
112 if ( empty( $features ) ) {
113 return null;
114 }
115
116 $experiments_data = [];
117
118 foreach ( $features as $feature_name => $feature ) {
119 $experiments_data[ $feature_name ] = [
120 'name' => $feature_name,
121 'title' => $feature['title'],
122 'state' => $feature['state'],
123 'default' => $feature['default'],
124 'release_status' => $feature['release_status'],
125 ];
126 }
127
128 return empty( $experiments_data ) ? null : $experiments_data;
129 }
130 }
131