WPThemeReview icon indicating copy to clipboard operation
WPThemeReview copied to clipboard

[New Sniff] Check for removal of admin pages

Open jrfnl opened this issue 8 years ago • 8 comments

Rule:

Removal of WP admin pages is not allowed.

The exception would be a child theme removing a theme admin submenu page added by the parent theme.

Ref: https://github.com/WPTRT/WordPress-Coding-Standards/issues/12#issuecomment-231783316

Theme check file covering this rule:

n/a

Decision needed:

This is currently not in the handbook as a rule. Should it be one ?

Notes for implementation:
  • Check for remove_menu_page() and forbid this.
  • Check for remove_submenu_page() and only forbid this if one of a known list of WP Core admin pages is being removed

To do:

  • [ ] If agreed this should be an error - Add the rule in the Theme Review handbook to the Requirements page.
  • [ ] If agreed this should be an error - Create unit tests
  • [ ] If agreed this should be an error - Create new sniff

jrfnl avatar Jul 12 '16 03:07 jrfnl

Discussed in the meeting of May 31st, let's add this.

jrfnl avatar May 31 '18 12:05 jrfnl

To create this sniff, I need some more information about the WP Core admin pages which are not supposed to be removed.

The question is basically: which submenu items are allowed to be removed ? Answers I can think of:

  • Only admin pages within the Themes submenu and of those, not the known core ones (themes, customizer and its variants, widgets, menus, theme-editor).
  • Admin pages within the Themes submenu + the Options submenu, again with the exception of the known core ones
  • Any admin page, as long as its not a known core one

jrfnl avatar Jun 05 '18 00:06 jrfnl

Essentially, the only admin pages allowed to be removed would be custom Appearance submenu items created by a parent theme and removed by a child theme. I can't think of any others we allow to be removed. I'm not even sure that there's a child theme that does this in the directory. The situation would be rare.

justintadlock avatar Jun 05 '18 12:06 justintadlock

I would go with

Only admin pages within the Themes submenu and of those, not the known core ones (themes, customizer and its variants, widgets, menus, theme-editor).

I agree with Justin.

grappler avatar Jun 06 '18 17:06 grappler

Thanks for the feedback. I have the sniff nearly ready already, but won't be able to get back to it until the weekend.

jrfnl avatar Jun 07 '18 00:06 jrfnl

@jrfnl is this a different sniff from the forbidden functions one?

dingo-d avatar May 18 '19 13:05 dingo-d

Yes it is and a lot more complicated one. Themes can remove admin pages from, for instance, a parent theme, but they are not allowed to remove WP Core admin pages, so there is a lot more involved in that.

I worked on it last year and it's quite tricky. I'd need to have a good look again to see where I got stuck.

jrfnl avatar May 20 '19 07:05 jrfnl

I've removed the input/decision needed, as we know what is and isn't allowed.

dingo-d avatar May 13 '20 17:05 dingo-d