PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
4.3.2 4.3.1 4.3.0 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 All 455 releases
← All changes | core/files/css/post.php +7 -91 4.3.2 → 3.17.2 View file →
@@ -1,11 +1,10 @@
1 1 <?php
2 2 namespace Elementor\Core\Files\CSS;
3 3
4 +use Elementor\Base_Data_Control;
5 +use Elementor\Control_Repeater;
4 6 use Elementor\Controls_Stack;
5 -use Elementor\Core\DynamicTags\Dynamic_CSS;
6 -use Elementor\Core\Kits\Manager;
7 -use Elementor\Core\Frontend\Widget_Content_Render_Mode;
8 7 use Elementor\Element_Base;
9 8 use Elementor\Plugin;
10 9
11 10 if ( ! defined( 'ABSPATH' ) ) {
@@ -126,14 +125,9 @@
126 125 *
127 126 * @param array $meta New meta data.
128 127 */
129 128 protected function update_meta( $meta ) {
130 - $is_updated = update_post_meta( $this->post_id, static::META_KEY, $meta );
131 -
132 - // When a concurrent request already stored the identical value, WP reports no change and skips its meta cache invalidation.
133 - if ( ! $is_updated ) {
134 - wp_cache_delete( $this->post_id, 'post_meta' );
135 - }
129 + update_post_meta( $this->post_id, static::META_KEY, $meta );
136 130 }
137 131
138 132 /**
139 133 * Delete meta.
@@ -223,9 +217,9 @@
223 217 * @param array $placeholders Placeholders.
224 218 * @param array $replacements Replacements.
225 219 * @param array $all_controls All controls.
226 220 */
227 - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) {
221 + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) {
228 222 parent::add_controls_stack_style_rules( $controls_stack, $controls, $values, $placeholders, $replacements, $all_controls );
229 223
230 224 if ( $controls_stack instanceof Element_Base ) {
231 225 foreach ( $controls_stack->get_children() as $child_element ) {
@@ -286,12 +280,8 @@
286 280 *
287 281 * @param Element_Base $element The element.
288 282 */
289 283 protected function render_styles( Element_Base $element ) {
290 - if ( Widget_Content_Render_Mode::is( Widget_Content_Render_Mode::MARKDOWN ) ) {
291 - return;
292 - }
293 -
294 284 /**
295 285 * Before element parse CSS.
296 286 *
297 287 * Fires before the CSS of the element is parsed.
@@ -302,11 +292,12 @@
302 292 * @param Element_Base $element The element.
303 293 */
304 294 do_action( 'elementor/element/before_parse_css', $this, $element );
305 295
306 - $this->render_element_global_styles( $element );
307 - $this->render_element_styles( $element );
296 + $element_settings = $element->get_settings();
308 297
298 + $this->add_controls_stack_style_rules( $element, $this->get_style_controls( $element, null, $element->get_parsed_dynamic_settings() ), $element_settings, [ '{{ID}}', '{{WRAPPER}}' ], [ $element->get_id(), $this->get_element_unique_selector( $element ) ] );
299 +
309 300 /**
310 301 * After element parse CSS.
311 302 *
312 303 * Fires after the CSS of the element is parsed.
@@ -316,81 +307,6 @@
316 307 * @param Post $this The post CSS file.
317 308 * @param Element_Base $element The element.
318 309 */
319 310 do_action( 'elementor/element/parse_css', $this, $element );
320 - }
321 -
322 - private function render_element_styles( Element_Base $element ) {
323 - $this->add_controls_stack_style_rules(
324 - $element,
325 - $this->get_style_controls( $element, null, $element->get_parsed_dynamic_settings() ),
326 - $element->get_settings(),
327 - [ '{{ID}}', '{{WRAPPER}}' ],
328 - [ $element->get_id(), $this->get_element_unique_selector( $element ) ]
329 - );
330 - }
331 -
332 - private function render_element_global_styles( Element_Base $element ) {
333 - if ( $this instanceof Dynamic_CSS ) {
334 - return;
335 - }
336 -
337 - /** @var Manager $module */
338 - $kits_manager = Plugin::$instance->kits_manager;
339 - $custom_colors_enabled = $kits_manager->is_custom_colors_enabled();
340 - $custom_typography_enabled = $kits_manager->is_custom_typography_enabled();
341 -
342 - $controls = $element->get_controls();
343 - $global_controls = [];
344 - $global_values['__globals__'] = [];
345 -
346 - foreach ( $controls as $control ) {
347 - $this->build_global_controls_and_values(
348 - $control,
349 - $controls,
350 - $global_controls,
351 - $global_values,
352 - $custom_colors_enabled,
353 - $custom_typography_enabled
354 - );
355 - }
356 -
357 - foreach ( $global_controls as $control ) {
358 - $this->add_control_rules(
359 - $control,
360 - $controls,
361 - function( $control ) {},
362 - [ '{{WRAPPER}}' ],
363 - [ '.elementor-widget-' . $element->get_name() ],
364 - $global_values
365 - );
366 - }
367 - }
368 -
369 - private function build_global_controls_and_values( $control, $controls, &$global_controls, &$global_values, $custom_colors_enabled, $custom_typography_enabled ) {
370 - $is_color_control = 'color' === $control['type'];
371 - $is_typography_control = isset( $control['groupType'] ) && 'typography' === $control['groupType'];
372 -
373 - // If it is a color/typography control and default colors/typography are disabled,
374 - // don't add the default CSS.
375 - if ( ( $is_color_control && ! $custom_colors_enabled ) || ( $is_typography_control && ! $custom_typography_enabled ) ) {
376 - return;
377 - }
378 -
379 - $global_control = $control;
380 -
381 - // Handle group controls that don't have a default global property.
382 - if ( ! empty( $control['groupType'] ) ) {
383 - $global_control = $controls[ $control['groupPrefix'] . $control['groupType'] ];
384 - }
385 -
386 - // If the control has a default global defined, add it to the globals array
387 - // that is used in add_control_rules.
388 - if ( ! empty( $control['global']['default'] ) ) {
389 - $global_values['__globals__'][ $control['name'] ] = $global_control['global']['default'];
390 - }
391 -
392 - if ( ! empty( $global_control['global']['default'] ) ) {
393 - $global_controls[] = $control;
394 - }
395 311 }
396 312 }