From 10ab25be57b19fafbf6e9a9e9e4f202058e179b7 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 30 Jul 2021 10:02:51 -0300 Subject: [PATCH] Optimize assets loading --- classes/class-ep-debug-bar-elasticpress.php | 8 ++++++-- debug-bar-elasticpress.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/class-ep-debug-bar-elasticpress.php b/classes/class-ep-debug-bar-elasticpress.php index e105522..f1e92b5 100755 --- a/classes/class-ep-debug-bar-elasticpress.php +++ b/classes/class-ep-debug-bar-elasticpress.php @@ -36,8 +36,12 @@ public function init() { * Enqueue scripts for front end and admin */ public function enqueue_scripts_styles() { - wp_enqueue_script( 'debug-bar-elasticpress', plugins_url( '../assets/js/main.js', __FILE__ ), array( 'wp-dom-ready' ), EP_DEBUG_VERSION, true ); - wp_enqueue_style( 'debug-bar-elasticpress', plugins_url( '../assets/css/main.css', __FILE__ ), array(), EP_DEBUG_VERSION ); + if ( ! is_user_logged_in() ) { + return; + } + + wp_enqueue_script( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/js/main.js', array( 'wp-dom-ready' ), EP_DEBUG_VERSION, true ); + wp_enqueue_style( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/css/main.css', array(), EP_DEBUG_VERSION ); } /** diff --git a/debug-bar-elasticpress.php b/debug-bar-elasticpress.php index 75bbaed..d6eb454 100755 --- a/debug-bar-elasticpress.php +++ b/debug-bar-elasticpress.php @@ -14,6 +14,7 @@ */ define( 'EP_DEBUG_VERSION', '2.0.0' ); +define( 'EP_DEBUG_URL', plugin_dir_url( __FILE__ ) ); /** * Register panel