Make WordPress Core

Opened 8 years ago

Last modified 2 years ago

#37445 new enhancement

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

Reported by: flixos90's profile flixos90 Owned by:
Milestone: Awaiting Review 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 8 years ago.

Download all attachments as: .zip

Change History (8)

@flixos90
8 years ago

#1 @flixos90
8 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
8 years ago

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

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


4 years ago

#4 @peterwilsoncc
4 years ago

@flixos90 this came up in a triage session today, is it something you're still interested in pursuing?

#5 follow-up: @flixos90
4 years ago

@peterwilsoncc Thanks for the ping. I'm no longer working on an implementation of a separate administration panel at this point, but if anybody else is, I still think this filter would be handy.

It's certainly a lower-hanging fruit, but IMO it is worth adding because it facilitates the use-case of building out separate administration panels. While the impact outside of it is practically non-existent, it is technically trivial so I'm in favor of doing it.

@johnjamesjacoby @jeremyfelt Still interested in "global admin"? :)

#6 in reply to: ↑ 5 @johnjamesjacoby
4 years ago

Replying to flixos90:

@johnjamesjacoby @jeremyfelt Still interested in "global admin"? :)

Yeah you know me 🎶

#7 @desrosj
2 years ago

  • Milestone set to Awaiting Review

Re-adding a milestone to this one. Was lost along the way somewhere.

Note: See TracTickets for help on using tickets.