PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.8
Elementor Website Builder – more than just a page builder v3.0.8
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
← All changes | core/kits/documents/kit.php +31 -103 4.1.0-dev33.0.8 View file →
@@ -2,14 +2,15 @@
2 2 namespace Elementor\Core\Kits\Documents;
3 3
4 4 use Elementor\Core\DocumentTypes\PageBase;
5 5 use Elementor\Core\Files\CSS\Post as Post_CSS;
6 +use Elementor\Core\Kits\Documents\Tabs;
6 7 use Elementor\Core\Settings\Manager as SettingsManager;
7 8 use Elementor\Core\Settings\Page\Manager as PageManager;
8 9 use Elementor\Plugin;
9 10
10 11 if ( ! defined( 'ABSPATH' ) ) {
11 - exit; // Exit if accessed directly.
12 + exit; // Exit if accessed directly
12 13 }
13 14
14 15 class Kit extends PageBase {
15 16 /**
@@ -19,9 +20,21 @@
19 20
20 21 public function __construct( array $data = [] ) {
21 22 parent::__construct( $data );
22 23
23 - $this->register_tabs();
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 + ];
24 37 }
25 38
26 39 public static function get_properties() {
27 40 $properties = parent::get_properties();
@@ -34,34 +47,16 @@
34 47
35 48 return $properties;
36 49 }
37 50
38 - public static function get_type() {
51 + public function get_name() {
39 52 return 'kit';
40 53 }
41 54
42 55 public static function get_title() {
43 - return esc_html__( 'Kit', 'elementor' );
56 + return __( 'Kit', 'elementor' );
44 57 }
45 58
46 - /**
47 - * @return Tabs\Tab_Base[]
48 - */
49 - public function get_tabs() {
50 - return $this->tabs;
51 - }
52 -
53 - /**
54 - * Retrieve a tab by ID.
55 - *
56 - * @param $id
57 - *
58 - * @return Tabs\Tab_Base
59 - */
60 - public function get_tab( $id ) {
61 - return self::get_items( $this->get_tabs(), $id );
62 - }
63 -
64 59 protected function get_have_a_look_url() {
65 60 return '';
66 61 }
67 62
@@ -68,9 +63,9 @@
68 63 public static function get_editor_panel_config() {
69 64 $config = parent::get_editor_panel_config();
70 65 $config['default_route'] = 'panel/global/menu';
71 66
72 - $config['needHelpUrl'] = 'https://go.elementor.com/global-settings/';
67 + $config['needHelpUrl'] = 'https://go.elementor.com/global-settings';
73 68
74 69 return $config;
75 70 }
76 71
@@ -78,71 +73,30 @@
78 73 return '.elementor-kit-' . $this->get_main_id();
79 74 }
80 75
81 76 public function save( $data ) {
82 - foreach ( $this->tabs as $tab ) {
83 - $data = $tab->before_save( $data );
84 - }
85 -
86 77 $saved = parent::save( $data );
87 78
88 - if ( ! $saved ) {
89 - return false;
90 - }
79 + if ( $saved ) {
80 + // Should set is_saving to true, to avoid infinite loop when updating
81 + // settings like: 'site_name" or "site_description".
82 + $this->set_is_saving( true );
91 83
92 - // Should set is_saving to true, to avoid infinite loop when updating
93 - // settings like: 'site_name" or "site_description".
94 - $this->set_is_saving( true );
84 + foreach ( $this->tabs as $tab ) {
85 + $tab->on_save( $data );
86 + }
95 87
96 - foreach ( $this->tabs as $tab ) {
97 - $tab->on_save( $data );
88 + $this->set_is_saving( false );
98 89 }
99 90
100 - $this->set_is_saving( false );
101 -
102 - // When deleting a global color or typo, the css variable still exists in the frontend
103 - // but without any value and it makes the element to be un styled even if there is a default style for the base element,
104 - // for that reason this method removes css files of the entire site.
105 - Plugin::instance()->files_manager->clear_cache();
106 -
107 91 return $saved;
108 92 }
109 93
110 94 /**
111 - * Register a kit settings menu.
112 - *
113 - * @param $id
114 - * @param $class_name
115 - */
116 - public function register_tab( $id, $class_name ) {
117 - $this->tabs[ $id ] = new $class_name( $this );
118 - }
119 -
120 - /**
121 - * @inheritDoc
122 - */
123 - protected function get_initial_config() {
124 - $config = parent::get_initial_config();
125 -
126 - foreach ( $this->tabs as $id => $tab ) {
127 - $config['tabs'][ $id ] = [
128 - 'id' => $id,
129 - 'title' => $tab->get_title(),
130 - 'icon' => $tab->get_icon(),
131 - 'group' => $tab->get_group(),
132 - 'helpUrl' => $tab->get_help_url(),
133 - 'additionalContent' => $tab->get_additional_tab_content(),
134 - ];
135 - }
136 -
137 - return $config;
138 - }
139 -
140 - /**
141 - * @since 3.1.0
95 + * @since 2.0.0
142 96 * @access protected
143 97 */
144 - protected function register_controls() {
98 + protected function _register_controls() {
145 99 $this->register_document_controls();
146 100
147 101 foreach ( $this->tabs as $tab ) {
148 102 $tab->register_controls();
@@ -150,10 +104,10 @@
150 104 }
151 105
152 106 protected function get_post_statuses() {
153 107 return [
154 - 'draft' => sprintf( '%s (%s)', esc_html__( 'Disabled', 'elementor' ), esc_html__( 'Draft', 'elementor' ) ),
155 - 'publish' => esc_html__( 'Published', 'elementor' ),
108 + 'draft' => sprintf( '%s (%s)', __( 'Disabled', 'elementor' ), __( 'Draft', 'elementor' ) ),
109 + 'publish' => __( 'Published', 'elementor' ),
156 110 ];
157 111 }
158 112
159 113 public function add_repeater_row( $control_id, $item ) {
@@ -172,9 +126,9 @@
172 126
173 127 $page_settings_manager = SettingsManager::get_settings_managers( 'page' );
174 128 $page_settings_manager->save_settings( $document_settings, $this->get_id() );
175 129
176 - /** @var Kit $autosave */
130 + /** @var Kit $autosave **/
177 131 $autosave = $this->get_autosave();
178 132
179 133 if ( $autosave ) {
180 134 $autosave->add_repeater_row( $control_id, $item );
@@ -190,32 +144,6 @@
190 144
191 145 $post_css = Post_CSS::create( $this->post->ID );
192 146
193 147 $post_css->enqueue();
194 - }
195 -
196 - /**
197 - * Register default tabs (menu pages) for site settings.
198 - */
199 - private function register_tabs() {
200 - $tabs = [
201 - 'global-colors' => Tabs\Global_Colors::class,
202 - 'global-typography' => Tabs\Global_Typography::class,
203 - 'theme-style-typography' => Tabs\Theme_Style_Typography::class,
204 - 'theme-style-buttons' => Tabs\Theme_Style_Buttons::class,
205 - 'theme-style-images' => Tabs\Theme_Style_Images::class,
206 - 'theme-style-form-fields' => Tabs\Theme_Style_Form_Fields::class,
207 - 'settings-site-identity' => Tabs\Settings_Site_Identity::class,
208 - 'settings-background' => Tabs\Settings_Background::class,
209 - 'settings-layout' => Tabs\Settings_Layout::class,
210 - 'settings-lightbox' => Tabs\Settings_Lightbox::class,
211 - 'settings-page-transitions' => Tabs\Settings_Page_Transitions::class,
212 - 'settings-custom-css' => Tabs\Settings_Custom_CSS::class,
213 - ];
214 -
215 - foreach ( $tabs as $id => $class ) {
216 - $this->register_tab( $id, $class );
217 - }
218 -
219 - do_action( 'elementor/kit/register_tabs', $this );
220 148 }
221 149 }