Opened 5 years ago
Last modified 21 months ago
#37445 new enhancement
Allow to adjust the `$in_admin` property of `WP_Screen`
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5 |
Component: | Administration | Keywords: | has-patch |
Focuses: | multisite | Cc: |
Description
The $in_admin
property of the WP_Screen
class is impossible to be changed by a developer at the moment, which makes sense in how WordPress uses it.
However, I'm currently building a plugin that creates an additional administration panel (like network and user admin) and I would need to adjust the $in_admin
property to reflect when this panel is active. Otherwise a function like is_blog_admin()
returns true although we actually aren't in the regular admin panel (since the value of $in_admin
defaults to 'site').
So I'm proposing to either make the property public so that a developer can override it (for example on the current_screen
action) or to add a new filter for the property specifically in WP_Screen::get()
. I would prefer the second approach since having the property being protected makes sense in general. The use-case I have is a very rare one, so I think a very specific filter for it should do.
37445.diff introduces such a filter. I'm not sure about whether the name of that filter is the best possible choice though, so feel free to come with something more accurate.