Plugin Directory

Opened 6 weeks ago

#2681 new defect

Custom debug panels break with namespaces

Reported by: neutrinoinc Owned by:
Priority: high Severity: normal
Plugin: not-listed Keywords: debug-bar namespace


Hi, when creating a custom Debug Bar Panel from a namespace that extends the Debug_Bar_Panel class, the resulting HTML that generates the panel markup is invalid. In my example I created a panel from a class in a namespace, called FuelIDX\DebugBarPanel. In doing so the markup generated looks like this - notice the uncompliant \ in the id:

<a id="debug-menu-link-FuelIDX\DebugBarPanel" ...>

Because of this clicking on the link to open the panel does not work, since it does not work correctly with a \ in the id name in any of the IDs.

This is caused by the use of get_class() in debug-bar\debug-bar.php which returns the namespace \ in its returned value, and that is used to generate the ids.

The most straightforward solution would be to replace those \ characters with something more benign like a _. I've included a patch where we do just that on all get_class() calls which solves the problem. This transforms the output to something like this, which works just fine:

<a id="debug-menu-link-FuelIDX_DebugBarPanel" ...>

I do hope that this can be implemented because namespaces are wonderful =). Thanks!

  • Mike Karikas

Attachments (1)

debug-bar-namespace-patch.patch (358 bytes) - added by neutrinoinc 6 weeks ago.
Patch to implement namespace fix for get_class() bug

Download all attachments as: .zip

Change History (1)

@neutrinoinc6 weeks ago

Patch to implement namespace fix for get_class() bug

Note: See TracTickets for help on using tickets.