PluginProbe
Elementor Website Builder – more than just a page builder / 3.11.1
Elementor Website Builder – more than just a page builder v3.11.1
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 / runners / import / site-settings.php

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

81 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\ImportExport\Runners\Import;
4
5 use Elementor\Plugin;
6 use Elementor\Core\Settings\Page\Manager as PageManager;
7
8 class Site_Settings extends Import_Runner_Base {
9
10 /**
11 * @var int
12 */
13 private $previous_kit_id;
14
15 /**
16 * @var int
17 */
18 private $active_kit_id;
19
20 /**
21 * @var int
22 */
23 private $imported_kit_id;
24
25 public static function get_name() : string {
26 return 'site-settings';
27 }
28
29 public function should_import( array $data ) {
30 return (
31 isset( $data['include'] ) &&
32 in_array( 'settings', $data['include'], true ) &&
33 ! empty( $data['site_settings']['settings'] )
34 );
35 }
36
37 public function import( array $data, array $imported_data ) {
38 $new_site_settings = $data['site_settings']['settings'];
39 $title = $data['manifest']['title'] ?? 'Imported Kit';
40
41 $active_kit = Plugin::$instance->kits_manager->get_active_kit();
42
43 $this->active_kit_id = (int) $active_kit->get_id();
44 $this->previous_kit_id = (int) Plugin::$instance->kits_manager->get_previous_id();
45
46 $result = [];
47
48 $old_settings = $active_kit->get_meta( PageManager::META_KEY );
49
50 if ( ! $old_settings ) {
51 $old_settings = [];
52 }
53
54 if ( ! empty( $old_settings['custom_colors'] ) ) {
55 $new_site_settings['custom_colors'] = array_merge( $old_settings['custom_colors'], $new_site_settings['custom_colors'] );
56 }
57
58 if ( ! empty( $old_settings['custom_typography'] ) ) {
59 $new_site_settings['custom_typography'] = array_merge( $old_settings['custom_typography'], $new_site_settings['custom_typography'] );
60 }
61
62 $new_site_settings = array_replace_recursive( $old_settings, $new_site_settings );
63
64 $new_kit = Plugin::$instance->kits_manager->create_new_kit( $title, $new_site_settings );
65
66 $this->imported_kit_id = (int) $new_kit;
67
68 $result['site-settings'] = (bool) $new_kit;
69
70 return $result;
71 }
72
73 public function get_import_session_metadata() : array {
74 return [
75 'previous_kit_id' => $this->previous_kit_id,
76 'active_kit_id' => $this->active_kit_id,
77 'imported_kit_id' => $this->imported_kit_id,
78 ];
79 }
80 }
81