From 94dc340831a2415aea981b29aa04d8ac871051f4 Mon Sep 17 00:00:00 2001 From: inwerpsel Date: Thu, 25 Feb 2021 10:31:29 +0100 Subject: [PATCH] PLANET-5971 Fix blocks js loading when logged in * By not making jquery depend on it when logged in, since in that case WordPress enqueues jquery in the head. --- src/MasterSite.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MasterSite.php b/src/MasterSite.php index 437104da7c..8d0c89f7ec 100644 --- a/src/MasterSite.php +++ b/src/MasterSite.php @@ -717,7 +717,9 @@ public function enqueue_public_assets() { // This loads a linked style file since the relative images paths are outside the build directory. wp_enqueue_style( 'parent-style', $this->theme_dir . '/assets/build/style.min.css', [], $css_creation ); - $jquery_deps = is_plugin_active( 'planet4-plugin-gutenberg-blocks/planet4-gutenberg-blocks.php' ) ? [ 'planet4-blocks-frontend' ] : []; + $jquery_should_wait = is_plugin_active( 'planet4-plugin-gutenberg-blocks/planet4-gutenberg-blocks.php' ) && ! is_user_logged_in(); + + $jquery_deps = $jquery_should_wait ? [ 'planet4-blocks-frontend' ] : []; // JS files. wp_deregister_script( 'jquery' );