fooplugins/debug-bar-screen-info

Compare to get_current_screen

grappler opened this issue · 8 comments

I did a check with get_current_screen() and I was getting differnt results then the plugin. I noticed it on the theme page with the parent_base.

This is with version 1.1.1

@grappler that is strange - I am pretty sure that code has not changed.

But I did a test on the themes page and got the same value for parent_base:

image

@grappler /cc @bradvin The plugin uses get_current_screen() internally to retrieve the information, so a difference shouldn't even be possible. Very strange.

Have you got some screen shots showing the diffs ?

Yes,
image

@grappler Thank you.

I believe I've figured out what the problem is, unfortunately not all too much we can do about it.

The method within WP_Screen() which sets the parent values set_parentage() is called from within admin_header.php after the menu parent for the screen has been determined.
Unfortunately on the admin side the Admin Bar loads before the page is loaded which includes admin_header.php.... (on the Front end the admin bar loads at the end).

A (dirty) work-around would be to copy the set_parentage() method and retrieve the values locally for use by the plugin. Nicer would be to call the WP_Screen::set_parentage() method. I'd need to check if that would not have any adverse effects.

@bradvin I've send in PR #6 which will fix this in most cases.
@grappler Thank you for reporting!

@jrfnl Thank you for fixing it. 😄

@grappler You're welcome ;-)

thanks @jrfnl @grappler
I will release an update to wp.org later today