PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 +32 -3 4.1.0-dev34.3.0-beta3 View file →
@@ -9,8 +9,9 @@
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;
13 14 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
14 15 use Elementor\Plugin;
15 16 use Elementor\Stylesheet;
16 17 use Elementor\Icons_Manager;
@@ -200,8 +201,12 @@
200 201 * @since 1.2.0
201 202 * @access public
202 203 */
203 204 public function enqueue() {
205 + if ( $this->should_skip_enqueue() ) {
206 + return;
207 + }
208 +
204 209 $handle_id = $this->get_file_handle_id();
205 210
206 211 if ( isset( self::$printed[ $handle_id ] ) ) {
207 212 return;
@@ -232,16 +237,17 @@
232 237 }
233 238
234 239 if ( self::CSS_STATUS_INLINE === $meta['status'] ) {
235 240 $dep = $this->get_inline_dependency();
236 - // If the dependency has already been printed ( like a template in footer )
237 - if ( wp_styles()->query( $dep, 'done' ) ) {
241 + $is_dependency_registered = (bool) wp_styles()->query( $dep, 'registered' );
242 +
243 + if ( ! $is_dependency_registered || wp_styles()->query( $dep, 'done' ) ) {
238 244 printf( '<style id="%1$s">%2$s</style>', $this->get_file_handle_id(), $meta['css'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
239 245 } else {
240 246 wp_add_inline_style( $dep, $meta['css'] );
241 247 }
242 248 } 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 );
249 + wp_enqueue_style( $this->get_file_handle_id(), $this->get_url(), $this->get_registered_enqueue_dependencies(), null );
244 250 }
245 251
246 252 // Handle fonts.
247 253 if ( ! empty( $meta['fonts'] ) ) {
@@ -604,8 +610,31 @@
604 610 *
605 611 * @return string CSS file handle ID.
606 612 */
607 613 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 + }
608 637
609 638 /**
610 639 * Render CSS.
611 640 *