Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#7214 closed defect (bug) (fixed)

Allow top-level menu page to use a slug, rather than filename

Reported by: DD32 Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.6
Component: Administration Keywords: has-patch needs-testing
Focuses: Cc:


This patch brings the add_menu_page() into align with the rest of the page addition functions, in that it allows the $file to be any string rather than specifically a filename.

It does look a bit hackish in a sense, But i couldnt see any other way to do it.

It certainly needs testing to check it doesnt adversly affect anything else, but it appears fine to me.

I'll also attach a version of the menu-tester plugin which works after this patch (and doesnt work before it)

Attachments (2)

top-level-menu.diff (1.5 KB) - added by DD32 10 years ago.
menu-test.php (2.4 KB) - added by DD32 10 years ago.

Download all attachments as: .zip

Change History (7)

10 years ago

10 years ago

#1 @DD32
10 years ago

The change to admin.php could probably be put inside get_plugin_page_hookname somewhere too if need be..

#2 @DD32
10 years ago

Any chance of this getting in?

By the looks of it, Only the changes to wp-admin/admin.php need to be applied to the current trunk, That is:

  • wp-admin/admin.php

    4646// Handle plugin admin pages.
    4747if (isset($plugin_page)) {
    48         $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
     48        if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) )
     49                $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
    5051        if ( $page_hook ) {
    5152                do_action('load-' . $page_hook);

#3 @DD32
10 years ago

(Thats lines 60-61 under current trunk, not 48-49)

#4 @ryan
10 years ago

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

(In [9147]) Allow top-level menu page to use a slug, rather than filename. Props DD32. fixes #7214

#5 @thee17
10 years ago

  • Milestone changed from 2.9 to 2.7
Note: See TracTickets for help on using tickets.