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.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 4.0.8 4.1.0-beta1 All 453 releases
← All changes | core/files/css/base.php +11 -60 4.3.0-beta23.17.2 View file →
@@ -8,10 +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 -use Elementor\Core\Frontend\Widget_Content_Render_Mode;
14 12 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
15 13 use Elementor\Plugin;
16 14 use Elementor\Stylesheet;
17 15 use Elementor\Icons_Manager;
@@ -65,10 +63,8 @@
65 63 private $icons_fonts = [];
66 64
67 65 private $dynamic_elements_ids = [];
68 66
69 - private $preserved_dynamic_style_values = [];
70 -
71 67 /**
72 68 * Stylesheet object.
73 69 *
74 70 * Holds the CSS file stylesheet instance.
@@ -201,12 +197,8 @@
201 197 * @since 1.2.0
202 198 * @access public
203 199 */
204 200 public function enqueue() {
205 - if ( $this->should_skip_enqueue() ) {
206 - return;
207 - }
208 -
209 201 $handle_id = $this->get_file_handle_id();
210 202
211 203 if ( isset( self::$printed[ $handle_id ] ) ) {
212 204 return;
@@ -237,17 +229,16 @@
237 229 }
238 230
239 231 if ( self::CSS_STATUS_INLINE === $meta['status'] ) {
240 232 $dep = $this->get_inline_dependency();
241 - $is_dependency_registered = (bool) wp_styles()->query( $dep, 'registered' );
242 -
243 - if ( ! $is_dependency_registered || wp_styles()->query( $dep, 'done' ) ) {
244 - printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
233 + // If the dependency has already been printed ( like a template in footer )
234 + if ( wp_styles()->query( $dep, 'done' ) ) {
235 + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok.
245 236 } else {
246 237 wp_add_inline_style( $dep, $meta['css'] );
247 238 }
248 239 } elseif ( self::CSS_STATUS_FILE === $meta['status'] ) { // Re-check if it's not empty after CSS update.
249 - wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_registered_enqueue_dependencies(), null );
240 + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
250 241 }
251 242
252 243 // Handle fonts.
253 244 if ( ! empty( $meta['fonts'] ) ) {
@@ -300,9 +291,9 @@
300 291 * @since 1.9.4
301 292 * @access public
302 293 */
303 294 public function print_css() {
304 - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
295 + echo '<style>' . $this->get_content() . '</style>'; // XSS ok.
305 296 Plugin::$instance->frontend->print_fonts_links();
306 297 }
307 298
308 299 /**
@@ -496,9 +487,9 @@
496 487 $value = $this->get_control_global_default_value( $control );
497 488 }
498 489
499 490 if ( Controls_Manager::FONT === $control['type'] ) {
500 - $this->add_font( $value );
491 + $this->fonts[] = $value;
501 492 }
502 493
503 494 /** @var Base_Data_Control $control_obj */
504 495 $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
@@ -554,9 +545,9 @@
554 545 * @param array $placeholders Placeholders.
555 546 * @param array $replacements Replacements.
556 547 * @param array $all_controls All controls.
557 548 */
558 - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) {
549 + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) {
559 550 if ( ! $all_controls ) {
560 551 $all_controls = $controls_stack->get_controls();
561 552 }
562 553
@@ -578,13 +569,8 @@
578 569 if ( ! empty( $parsed_dynamic_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control['name'] ] ) ) {
579 570 // Dynamic CSS should not be added to the CSS files.
580 571 // Instead it's handled by \Elementor\Core\DynamicTags\Dynamic_CSS
581 572 // and printed in a style tag.
582 - $should_preserve_value = isset( $control['control_type'] ) && 'content' === $control['control_type'];
583 - if ( $should_preserve_value ) {
584 - $this->preserved_dynamic_style_values[ $control['name'] ] = $parsed_dynamic_settings[ $control['name'] ];
585 - }
586 -
587 573 unset( $parsed_dynamic_settings[ $control['name'] ] );
588 574
589 575 $this->dynamic_elements_ids[] = $controls_stack->get_id();
590 576
@@ -611,31 +597,8 @@
611 597 * @return string CSS file handle ID.
612 598 */
613 599 abstract protected function get_file_handle_id();
614 600
615 - protected function should_skip_enqueue(): bool {
616 - if ( Widget_Content_Render_Mode::is( Widget_Content_Render_Mode::MARKDOWN ) ) {
617 - return true;
618 - }
619 -
620 - if ( ! is_admin() ) {
621 - return false;
622 - }
623 -
624 - $editor = Plugin::$instance->editor;
625 -
626 - return $editor && $editor->is_editor_request();
627 - }
628 -
629 - protected function get_registered_enqueue_dependencies(): array {
630 - return array_values( array_filter(
631 - $this->get_enqueue_dependencies(),
632 - static function ( $handle ) {
633 - return (bool) wp_styles()->query( $handle, 'registered' );
634 - }
635 - ) );
636 - }
637 -
638 601 /**
639 602 * Render CSS.
640 603 *
641 604 * Parse the CSS.
@@ -706,10 +669,8 @@
706 669 * @since 1.2.0
707 670 * @access protected
708 671 */
709 672 protected function parse_content() {
710 - Performance::set_use_style_controls( true );
711 -
712 673 $initial_responsive_controls_duplication_mode = Plugin::$instance->breakpoints->get_responsive_control_duplication_mode();
713 674
714 675 Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $this->get_responsive_control_duplication_mode() );
715 676
@@ -731,10 +692,8 @@
731 692 do_action( "elementor/css-file/{$name}/parse", $this );
732 693
733 694 Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $initial_responsive_controls_duplication_mode );
734 695
735 - Performance::set_use_style_controls( false );
736 -
737 696 return $this->get_stylesheet()->__toString();
738 697 }
739 698
740 699 /**
@@ -815,11 +774,9 @@
815 774 // When the control itself has no global value, but it refers to another control global value
816 775 return $this->get_selector_global_value( $control, $values['__globals__'][ $control['name'] ] );
817 776 }
818 777
819 - $value = isset( $values[ $control['name'] ] )
820 - ? $values[ $control['name'] ]
821 - : $this->preserved_dynamic_style_values[ $control['name'] ] ?? null;
778 + $value = $values[ $control['name'] ];
822 779
823 780 if ( isset( $control['selectors_dictionary'][ $value ] ) ) {
824 781 $value = $control['selectors_dictionary'][ $value ];
825 782 }
@@ -936,9 +893,9 @@
936 893 if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) {
937 894 $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' );
938 895
939 896 if ( $default_generic_fonts ) {
940 - $value .= ", $default_generic_fonts";
897 + $value .= ", $default_generic_fonts";
941 898 }
942 899 }
943 900 } else {
944 901 $value = "var( --e-global-$control[type]-$id )";
@@ -946,9 +903,9 @@
946 903
947 904 return $value;
948 905 }
949 906
950 - final protected function get_active_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
907 + final protected function get_active_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
951 908 if ( ! $controls ) {
952 909 $controls = $controls_stack->get_controls();
953 910 }
954 911
@@ -974,9 +931,9 @@
974 931
975 932 return $active_controls;
976 933 }
977 934
978 - final public function get_style_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
935 + final public function get_style_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
979 936 $controls = $this->get_active_controls( $controls_stack, $controls, $settings );
980 937
981 938 $style_controls = [];
982 939
@@ -1053,12 +1010,6 @@
1053 1010
1054 1011 $globals = $controls_stack->get_settings( '__globals__' );
1055 1012
1056 1013 return ! empty( $globals[ $control_global_key ] );
1057 - }
1058 -
1059 - public function add_font( $font ) {
1060 - if ( ! in_array( $font, $this->fonts, true ) ) {
1061 - $this->fonts[] = $font;
1062 - }
1063 1014 }
1064 1015 }