PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.0-dev3
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/files/css/base.php +11 -55 4.3.0-beta23.23.0-dev3 View file →
@@ -9,9 +9,8 @@
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 12 use Elementor\Core\Frontend\Performance;
13 -use Elementor\Core\Frontend\Widget_Content_Render_Mode;
14 13 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
15 14 use Elementor\Plugin;
16 15 use Elementor\Stylesheet;
17 16 use Elementor\Icons_Manager;
@@ -65,10 +64,8 @@
65 64 private $icons_fonts = [];
66 65
67 66 private $dynamic_elements_ids = [];
68 67
69 - private $preserved_dynamic_style_values = [];
70 -
71 68 /**
72 69 * Stylesheet object.
73 70 *
74 71 * Holds the CSS file stylesheet instance.
@@ -201,12 +198,8 @@
201 198 * @since 1.2.0
202 199 * @access public
203 200 */
204 201 public function enqueue() {
205 - if ( $this->should_skip_enqueue() ) {
206 - return;
207 - }
208 -
209 202 $handle_id = $this->get_file_handle_id();
210 203
211 204 if ( isset( self::$printed[ $handle_id ] ) ) {
212 205 return;
@@ -237,17 +230,16 @@
237 230 }
238 231
239 232 if ( self::CSS_STATUS_INLINE === $meta['status'] ) {
240 233 $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
234 + // If the dependency has already been printed ( like a template in footer )
235 + if ( wp_styles()->query( $dep, 'done' ) ) {
236 + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok.
245 237 } else {
246 238 wp_add_inline_style( $dep, $meta['css'] );
247 239 }
248 240 } 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 );
241 + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
250 242 }
251 243
252 244 // Handle fonts.
253 245 if ( ! empty( $meta['fonts'] ) ) {
@@ -300,9 +292,9 @@
300 292 * @since 1.9.4
301 293 * @access public
302 294 */
303 295 public function print_css() {
304 - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
296 + echo '<style>' . $this->get_content() . '</style>'; // XSS ok.
305 297 Plugin::$instance->frontend->print_fonts_links();
306 298 }
307 299
308 300 /**
@@ -496,9 +488,9 @@
496 488 $value = $this->get_control_global_default_value( $control );
497 489 }
498 490
499 491 if ( Controls_Manager::FONT === $control['type'] ) {
500 - $this->add_font( $value );
492 + $this->fonts[] = $value;
501 493 }
502 494
503 495 /** @var Base_Data_Control $control_obj */
504 496 $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
@@ -554,9 +546,9 @@
554 546 * @param array $placeholders Placeholders.
555 547 * @param array $replacements Replacements.
556 548 * @param array $all_controls All controls.
557 549 */
558 - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) {
550 + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) {
559 551 if ( ! $all_controls ) {
560 552 $all_controls = $controls_stack->get_controls();
561 553 }
562 554
@@ -578,13 +570,8 @@
578 570 if ( ! empty( $parsed_dynamic_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control['name'] ] ) ) {
579 571 // Dynamic CSS should not be added to the CSS files.
580 572 // Instead it's handled by \Elementor\Core\DynamicTags\Dynamic_CSS
581 573 // 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 574 unset( $parsed_dynamic_settings[ $control['name'] ] );
588 575
589 576 $this->dynamic_elements_ids[] = $controls_stack->get_id();
590 577
@@ -611,31 +598,8 @@
611 598 * @return string CSS file handle ID.
612 599 */
613 600 abstract protected function get_file_handle_id();
614 601
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 602 /**
639 603 * Render CSS.
640 604 *
641 605 * Parse the CSS.
@@ -815,11 +779,9 @@
815 779 // When the control itself has no global value, but it refers to another control global value
816 780 return $this->get_selector_global_value( $control, $values['__globals__'][ $control['name'] ] );
817 781 }
818 782
819 - $value = isset( $values[ $control['name'] ] )
820 - ? $values[ $control['name'] ]
821 - : $this->preserved_dynamic_style_values[ $control['name'] ] ?? null;
783 + $value = $values[ $control['name'] ];
822 784
823 785 if ( isset( $control['selectors_dictionary'][ $value ] ) ) {
824 786 $value = $control['selectors_dictionary'][ $value ];
825 787 }
@@ -936,9 +898,9 @@
936 898 if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) {
937 899 $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' );
938 900
939 901 if ( $default_generic_fonts ) {
940 - $value .= ", $default_generic_fonts";
902 + $value .= ", $default_generic_fonts";
941 903 }
942 904 }
943 905 } else {
944 906 $value = "var( --e-global-$control[type]-$id )";
@@ -946,9 +908,9 @@
946 908
947 909 return $value;
948 910 }
949 911
950 - final protected function get_active_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
912 + final protected function get_active_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
951 913 if ( ! $controls ) {
952 914 $controls = $controls_stack->get_controls();
953 915 }
954 916
@@ -974,9 +936,9 @@
974 936
975 937 return $active_controls;
976 938 }
977 939
978 - final public function get_style_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) {
940 + final public function get_style_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) {
979 941 $controls = $this->get_active_controls( $controls_stack, $controls, $settings );
980 942
981 943 $style_controls = [];
982 944
@@ -1053,12 +1015,6 @@
1053 1015
1054 1016 $globals = $controls_stack->get_settings( '__globals__' );
1055 1017
1056 1018 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 1019 }
1064 1020 }