WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#24531 closed enhancement (fixed)

Add subpage_file Filter Before Admin Menu

Reported by: Nessworthy Owned by: SergeyBiryukov
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch commit
Focuses: Cc:
PR Number:

Description

For users extending the back end of wordpress, sometimes custom pages added to the main menu will not be flagged as the current page because of unexpected aspects such as additional GET data.

The problem is, setting this directly using a filter like admin_menu does not work due to $subpage_file being set later on (needs confirming), nor does it make sense due to context.

At the top of menu-header.php, there is a filter called parent_file, used to allow plugins/themes to move the submenu tabs around, a suggestion would be to add a subpage_file filter, allowing plugins and the theme to modify the compared url to check the current page.

Would add a patch, but away from my development environment.

Attachments (3)

24531.diff (528 bytes) - added by swissspidy 4 years ago.
24531.2.diff (541 bytes) - added by kraftbj 4 years ago.
adds parent_file arg
24531.3.diff (605 bytes) - added by kraftbj 4 years ago.
inline docs. Sorry Drew :(

Download all attachments as: .zip

Change History (16)

#1 @chriscct7
4 years ago

  • Keywords needs-patch added
  • Severity changed from minor to normal

@swissspidy
4 years ago

#2 @swissspidy
4 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.4

24531.diff adds a submenu_file filter right after the parent_file filter. Not sure if $parent_file should be added as a second parameter, but this filter would be already very useful in my Admin Menu Manager plugin.

I think that could go into 4.4 with no problems.

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


4 years ago

#4 @SergeyBiryukov
4 years ago

Let's add $parent_file as a second argument.

@kraftbj
4 years ago

adds parent_file arg

@kraftbj
4 years ago

inline docs. Sorry Drew :(

#5 @SergeyBiryukov
4 years ago

  • Keywords commit added

#6 @chriscct7
4 years ago

  • Owner set to chriscct7
  • Status changed from new to accepted

#7 @chriscct7
4 years ago

Looks good. Nice work @swissspidy

#8 @Nessworthy
4 years ago

Happy to see it's all full steam ahead with this ticket!

#9 @wonderboymusic
4 years ago

  • Owner changed from chriscct7 to SergeyBiryukov
  • Status changed from accepted to assigned

#10 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34722:

Add 'submenu_file' filter for the file of an admin menu sub-menu item.

This complements the 'parent_file' filter added in [12712].

Props swissspidy, kraftbj.
Fixes #24531.

#11 @DrewAPicture
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The $submenu_file global needs to be declared to avoid a notice here.

#12 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 34724:

Declare the $submenu_file global to avoid a notice generated by passing it as a parameter to the submenu_file hook, introduced in [34722].

Fixes #24531.

#13 @DrewAPicture
4 years ago

In 34725:

Docs: Document declaration of the $submenu_file global in wp-admin/menu-header.php.

See #24531. See #32246.

Note: See TracTickets for help on using tickets.