PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
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 +28 -105 4.2.23.0.6 View file →
@@ -2,17 +2,19 @@
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 {
16 +
15 17 /**
16 18 * @var Tabs\Tab_Base[]
17 19 */
18 20 private $tabs;
@@ -19,9 +21,21 @@
19 21
20 22 public function __construct( array $data = [] ) {
21 23 parent::__construct( $data );
22 24
23 - $this->register_tabs();
25 + $this->tabs = [
26 + 'global-colors' => new Tabs\Global_Colors( $this ),
27 + 'global-typography' => new Tabs\Global_Typography( $this ),
28 + 'theme-style-typography' => new Tabs\Theme_Style_Typography( $this ),
29 + 'theme-style-buttons' => new Tabs\Theme_Style_Buttons( $this ),
30 + 'theme-style-images' => new Tabs\Theme_Style_Images( $this ),
31 + 'theme-style-form-fields' => new Tabs\Theme_Style_Form_Fields( $this ),
32 + 'settings-site-identity' => new Tabs\Settings_Site_Identity( $this ),
33 + 'settings-background' => new Tabs\Settings_Background( $this ),
34 + 'settings-layout' => new Tabs\Settings_Layout( $this ),
35 + 'settings-lightbox' => new Tabs\Settings_Lightbox( $this ),
36 + 'settings-custom-css' => new Tabs\Settings_Custom_CSS( $this ),
37 + ];
24 38 }
25 39
26 40 public static function get_properties() {
27 41 $properties = parent::get_properties();
@@ -34,34 +48,16 @@
34 48
35 49 return $properties;
36 50 }
37 51
38 - public static function get_type() {
52 + public function get_name() {
39 53 return 'kit';
40 54 }
41 55
42 56 public static function get_title() {
43 - return esc_html__( 'Kit', 'elementor' );
57 + return __( 'Kit', 'elementor' );
44 58 }
45 59
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 60 protected function get_have_a_look_url() {
65 61 return '';
66 62 }
67 63
@@ -68,9 +64,9 @@
68 64 public static function get_editor_panel_config() {
69 65 $config = parent::get_editor_panel_config();
70 66 $config['default_route'] = 'panel/global/menu';
71 67
72 - $config['needHelpUrl'] = 'https://go.elementor.com/global-settings/';
68 + $config['needHelpUrl'] = 'https://go.elementor.com/global-settings';
73 69
74 70 return $config;
75 71 }
76 72
@@ -78,71 +74,24 @@
78 74 return '.elementor-kit-' . $this->get_main_id();
79 75 }
80 76
81 77 public function save( $data ) {
82 - foreach ( $this->tabs as $tab ) {
83 - $data = $tab->before_save( $data );
84 - }
85 -
86 78 $saved = parent::save( $data );
87 79
88 - if ( ! $saved ) {
89 - return false;
80 + if ( $saved ) {
81 + foreach ( $this->tabs as $tab ) {
82 + $tab->on_save( $data );
83 + }
90 84 }
91 85
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 );
95 -
96 - foreach ( $this->tabs as $tab ) {
97 - $tab->on_save( $data );
98 - }
99 -
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 86 return $saved;
108 87 }
109 88
110 89 /**
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
90 + * @since 2.0.0
142 91 * @access protected
143 92 */
144 - protected function register_controls() {
93 + protected function _register_controls() {
145 94 $this->register_document_controls();
146 95
147 96 foreach ( $this->tabs as $tab ) {
148 97 $tab->register_controls();
@@ -150,10 +99,10 @@
150 99 }
151 100
152 101 protected function get_post_statuses() {
153 102 return [
154 - 'draft' => sprintf( '%s (%s)', esc_html__( 'Disabled', 'elementor' ), esc_html__( 'Draft', 'elementor' ) ),
155 - 'publish' => esc_html__( 'Published', 'elementor' ),
103 + 'draft' => sprintf( '%s (%s)', __( 'Disabled', 'elementor' ), __( 'Draft', 'elementor' ) ),
104 + 'publish' => __( 'Published', 'elementor' ),
156 105 ];
157 106 }
158 107
159 108 public function add_repeater_row( $control_id, $item ) {
@@ -172,9 +121,9 @@
172 121
173 122 $page_settings_manager = SettingsManager::get_settings_managers( 'page' );
174 123 $page_settings_manager->save_settings( $document_settings, $this->get_id() );
175 124
176 - /** @var Kit $autosave */
125 + /** @var Kit $autosave **/
177 126 $autosave = $this->get_autosave();
178 127
179 128 if ( $autosave ) {
180 129 $autosave->add_repeater_row( $control_id, $item );
@@ -190,32 +139,6 @@
190 139
191 140 $post_css = Post_CSS::create( $this->post->ID );
192 141
193 142 $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 143 }
221 144 }