diff --git a/debug-bar-panel.php b/debug-bar-panel.php index 54b7b79..7f6c629 100644 --- a/debug-bar-panel.php +++ b/debug-bar-panel.php @@ -11,7 +11,11 @@ class PluginUpdateCheckerPanel extends Debug_Bar_Panel { public function __construct($updateChecker) { $this->updateChecker = $updateChecker; - $title = sprintf('PUC (%s)', $this->updateChecker->slug); + $title = sprintf( + 'PUC (%s)', + esc_attr($this->updateChecker->slug), + $this->updateChecker->slug + ); parent::Debug_Bar_Panel($title); } diff --git a/js/debug-bar.js b/js/debug-bar.js index 7795a6a..1efd941 100644 --- a/js/debug-bar.js +++ b/js/debug-bar.js @@ -29,4 +29,24 @@ jQuery(function($) { runAjaxAction(this, 'puc_debug_request_info'); return false; }); + + + // Debug Bar uses the panel class name as part of its link and container IDs. This means we can + // end up with multiple identical IDs if more than one plugin uses the update checker library. + // Fix it by replacing the class name with the plugin slug. + var panels = $('#debug-menu-targets').find('.puc-debug-bar-panel'); + panels.each(function(index) { + var panel = $(this); + var slug = panel.data('slug'); + var target = panel.closest('.debug-menu-target'); + + //Change the panel wrapper ID. + target.attr('id', 'debug-menu-target-' + slug); + + //Change the menu link ID as well and point it at the new target ID. + $('#puc-debug-menu-link-' + panel.data('slug')) + .closest('.debug-menu-link') + .attr('id', 'debug-menu-link-' + slug) + .attr('href', '#' + target.attr('id')); + }); }); \ No newline at end of file