| @@ -64,10 +64,8 @@ | ||
| 64 | 64 | private $icons_fonts = []; |
| 65 | 65 | |
| 66 | 66 | private $dynamic_elements_ids = []; |
| 67 | 67 | |
| 68 | - private $preserved_dynamic_style_values = []; | |
| 69 | - | |
| 70 | 68 | /** |
| 71 | 69 | * Stylesheet object. |
| 72 | 70 | * |
| 73 | 71 | * Holds the CSS file stylesheet instance. |
| @@ -234,14 +232,14 @@ | ||
| 234 | 232 | if ( self::CSS_STATUS_INLINE === $meta['status'] ) { |
| 235 | 233 | $dep = $this->get_inline_dependency(); |
| 236 | 234 | // If the dependency has already been printed ( like a template in footer ) |
| 237 | 235 | 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 | |
| 236 | + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok. | |
| 239 | 237 | } else { |
| 240 | 238 | wp_add_inline_style( $dep, $meta['css'] ); |
| 241 | 239 | } |
| 242 | 240 | } 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 ); | |
| 241 | + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 244 | 242 | } |
| 245 | 243 | |
| 246 | 244 | // Handle fonts. |
| 247 | 245 | if ( ! empty( $meta['fonts'] ) ) { |
| @@ -294,9 +292,9 @@ | ||
| 294 | 292 | * @since 1.9.4 |
| 295 | 293 | * @access public |
| 296 | 294 | */ |
| 297 | 295 | public function print_css() { |
| 298 | - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 296 | + echo '<style>' . $this->get_content() . '</style>'; // XSS ok. | |
| 299 | 297 | Plugin::$instance->frontend->print_fonts_links(); |
| 300 | 298 | } |
| 301 | 299 | |
| 302 | 300 | /** |
| @@ -490,9 +488,9 @@ | ||
| 490 | 488 | $value = $this->get_control_global_default_value( $control ); |
| 491 | 489 | } |
| 492 | 490 | |
| 493 | 491 | if ( Controls_Manager::FONT === $control['type'] ) { |
| 494 | - $this->add_font( $value ); | |
| 492 | + $this->fonts[] = $value; | |
| 495 | 493 | } |
| 496 | 494 | |
| 497 | 495 | /** @var Base_Data_Control $control_obj */ |
| 498 | 496 | $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); |
| @@ -548,9 +546,9 @@ | ||
| 548 | 546 | * @param array $placeholders Placeholders. |
| 549 | 547 | * @param array $replacements Replacements. |
| 550 | 548 | * @param array $all_controls All controls. |
| 551 | 549 | */ |
| 552 | - 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 ) { | |
| 553 | 551 | if ( ! $all_controls ) { |
| 554 | 552 | $all_controls = $controls_stack->get_controls(); |
| 555 | 553 | } |
| 556 | 554 | |
| @@ -572,13 +570,8 @@ | ||
| 572 | 570 | if ( ! empty( $parsed_dynamic_settings[ Manager::DYNAMIC_SETTING_KEY ][ $control['name'] ] ) ) { |
| 573 | 571 | // Dynamic CSS should not be added to the CSS files. |
| 574 | 572 | // Instead it's handled by \Elementor\Core\DynamicTags\Dynamic_CSS |
| 575 | 573 | // 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 | 574 | unset( $parsed_dynamic_settings[ $control['name'] ] ); |
| 582 | 575 | |
| 583 | 576 | $this->dynamic_elements_ids[] = $controls_stack->get_id(); |
| 584 | 577 | |
| @@ -786,11 +779,9 @@ | ||
| 786 | 779 | // When the control itself has no global value, but it refers to another control global value |
| 787 | 780 | return $this->get_selector_global_value( $control, $values['__globals__'][ $control['name'] ] ); |
| 788 | 781 | } |
| 789 | 782 | |
| 790 | - $value = isset( $values[ $control['name'] ] ) | |
| 791 | - ? $values[ $control['name'] ] | |
| 792 | - : $this->preserved_dynamic_style_values[ $control['name'] ] ?? null; | |
| 783 | + $value = $values[ $control['name'] ]; | |
| 793 | 784 | |
| 794 | 785 | if ( isset( $control['selectors_dictionary'][ $value ] ) ) { |
| 795 | 786 | $value = $control['selectors_dictionary'][ $value ]; |
| 796 | 787 | } |
| @@ -907,9 +898,9 @@ | ||
| 907 | 898 | if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) { |
| 908 | 899 | $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' ); |
| 909 | 900 | |
| 910 | 901 | if ( $default_generic_fonts ) { |
| 911 | - $value .= ", $default_generic_fonts"; | |
| 902 | + $value .= ", $default_generic_fonts"; | |
| 912 | 903 | } |
| 913 | 904 | } |
| 914 | 905 | } else { |
| 915 | 906 | $value = "var( --e-global-$control[type]-$id )"; |
| @@ -917,9 +908,9 @@ | ||
| 917 | 908 | |
| 918 | 909 | return $value; |
| 919 | 910 | } |
| 920 | 911 | |
| 921 | - 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 ) { | |
| 922 | 913 | if ( ! $controls ) { |
| 923 | 914 | $controls = $controls_stack->get_controls(); |
| 924 | 915 | } |
| 925 | 916 | |
| @@ -945,9 +936,9 @@ | ||
| 945 | 936 | |
| 946 | 937 | return $active_controls; |
| 947 | 938 | } |
| 948 | 939 | |
| 949 | - 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 ) { | |
| 950 | 941 | $controls = $this->get_active_controls( $controls_stack, $controls, $settings ); |
| 951 | 942 | |
| 952 | 943 | $style_controls = []; |
| 953 | 944 | |
| @@ -1024,12 +1015,6 @@ | ||
| 1024 | 1015 | |
| 1025 | 1016 | $globals = $controls_stack->get_settings( '__globals__' ); |
| 1026 | 1017 | |
| 1027 | 1018 | 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 | 1019 | } |
| 1035 | 1020 | } |