| @@ -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' ) ) { | |
| 236 | + // If the dependency has already been printed ( like a template in footer ) | |
| 237 | + if ( wp_styles()->query( $dep, 'done' ) ) { | |
| 244 | 238 | printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 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 ); | |
| 250 | 244 | } |
| 251 | 245 | |
| 252 | 246 | // Handle fonts. |
| 253 | 247 | if ( ! empty( $meta['fonts'] ) ) { |
| @@ -610,31 +604,8 @@ | ||
| 610 | 604 | * |
| 611 | 605 | * @return string CSS file handle ID. |
| 612 | 606 | */ |
| 613 | 607 | abstract protected function get_file_handle_id(); |
| 614 | - | |
| 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 | 608 | |
| 638 | 609 | /** |
| 639 | 610 | * Render CSS. |
| 640 | 611 | * |