| @@ -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; |
| @@ -201,12 +200,8 @@ | ||
| 201 | 200 | * @since 1.2.0 |
| 202 | 201 | * @access public |
| 203 | 202 | */ |
| 204 | 203 | public function enqueue() { |
| 205 | - if ( $this->should_skip_enqueue() ) { | |
| 206 | - return; | |
| 207 | - } | |
| 208 | - | |
| 209 | 204 | $handle_id = $this->get_file_handle_id(); |
| 210 | 205 | |
| 211 | 206 | if ( isset( self::$printed[ $handle_id ] ) ) { |
| 212 | 207 | return; |
| @@ -237,17 +232,16 @@ | ||
| 237 | 232 | } |
| 238 | 233 | |
| 239 | 234 | if ( self::CSS_STATUS_INLINE === $meta['status'] ) { |
| 240 | 235 | $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 | |
| 236 | + // If the dependency has already been printed ( like a template in footer ) | |
| 237 | + if ( wp_styles()->query( $dep, 'done' ) ) { | |
| 238 | + printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // XSS ok. | |
| 245 | 239 | } else { |
| 246 | 240 | wp_add_inline_style( $dep, $meta['css'] ); |
| 247 | 241 | } |
| 248 | 242 | } 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 ); | |
| 243 | + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_enqueue_dependencies(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 250 | 244 | } |
| 251 | 245 | |
| 252 | 246 | // Handle fonts. |
| 253 | 247 | if ( ! empty( $meta['fonts'] ) ) { |
| @@ -300,9 +294,9 @@ | ||
| 300 | 294 | * @since 1.9.4 |
| 301 | 295 | * @access public |
| 302 | 296 | */ |
| 303 | 297 | public function print_css() { |
| 304 | - echo '<style>' . $this->get_content() . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 298 | + echo '<style>' . $this->get_content() . '</style>'; // XSS ok. | |
| 305 | 299 | Plugin::$instance->frontend->print_fonts_links(); |
| 306 | 300 | } |
| 307 | 301 | |
| 308 | 302 | /** |
| @@ -496,9 +490,9 @@ | ||
| 496 | 490 | $value = $this->get_control_global_default_value( $control ); |
| 497 | 491 | } |
| 498 | 492 | |
| 499 | 493 | if ( Controls_Manager::FONT === $control['type'] ) { |
| 500 | - $this->add_font( $value ); | |
| 494 | + $this->fonts[] = $value; | |
| 501 | 495 | } |
| 502 | 496 | |
| 503 | 497 | /** @var Base_Data_Control $control_obj */ |
| 504 | 498 | $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); |
| @@ -554,9 +548,9 @@ | ||
| 554 | 548 | * @param array $placeholders Placeholders. |
| 555 | 549 | * @param array $replacements Replacements. |
| 556 | 550 | * @param array $all_controls All controls. |
| 557 | 551 | */ |
| 558 | - public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, ?array $all_controls = null ) { | |
| 552 | + public function add_controls_stack_style_rules( Controls_Stack $controls_stack, array $controls, array $values, array $placeholders, array $replacements, array $all_controls = null ) { | |
| 559 | 553 | if ( ! $all_controls ) { |
| 560 | 554 | $all_controls = $controls_stack->get_controls(); |
| 561 | 555 | } |
| 562 | 556 | |
| @@ -611,31 +605,8 @@ | ||
| 611 | 605 | * @return string CSS file handle ID. |
| 612 | 606 | */ |
| 613 | 607 | abstract protected function get_file_handle_id(); |
| 614 | 608 | |
| 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 | 609 | /** |
| 639 | 610 | * Render CSS. |
| 640 | 611 | * |
| 641 | 612 | * Parse the CSS. |
| @@ -936,9 +907,9 @@ | ||
| 936 | 907 | if ( $control['groupPrefix'] . 'font_family' === $control['name'] ) { |
| 937 | 908 | $default_generic_fonts = Plugin::$instance->kits_manager->get_current_settings( 'default_generic_fonts' ); |
| 938 | 909 | |
| 939 | 910 | if ( $default_generic_fonts ) { |
| 940 | - $value .= ", $default_generic_fonts"; | |
| 911 | + $value .= ", $default_generic_fonts"; | |
| 941 | 912 | } |
| 942 | 913 | } |
| 943 | 914 | } else { |
| 944 | 915 | $value = "var( --e-global-$control[type]-$id )"; |
| @@ -946,9 +917,9 @@ | ||
| 946 | 917 | |
| 947 | 918 | return $value; |
| 948 | 919 | } |
| 949 | 920 | |
| 950 | - final protected function get_active_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) { | |
| 921 | + final protected function get_active_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) { | |
| 951 | 922 | if ( ! $controls ) { |
| 952 | 923 | $controls = $controls_stack->get_controls(); |
| 953 | 924 | } |
| 954 | 925 | |
| @@ -974,9 +945,9 @@ | ||
| 974 | 945 | |
| 975 | 946 | return $active_controls; |
| 976 | 947 | } |
| 977 | 948 | |
| 978 | - final public function get_style_controls( Controls_Stack $controls_stack, ?array $controls = null, ?array $settings = null ) { | |
| 949 | + final public function get_style_controls( Controls_Stack $controls_stack, array $controls = null, array $settings = null ) { | |
| 979 | 950 | $controls = $this->get_active_controls( $controls_stack, $controls, $settings ); |
| 980 | 951 | |
| 981 | 952 | $style_controls = []; |
| 982 | 953 | |
| @@ -1053,12 +1024,6 @@ | ||
| 1053 | 1024 | |
| 1054 | 1025 | $globals = $controls_stack->get_settings( '__globals__' ); |
| 1055 | 1026 | |
| 1056 | 1027 | 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 | 1028 | } |
| 1064 | 1029 | } |