PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.13
Elementor Website Builder – more than just a page builder v3.0.13
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 / core / kits / documents / kit.php

kit.php in Elementor Website Builder – more than just a page builder 3.0.13, at core/kits/documents/kit.php

157 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Kits\Documents;
3
4 use Elementor\Core\DocumentTypes\PageBase;
5 use Elementor\Core\Files\CSS\Post as Post_CSS;
6 use Elementor\Core\Kits\Documents\Tabs;
7 use Elementor\Core\Settings\Manager as SettingsManager;
8 use Elementor\Core\Settings\Page\Manager as PageManager;
9 use Elementor\Plugin;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly
13 }
14
15 class Kit extends PageBase {
16 /**
17 * @var Tabs\Tab_Base[]
18 */
19 private $tabs;
20
21 public function __construct( array $data = [] ) {
22 parent::__construct( $data );
23
24 $this->tabs = [
25 'global-colors' => new Tabs\Global_Colors( $this ),
26 'global-typography' => new Tabs\Global_Typography( $this ),
27 'theme-style-typography' => new Tabs\Theme_Style_Typography( $this ),
28 'theme-style-buttons' => new Tabs\Theme_Style_Buttons( $this ),
29 'theme-style-images' => new Tabs\Theme_Style_Images( $this ),
30 'theme-style-form-fields' => new Tabs\Theme_Style_Form_Fields( $this ),
31 'settings-site-identity' => new Tabs\Settings_Site_Identity( $this ),
32 'settings-background' => new Tabs\Settings_Background( $this ),
33 'settings-layout' => new Tabs\Settings_Layout( $this ),
34 'settings-lightbox' => new Tabs\Settings_Lightbox( $this ),
35 'settings-custom-css' => new Tabs\Settings_Custom_CSS( $this ),
36 ];
37 }
38
39 public static function get_properties() {
40 $properties = parent::get_properties();
41
42 $properties['has_elements'] = false;
43 $properties['show_in_finder'] = false;
44 $properties['show_on_admin_bar'] = false;
45 $properties['edit_capability'] = 'edit_theme_options';
46 $properties['support_kit'] = true;
47
48 return $properties;
49 }
50
51 public function get_name() {
52 return 'kit';
53 }
54
55 public static function get_title() {
56 return __( 'Kit', 'elementor' );
57 }
58
59 protected function get_have_a_look_url() {
60 return '';
61 }
62
63 public static function get_editor_panel_config() {
64 $config = parent::get_editor_panel_config();
65 $config['default_route'] = 'panel/global/menu';
66
67 $config['needHelpUrl'] = 'https://go.elementor.com/global-settings';
68
69 return $config;
70 }
71
72 public function get_css_wrapper_selector() {
73 return '.elementor-kit-' . $this->get_main_id();
74 }
75
76 public function save( $data ) {
77 $saved = parent::save( $data );
78
79 if ( ! $saved ) {
80 return false;
81 }
82
83 // Should set is_saving to true, to avoid infinite loop when updating
84 // settings like: 'site_name" or "site_description".
85 $this->set_is_saving( true );
86
87 foreach ( $this->tabs as $tab ) {
88 $tab->on_save( $data );
89 }
90
91 $this->set_is_saving( false );
92
93 // When deleting a global color or typo, the css variable still exists in the frontend
94 // but without any value and it makes the element to be un styled even if there is a default style for the base element,
95 // for that reason this method removes css files of the entire site.
96 Plugin::instance()->files_manager->clear_cache();
97
98 return $saved;
99 }
100
101 /**
102 * @since 2.0.0
103 * @access protected
104 */
105 protected function _register_controls() {
106 $this->register_document_controls();
107
108 foreach ( $this->tabs as $tab ) {
109 $tab->register_controls();
110 }
111 }
112
113 protected function get_post_statuses() {
114 return [
115 'draft' => sprintf( '%s (%s)', __( 'Disabled', 'elementor' ), __( 'Draft', 'elementor' ) ),
116 'publish' => __( 'Published', 'elementor' ),
117 ];
118 }
119
120 public function add_repeater_row( $control_id, $item ) {
121 $meta_key = PageManager::META_KEY;
122 $document_settings = $this->get_meta( $meta_key );
123
124 if ( ! $document_settings ) {
125 $document_settings = [];
126 }
127
128 if ( ! isset( $document_settings[ $control_id ] ) ) {
129 $document_settings[ $control_id ] = [];
130 }
131
132 $document_settings[ $control_id ][] = $item;
133
134 $page_settings_manager = SettingsManager::get_settings_managers( 'page' );
135 $page_settings_manager->save_settings( $document_settings, $this->get_id() );
136
137 /** @var Kit $autosave **/
138 $autosave = $this->get_autosave();
139
140 if ( $autosave ) {
141 $autosave->add_repeater_row( $control_id, $item );
142 }
143
144 // Remove Post CSS.
145 $post_css = Post_CSS::create( $this->post->ID );
146
147 $post_css->delete();
148
149 // Refresh Cache.
150 Plugin::$instance->documents->get( $this->post->ID, false );
151
152 $post_css = Post_CSS::create( $this->post->ID );
153
154 $post_css->enqueue();
155 }
156 }
157