PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev3
Elementor Website Builder – more than just a page builder v3.35.0-dev3
4.3.0-beta3 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 All 452 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.35.0-dev3, at app/modules/import-export-customization/runners/export/site-settings.php

134 lines 3.1 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 'customCode',
15 'customIcons',
16 'customFonts',
17 ];
18
19 public static function get_name(): string {
20 return 'site-settings';
21 }
22
23 public function should_export( array $data ) {
24 return (
25 isset( $data['include'] ) &&
26 in_array( 'settings', $data['include'], true )
27 );
28 }
29
30 public function export( array $data ) {
31 $customization = $data['customization']['settings'] ?? null;
32 if ( $customization ) {
33 return $this->export_customization( $data, $customization );
34 }
35
36 return $this->export_all( $data );
37 }
38
39 private function export_all( $data, $include_theme = true ) {
40 $kit = Plugin::$instance->kits_manager->get_active_kit();
41 $kit_data = $kit->get_export_data();
42
43 $excluded_kit_settings_keys = [
44 'site_name',
45 'site_description',
46 'site_logo',
47 'site_favicon',
48 ];
49
50 foreach ( $excluded_kit_settings_keys as $setting_key ) {
51 unset( $kit_data['settings'][ $setting_key ] );
52 }
53
54 if ( $include_theme ) {
55 $theme_data = $this->export_theme();
56
57 if ( $theme_data ) {
58 $kit_data['theme'] = $theme_data;
59 $manifest_data['theme'] = $theme_data;
60 }
61 }
62
63 $experiments_data = $this->export_experiments();
64
65 if ( $experiments_data ) {
66 $kit_data['experiments'] = $experiments_data;
67 $manifest_data['experiments'] = array_keys( $experiments_data );
68 }
69
70 $manifest_data['site-settings'] = array_fill_keys( self::ALLOWED_SETTINGS, true );
71
72 if ( ! $include_theme ) {
73 $manifest_data['site-settings']['theme'] = false;
74 }
75
76 return [
77 'files' => [
78 'path' => 'site-settings',
79 'data' => $kit_data,
80 ],
81 'manifest' => [
82 $manifest_data,
83 ],
84 ];
85 }
86
87 private function export_customization( $data, $customization ) {
88 $result = apply_filters( 'elementor/import-export-customization/export/site-settings/customization', null, $data, $customization, $this );
89
90 if ( is_array( $result ) ) {
91 return $result;
92 }
93
94 return $this->export_all( $data, ! empty( $customization['theme'] ) );
95 }
96
97 public function export_theme() {
98 $theme = wp_get_theme();
99
100 if ( empty( $theme ) || empty( $theme->get( 'ThemeURI' ) ) ) {
101 return null;
102 }
103
104 $theme_data['name'] = $theme->get( 'Name' );
105 $theme_data['theme_uri'] = $theme->get( 'ThemeURI' );
106 $theme_data['version'] = $theme->get( 'Version' );
107 $theme_data['slug'] = $theme->get_stylesheet();
108
109 return $theme_data;
110 }
111
112 public function export_experiments() {
113 $features = Plugin::$instance->experiments->get_features();
114
115 if ( empty( $features ) ) {
116 return null;
117 }
118
119 $experiments_data = [];
120
121 foreach ( $features as $feature_name => $feature ) {
122 $experiments_data[ $feature_name ] = [
123 'name' => $feature_name,
124 'title' => $feature['title'],
125 'state' => $feature['state'],
126 'default' => $feature['default'],
127 'release_status' => $feature['release_status'],
128 ];
129 }
130
131 return empty( $experiments_data ) ? null : $experiments_data;
132 }
133 }
134