From 73733c23ecabc6d092898ce85bc9e12da6963d8e Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 22 Apr 2026 11:47:48 +0500 Subject: [PATCH 1/3] Add compatibility with Query Monitor 4 --- assets/css/main.css | 35 ++++++++++++--------------- classes/CommonPanel.php | 19 ++++++++++++--- classes/EP_Debug_Bar_ElasticPress.php | 5 ++-- classes/QueryLog.php | 4 ++- classes/QueryMonitorOutput.php | 14 +++++++++++ debug-bar-elasticpress.php | 2 +- 6 files changed, 53 insertions(+), 26 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index 5594500..cf3ab2f 100755 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -10,11 +10,15 @@ } .ep-queries-debug .dashicons { + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid currentColor; cursor: pointer; -} - -.ep-queries-debug .dashicons::before { - content: "\f140"; + display: inline-block; + height: 0; + margin-left: 5px; + vertical-align: middle; + width: 0; } .ep-queries-debug .hide-query-results .query-results, @@ -33,12 +37,13 @@ background-color: white; } -.ep-queries-debug .hide-query-results .query-result-toggle::before, -.ep-queries-debug .hide-query-args .query-args-toggle::before, -.ep-queries-debug .hide-query-headers .query-headers-toggle::before, -.ep-queries-debug .hide-query-errors .query-errors-toggle::before, -.ep-queries-debug .hide-query-body .query-body-toggle::before { - content: "\f142"; +.ep-queries-debug .hide-query-results .query-result-toggle, +.ep-queries-debug .hide-query-args .query-args-toggle, +.ep-queries-debug .hide-query-headers .query-headers-toggle, +.ep-queries-debug .hide-query-errors .query-errors-toggle, +.ep-queries-debug .hide-query-body .query-body-toggle { + border-bottom: 5px solid currentColor; + border-top: none; } .ep-queries-debug .ep-query-failed .ep-query-response-code { @@ -55,17 +60,9 @@ } .ep-queries-debug-container .copy-curl { - border-color: #000; - border-radius: 3px; - border-style: solid; - border-width: 1px; - color: #000; cursor: pointer; display: inline-block; font-size: 13px; - line-height: 2.1538; - min-height: 30px; - padding: 0 10px; text-decoration: none; } @@ -85,7 +82,7 @@ background: #f6f7f7 !important; border: 1px solid #2271b1 !important; border-radius: 3px !important; - + /* Overriding some Debug Bar "important" rules */ color: #2271b1 !important; cursor: pointer; diff --git a/classes/CommonPanel.php b/classes/CommonPanel.php index 75c0861..63be14f 100644 --- a/classes/CommonPanel.php +++ b/classes/CommonPanel.php @@ -36,15 +36,28 @@ public function get_title(): string { /** * Enqueue scripts for front end and admin */ - public function enqueue_scripts_styles() { + public function enqueue_scripts(): void { if ( ! is_user_logged_in() ) { return; } - wp_enqueue_script( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/js/main.js', array( 'wp-dom-ready', 'clipboard' ), EP_DEBUG_VERSION, true ); - wp_enqueue_style( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/css/main.css', array(), EP_DEBUG_VERSION ); + wp_enqueue_script( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/js/main.js', [ 'wp-dom-ready', 'clipboard' ], EP_DEBUG_VERSION, true ); } + /** + * Enqueue styles for front end and admin + * + * @since 3.1.0 + */ + public function enqueue_styles(): void { + if ( ! is_user_logged_in() ) { + return; + } + + wp_enqueue_style( 'debug-bar-elasticpress', EP_DEBUG_URL . 'assets/css/main.css', [], EP_DEBUG_VERSION ); + } + + /** * Show the contents of the panel */ diff --git a/classes/EP_Debug_Bar_ElasticPress.php b/classes/EP_Debug_Bar_ElasticPress.php index ed0ab2b..e5eaf81 100644 --- a/classes/EP_Debug_Bar_ElasticPress.php +++ b/classes/EP_Debug_Bar_ElasticPress.php @@ -38,14 +38,15 @@ public function init() { $this->title( esc_html__( 'ElasticPress', 'debug-bar-elasticpress' ) ); $this->common_panel = new \DebugBarElasticPress\CommonPanel(); - $this->common_panel->enqueue_scripts_styles(); + $this->common_panel->enqueue_scripts(); + $this->common_panel->enqueue_styles(); } /** * Enqueue scripts for front end and admin */ public function enqueue_scripts_styles() { - _deprecated_function( __METHOD__, '3.1.0', 'DebugBarElasticPress\EP_Panel::enqueue_scripts_styles()' ); + _deprecated_function( __METHOD__, '3.1.0', 'DebugBarElasticPress\EP_Panel::enqueue_scripts() and DebugBarElasticPress\EP_Panel::enqueue_styles()' ); } /** diff --git a/classes/QueryLog.php b/classes/QueryLog.php index 9a52067..3cf8f07 100644 --- a/classes/QueryLog.php +++ b/classes/QueryLog.php @@ -478,7 +478,9 @@ public function admin_enqueue_scripts() { return; } - ( new CommonPanel() )->enqueue_scripts_styles(); + $common_panel = new CommonPanel(); + $common_panel->enqueue_scripts(); + $common_panel->enqueue_styles(); } /** diff --git a/classes/QueryMonitorOutput.php b/classes/QueryMonitorOutput.php index 53ba2fe..2bda84e 100644 --- a/classes/QueryMonitorOutput.php +++ b/classes/QueryMonitorOutput.php @@ -50,6 +50,7 @@ public function name(): string { */ public function output() { ?> + output_styles(); ?>
render_summary(); ?> common_panel->render(); ?> @@ -57,6 +58,19 @@ public function output() { ', + esc_url( EP_DEBUG_URL . 'assets/css/main.css?ver=' . EP_DEBUG_VERSION ) + ); + } + /** * Render the summary in Query Monitor format * diff --git a/debug-bar-elasticpress.php b/debug-bar-elasticpress.php index 555f44f..e51d1fc 100644 --- a/debug-bar-elasticpress.php +++ b/debug-bar-elasticpress.php @@ -67,7 +67,7 @@ function setup() { if ( class_exists( '\QM_Collectors' ) ) { \QM_Collectors::add( new QueryMonitorCollector() ); add_filter( 'qm/outputter/html', $n( 'register_qm_output' ) ); - add_action( 'qm/output/enqueued-assets', [ new CommonPanel(), 'enqueue_scripts_styles' ] ); + add_action( 'qm/output/enqueued-assets', [ new CommonPanel(), 'enqueue_scripts' ] ); } else { add_filter( 'debug_bar_panels', $n( 'add_debug_bar_panel' ) ); add_filter( 'debug_bar_statuses', $n( 'add_debug_bar_stati' ) ); From 89099a59c96f220b02d3951d96cc0d45a8c3e893 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 22 Apr 2026 12:04:47 +0500 Subject: [PATCH 2/3] Cleanup --- assets/css/main.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index cf3ab2f..7db1659 100755 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -15,10 +15,8 @@ border-top: 5px solid currentColor; cursor: pointer; display: inline-block; - height: 0; margin-left: 5px; vertical-align: middle; - width: 0; } .ep-queries-debug .hide-query-results .query-results, From 8dc15218eefc4c9f3136b23cbacf1dbe2b416e16 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Wed, 22 Apr 2026 12:32:17 +0500 Subject: [PATCH 3/3] Fix linting issues --- classes/CommonPanel.php | 4 ++-- classes/QueryMonitorOutput.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/CommonPanel.php b/classes/CommonPanel.php index 63be14f..8e3b7a8 100644 --- a/classes/CommonPanel.php +++ b/classes/CommonPanel.php @@ -36,7 +36,7 @@ public function get_title(): string { /** * Enqueue scripts for front end and admin */ - public function enqueue_scripts(): void { + public function enqueue_scripts() { if ( ! is_user_logged_in() ) { return; } @@ -49,7 +49,7 @@ public function enqueue_scripts(): void { * * @since 3.1.0 */ - public function enqueue_styles(): void { + public function enqueue_styles() { if ( ! is_user_logged_in() ) { return; } diff --git a/classes/QueryMonitorOutput.php b/classes/QueryMonitorOutput.php index 2bda84e..e9691ce 100644 --- a/classes/QueryMonitorOutput.php +++ b/classes/QueryMonitorOutput.php @@ -66,7 +66,7 @@ public function output() { */ protected function output_styles() { printf( - '', + '', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet esc_url( EP_DEBUG_URL . 'assets/css/main.css?ver=' . EP_DEBUG_VERSION ) ); }