| @@ -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. |
| @@ -234,14 +231,14 @@ | ||
| 234 | 231 | if ( self::CSS_STATUS_INLINE === $meta['status'] ) { |
| 235 | 232 | $dep = $this->get_inline_dependency(); |
| 236 | 233 | // If the dependency has already been printed ( like a template in footer ) |
| 237 | 234 | 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 | |
| 235 | + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok. | |
| 239 | 236 | } else { |
| 240 | 237 | wp_add_inline_style( $dep, $meta['css'] ); |
| 241 | 238 | } |
| 242 | 239 | } 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 ); | |
| 240 | + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 244 | 241 | } |
| 245 | 242 | |
| 246 | 243 | // Handle fonts. |
| 247 | 244 | if ( ! empty( $meta['fonts'] ) ) { |
| @@ -294,9 +291,9 @@ | ||
| 294 | 291 | * @since 1.9.4 |
| 295 | 292 | * @access public |
| 296 | 293 | */ |
| 297 | 294 | public function print_css() { |
| 298 | - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 295 | + echo '<style>' . $this->get_content() . '</style>'; // XSS ok. | |
| 299 | 296 | Plugin::$instance->frontend->print_fonts_links(); |
| 300 | 297 | } |
| 301 | 298 | |
| 302 | 299 | /** |
| @@ -490,9 +487,9 @@ | ||
| 490 | 487 | $value = $this->get_control_global_default_value( $control ); |
| 491 | 488 | } |
| 492 | 489 | |
| 493 | 490 | if ( Controls_Manager::FONT === $control['type'] ) { |
| 494 | - $this->add_font( $value ); | |
| 491 | + $this->fonts[] = $value; | |
| 495 | 492 | } |
| 496 | 493 | |
| 497 | 494 | /** @var Base_Data_Control $control_obj */ |
| 498 | 495 | $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); |
| @@ -548,9 +545,9 @@ | ||
| 548 | 545 | * @param array $placeholders Placeholders. |
| 549 | 546 | * @param array $replacements Replacements. |
| 550 | 547 | * @param array $all_controls All controls. |
| 551 | 548 | */ |
| 552 | - 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 ) { | |
| 553 | 550 | if ( ! $all_controls ) { |
| 554 | 551 | $all_controls = $controls_stack->get_controls(); |
| 555 | 552 | } |
| 556 | 553 | |
| @@ -572,13 +569,8 @@ | ||
| 572 | 569 | if ( ! empty( $parsed_dynamic_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control['name'] ] ) ) { |
| 573 | 570 | // Dynamic CSS should not be added to the CSS files. |
| 574 | 571 | // Instead it's handled by \Elementor\Core\DynamicTags\Dynamic_CSS |
| 575 | 572 | // 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 | 573 | unset( $parsed_dynamic_settings[ $control['name'] ] ); |
| 582 | 574 | |
| 583 | 575 | $this->dynamic_elements_ids[] = $controls_stack->get_id(); |
| 584 | 576 | |
| @@ -677,10 +669,8 @@ | ||
| 677 | 669 | * @since 1.2.0 |
| 678 | 670 | * @access protected |
| 679 | 671 | */ |
| 680 | 672 | protected function parse_content() { |
| 681 | - Performance::set_use_style_controls( true ); | |
| 682 | - | |
| 683 | 673 | $initial_responsive_controls_duplication_mode = Plugin::$instance->breakpoints->get_responsive_control_duplication_mode(); |
| 684 | 674 | |
| 685 | 675 | Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $this->get_responsive_control_duplication_mode() ); |
| 686 | 676 | |
| @@ -702,10 +692,8 @@ | ||
| 702 | 692 | do_action( "elementor/css-file/{$name}/parse", $this ); |
| 703 | 693 | |
| 704 | 694 | Plugin::$instance->breakpoints->set_responsive_control_duplication_mode( $initial_responsive_controls_duplication_mode ); |
| 705 | 695 | |
| 706 | - Performance::set_use_style_controls( false ); | |
| 707 | - | |
| 708 | 696 | return $this->get_stylesheet()->__toString(); |
| 709 | 697 | } |
| 710 | 698 | |
| 711 | 699 | /** |
| @@ -786,11 +774,9 @@ | ||
| 786 | 774 | // When the control itself has no global value, but it refers to another control global value |
| 787 | 775 | return $this->get_selector_global_value( $control, $values['__globals__'][ $control['name'] ] ); |
| 788 | 776 | } |
| 789 | 777 | |
| 790 | - $value = isset( $values[ $control['name'] ] ) | |
| 791 | - ? $values[ $control['name'] ] | |
| 792 | - : $this->preserved_dynamic_style_values[ $control['name'] ] ?? null; | |
| 778 | + $value = $values[ $control['name'] ]; | |
| 793 | 779 | |
| 794 | 780 | if ( isset( $control['selectors_dictionary'][ $value ] ) ) { |
| 795 | 781 | $value = $control['selectors_dictionary'][ $value ]; |
| 796 | 782 | } |
| @@ -907,9 +893,9 @@ | ||
| 907 | 893 | if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) { |
| 908 | 894 | $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' ); |
| 909 | 895 | |
| 910 | 896 | if ( $default_generic_fonts ) { |
| 911 | - $value .= ", $default_generic_fonts"; | |
| 897 | + $value .= ", $default_generic_fonts"; | |
| 912 | 898 | } |
| 913 | 899 | } |
| 914 | 900 | } else { |
| 915 | 901 | $value = "var( --e-global-$control[type]-$id )"; |
| @@ -917,9 +903,9 @@ | ||
| 917 | 903 | |
| 918 | 904 | return $value; |
| 919 | 905 | } |
| 920 | 906 | |
| 921 | - 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 ) { | |
| 922 | 908 | if ( ! $controls ) { |
| 923 | 909 | $controls = $controls_stack->get_controls(); |
| 924 | 910 | } |
| 925 | 911 | |
| @@ -945,9 +931,9 @@ | ||
| 945 | 931 | |
| 946 | 932 | return $active_controls; |
| 947 | 933 | } |
| 948 | 934 | |
| 949 | - 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 ) { | |
| 950 | 936 | $controls = $this->get_active_controls( $controls_stack, $controls, $settings ); |
| 951 | 937 | |
| 952 | 938 | $style_controls = []; |
| 953 | 939 | |
| @@ -1024,12 +1010,6 @@ | ||
| 1024 | 1010 | |
| 1025 | 1011 | $globals = $controls_stack->get_settings( '__globals__' ); |
| 1026 | 1012 | |
| 1027 | 1013 | 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 | 1014 | } |
| 1035 | 1015 | } |