WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 18 months ago

#37445 new enhancement

Allow to adjust the `$in_admin` property of `WP_Screen`

Reported by: flixos90 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.

Attachments (1)

37445.diff (706 bytes) - added by flixos90 4 years ago.

Download all attachments as: .zip

Change History (3)

@flixos90
4 years ago

#1 @flixos90
4 years ago

  • Keywords has-patch added; needs-patch removed

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.

#2 @flixos90
4 years ago

For reference: Implementing the proposal from #37526 would make this ticket invalid/unnecessary.

Note: See TracTickets for help on using tickets.