From aa973518f0655b98df7284bd22b7cc6b36e60fa7 Mon Sep 17 00:00:00 2001 From: Kosta Date: Fri, 19 Apr 2024 16:05:27 +0200 Subject: [PATCH] Ensure gutenberg assets are enqueued only when needed (#36983) --- .../jetpack-mu-wpcom/changelog/fix-verbum-style-enqueue | 4 ++++ .../assets/class-verbum-gutenberg-editor.php | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-verbum-style-enqueue diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-verbum-style-enqueue b/projects/packages/jetpack-mu-wpcom/changelog/fix-verbum-style-enqueue new file mode 100644 index 0000000000000..727cedcb39d8c --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-verbum-style-enqueue @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix enqueuing editor styles diff --git a/projects/packages/jetpack-mu-wpcom/src/features/verbum-comments/assets/class-verbum-gutenberg-editor.php b/projects/packages/jetpack-mu-wpcom/src/features/verbum-comments/assets/class-verbum-gutenberg-editor.php index 6a9ac17801cc2..c177984a4b819 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/verbum-comments/assets/class-verbum-gutenberg-editor.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/verbum-comments/assets/class-verbum-gutenberg-editor.php @@ -51,8 +51,17 @@ public function remove_strict_kses_filters() { /** * Enqueue the assets for the Gutenberg editor + * + * In case the page is singular and has comment closed or front page with comments closed we avoid the enqueueing */ public function enqueue_assets() { + if ( + ! ( is_singular() && comments_open() ) + && ! ( is_front_page() && is_page() && comments_open() ) + ) { + return; + } + $vbe_cache_buster = filemtime( ABSPATH . '/widgets.wp.com/verbum-block-editor/build_meta.json' ); wp_enqueue_style(