PluginProbe
Elementor Website Builder – more than just a page builder / 3.9.2
Elementor Website Builder – more than just a page builder v3.9.2
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
← All changes | core/files/css/base.php +11 -61 4.2.13.9.2 View file →
@@ -8,9 +8,8 @@
8 8 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
9 9 use Elementor\Core\Files\Base as Base_File;
10 10 use Elementor\Core\DynamicTags\Manager;
11 11 use Elementor\Core\DynamicTags\Tag;
12 -use Elementor\Core\Frontend\Performance;
13 12 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
14 13 use Elementor\Plugin;
15 14 use Elementor\Stylesheet;
16 15 use Elementor\Icons_Manager;
@@ -64,10 +63,8 @@
64 63 private $icons_fonts = [];
65 64
66 65 private $dynamic_elements_ids = [];
67 66
68 - private $preserved_dynamic_style_values = [];
69 -
70 67 /**
71 68 * Stylesheet object.
72 69 *
73 70 * Holds the CSS file stylesheet instance.
@@ -214,17 +211,8 @@
214 211 if ( self::CSS_STATUS_EMPTY === $meta['status'] ) {
215 212 return;
216 213 }
217 214
218 - /**
219 - * Enqueue CSS file.
220 - *
221 - * Fires before enqueuing a CSS file.
222 - *
223 - * @param Base $this The current CSS file.
224 - */
225 - do_action( 'elementor/css-file/before_enqueue', $this );
226 -
227 215 // First time after clear cache and etc.
228 216 if ( '' === $meta['status'] || $this->is_update_required() ) {
229 217 $this->update();
230 218
@@ -234,14 +222,14 @@
234 222 if ( self::CSS_STATUS_INLINE === $meta['status'] ) {
235 223 $dep = $this->get_inline_dependency();
236 224 // If the dependency has already been printed ( like a template in footer )
237 225 if ( wp_styles()->query( $dep, 'done' ) ) {
238 - printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
226 + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok.
239 227 } else {
240 228 wp_add_inline_style( $dep, $meta['css'] );
241 229 }
242 230 } elseif ( self::CSS_STATUS_FILE === $meta['status'] ) { // Re-check if it's not empty after CSS update.
243 - wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null );
231 + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
244 232 }
245 233
246 234 // Handle fonts.
247 235 if ( ! empty( $meta['fonts'] ) ) {
@@ -273,17 +261,8 @@
273 261 *
274 262 * @param Base $this The current CSS file.
275 263 */
276 264 do_action( "elementor/css-file/{$name}/enqueue", $this );
277 -
278 - /**
279 - * Enqueue CSS file.
280 - *
281 - * Fires after enqueuing a CSS file.
282 - *
283 - * @param Base $this The current CSS file.
284 - */
285 - do_action( 'elementor/css-file/after_enqueue', $this );
286 265 }
287 266
288 267 /**
289 268 * Print CSS.
@@ -294,9 +273,9 @@
294 273 * @since 1.9.4
295 274 * @access public
296 275 */
297 276 public function print_css() {
298 - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
277 + echo '<style>' . $this->get_content() . '</style>'; // XSS ok.
299 278 Plugin::$instance->frontend->print_fonts_links();
300 279 }
301 280
302 281 /**
@@ -347,9 +326,9 @@
347 326 }
348 327
349 328 $stylesheet = $this->get_stylesheet();
350 329
351 - $control = apply_filters( 'elementor/files/css/selectors', $control, $value ?? [], $this );
330 + $control = apply_filters( 'elementor/files/css/selectors', $control, $value ?? [] );
352 331
353 332 foreach ( $control['selectors'] as $selector => $css_property ) {
354 333 $output_css_property = '';
355 334
@@ -360,12 +339,8 @@
360 339 $output_css_property = preg_replace( '/(:)[^;]+(;?)/', '$1' . $selector_global_value . '$2', $css_property );
361 340 }
362 341 } else {
363 342 try {
364 - if ( $this->unit_has_custom_selector( $control, $value ) ) {
365 - $css_property = $control['unit_selectors_dictionary'][ $value['unit'] ];
366 - }
367 -
368 343 $output_css_property = preg_replace_callback( '/{{(?:([^.}]+)\.)?([^}| ]*)(?: *\|\| *(?:([^.}]+)\.)?([^}| ]*) *)*}}/', function( $matches ) use ( $control, $value_callback, $controls_stack, $value, $css_property ) {
369 344 $external_control_missing = $matches[1] && ! isset( $controls_stack[ $matches[1] ] );
370 345
371 346 $parsed_value = '';
@@ -401,12 +376,8 @@
401 376 throw new \Exception();
402 377 }
403 378 }
404 379
405 - if ( '__EMPTY__' === $parsed_value ) {
406 - $parsed_value = '';
407 - }
408 -
409 380 return $parsed_value;
410 381 }, $css_property );
411 382 } catch ( \Exception $e ) {
412 383 return;
@@ -456,12 +427,8 @@
456 427 $stylesheet->add_rules( $parsed_selector, $output_css_property, $query );
457 428 }
458 429 }
459 430
460 - protected function unit_has_custom_selector( $control, $value ) {
461 - return isset( $control['unit_selectors_dictionary'] ) && isset( $control['unit_selectors_dictionary'][ $value['unit'] ] );
462 - }
463 -
464 431 /**
465 432 * @param array $control
466 433 * @param mixed $value
467 434 * @param array $controls_stack
@@ -490,9 +457,9 @@
490 457 $value = $this->get_control_global_default_value( $control );
491 458 }
492 459
493 460 if ( Controls_Manager::FONT === $control['type'] ) {
494 - $this->add_font( $value );
461 + $this->fonts[] = $value;
495 462 }
496 463
497 464 /** @var Base_Data_Control $control_obj */
498 465 $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
@@ -548,9 +515,9 @@
548 515 * @param array $placeholders Placeholders.
549 516 * @param array $replacements Replacements.
550 517 * @param array $all_controls All controls.
551 518 */
552 - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) {
519 + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) {
553 520 if ( ! $all_controls ) {
554 521 $all_controls = $controls_stack->get_controls();
555 522 }
556 523
@@ -572,13 +539,8 @@
572 539 if ( ! empty( $parsed_dynamic_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control['name'] ] ) ) {
573 540 // Dynamic CSS should not be added to the CSS files.
574 541 // Instead it's handled by \Elementor\Core\DynamicTags\Dynamic_CSS
575 542 // and printed in a style tag.
576 - $should_preserve_value = isset( $control['control_type'] ) && 'content' === $control['control_type'];
577 - if ( $should_preserve_value ) {
578 - $this->preserved_dynamic_style_values[ $control['name'] ] = $parsed_dynamic_settings[ $control['name'] ];
579 - }
580 -
581 543 unset( $parsed_dynamic_settings[ $control['name'] ] );
582 544
583 545 $this->dynamic_elements_ids[] = $controls_stack->get_id();
584 546
@@ -677,10 +639,8 @@
677 639 * @since 1.2.0
678 640 * @access protected
679 641 */
680 642 protected function parse_content() {
681 - Performance::set_use_style_controls( true );
682 -
683 643 $initial_responsive_controls_duplication_mode = Plugin::$instance->breakpoints->get_responsive_control_duplication_mode();
684 644
685 645 Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $this->get_responsive_control_duplication_mode() );
686 646
@@ -702,10 +662,8 @@
702 662 do_action( "elementor/css-file/{$name}/parse", $this );
703 663
704 664 Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $initial_responsive_controls_duplication_mode );
705 665
706 - Performance::set_use_style_controls( false );
707 -
708 666 return $this->get_stylesheet()->__toString();
709 667 }
710 668
711 669 /**
@@ -786,11 +744,9 @@
786 744 // When the control itself has no global value, but it refers to another control global value
787 745 return $this->get_selector_global_value( $control, $values['__globals__'][ $control['name'] ] );
788 746 }
789 747
790 - $value = isset( $values[ $control['name'] ] )
791 - ? $values[ $control['name'] ]
792 - : $this->preserved_dynamic_style_values[ $control['name'] ] ?? null;
748 + $value = $values[ $control['name'] ];
793 749
794 750 if ( isset( $control['selectors_dictionary'][ $value ] ) ) {
795 751 $value = $control['selectors_dictionary'][ $value ];
796 752 }
@@ -907,9 +863,9 @@
907 863 if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) {
908 864 $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' );
909 865
910 866 if ( $default_generic_fonts ) {
911 - $value .= ", $default_generic_fonts";
867 + $value .= ", $default_generic_fonts";
912 868 }
913 869 }
914 870 } else {
915 871 $value = "var( --e-global-$control[type]-$id )";
@@ -917,9 +873,9 @@
917 873
918 874 return $value;
919 875 }
920 876
921 - final protected function get_active_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
877 + final protected function get_active_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
922 878 if ( ! $controls ) {
923 879 $controls = $controls_stack->get_controls();
924 880 }
925 881
@@ -934,9 +890,9 @@
934 890 $active_controls = array_reduce(
935 891 array_keys( $controls ), function( $active_controls, $control_key ) use ( $controls_stack, $controls, $settings ) {
936 892 $control = $controls[ $control_key ];
937 893
938 - if ( $controls_stack->is_control_visible( $control, $settings, $controls ) ) {
894 + if ( $controls_stack->is_control_visible( $control, $settings ) ) {
939 895 $active_controls[ $control_key ] = $control;
940 896 }
941 897
942 898 return $active_controls;
@@ -945,9 +901,9 @@
945 901
946 902 return $active_controls;
947 903 }
948 904
949 - final public function get_style_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
905 + final public function get_style_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
950 906 $controls = $this->get_active_controls( $controls_stack, $controls, $settings );
951 907
952 908 $style_controls = [];
953 909
@@ -1024,12 +980,6 @@
1024 980
1025 981 $globals = $controls_stack->get_settings( '__globals__' );
1026 982
1027 983 return ! empty( $globals[ $control_global_key ] );
1028 - }
1029 -
1030 - public function add_font( $font ) {
1031 - if ( ! in_array( $font, $this->fonts, true ) ) {
1032 - $this->fonts[] = $font;
1033 - }
1034 984 }
1035 985 }