Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/elementor/core/kits/documents/kit.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
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\Settings\Manager as SettingsManager;
7
+
use Elementor\Core\Settings\Page\Manager as PageManager;
8
+
use Elementor\Plugin;
9
+
10
+
if ( ! defined( 'ABSPATH' ) ) {
11
+
exit; // Exit if accessed directly.
12
+
}
13
+
14
+
class Kit extends PageBase {
15
+
/**
16
+
* @var Tabs\Tab_Base[]
17
+
*/
18
+
private $tabs;
19
+
20
+
public function __construct( array $data = [] ) {
21
+
parent::__construct( $data );
22
+
23
+
$this->register_tabs();
24
+
}
25
+
26
+
public static function get_properties() {
27
+
$properties = parent::get_properties();
28
+
29
+
$properties['has_elements'] = false;
30
+
$properties['show_in_finder'] = false;
31
+
$properties['show_on_admin_bar'] = false;
32
+
$properties['edit_capability'] = 'edit_theme_options';
33
+
$properties['support_kit'] = true;
34
+
35
+
return $properties;
36
+
}
37
+
38
+
public static function get_type() {
39
+
return 'kit';
40
+
}
41
+
42
+
public static function get_title() {
43
+
return esc_html__( 'Kit', 'elementor' );
44
+
}
45
+
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
+
protected function get_have_a_look_url() {
65
+
return '';
66
+
}
67
+
68
+
public static function get_editor_panel_config() {
69
+
$config = parent::get_editor_panel_config();
70
+
$config['default_route'] = 'panel/global/menu';
71
+
72
+
$config['needHelpUrl'] = 'https://go.elementor.com/global-settings/';
73
+
74
+
return $config;
75
+
}
76
+
77
+
public function get_css_wrapper_selector() {
78
+
return '.elementor-kit-' . $this->get_main_id();
79
+
}
80
+
81
+
public function save( $data ) {
82
+
foreach ( $this->tabs as $tab ) {
83
+
$data = $tab->before_save( $data );
84
+
}
85
+
86
+
$saved = parent::save( $data );
87
+
88
+
if ( ! $saved ) {
89
+
return false;
90
+
}
91
+
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
+
return $saved;
108
+
}
109
+
110
+
/**
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
142
+
* @access protected
143
+
*/
144
+
protected function register_controls() {
145
+
$this->register_document_controls();
146
+
147
+
foreach ( $this->tabs as $tab ) {
148
+
$tab->register_controls();
149
+
}
150
+
}
151
+
152
+
protected function get_post_statuses() {
153
+
return [
154
+
'draft' => sprintf( '%s (%s)', esc_html__( 'Disabled', 'elementor' ), esc_html__( 'Draft', 'elementor' ) ),
155
+
'publish' => esc_html__( 'Published', 'elementor' ),
156
+
];
157
+
}
158
+
159
+
public function add_repeater_row( $control_id, $item ) {
160
+
$meta_key = PageManager::META_KEY;
161
+
$document_settings = $this->get_meta( $meta_key );
162
+
163
+
if ( ! $document_settings ) {
164
+
$document_settings = [];
165
+
}
166
+
167
+
if ( ! isset( $document_settings[ $control_id ] ) ) {
168
+
$document_settings[ $control_id ] = [];
169
+
}
170
+
171
+
$document_settings[ $control_id ][] = $item;
172
+
173
+
$page_settings_manager = SettingsManager::get_settings_managers( 'page' );
174
+
$page_settings_manager->save_settings( $document_settings, $this->get_id() );
175
+
176
+
/** @var Kit $autosave */
177
+
$autosave = $this->get_autosave();
178
+
179
+
if ( $autosave ) {
180
+
$autosave->add_repeater_row( $control_id, $item );
181
+
}
182
+
183
+
// Remove Post CSS.
184
+
$post_css = Post_CSS::create( $this->post->ID );
185
+
186
+
$post_css->delete();
187
+
188
+
// Refresh Cache.
189
+
Plugin::$instance->documents->get( $this->post->ID, false );
190
+
191
+
$post_css = Post_CSS::create( $this->post->ID );
192
+
193
+
$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
+
}
221
+
}
222
+