WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 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:

Description

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 7 years ago.
menu-test.php (2.4 KB) - added by DD32 7 years ago.

Download all attachments as: .zip

Change History (7)

@DD327 years ago

@DD327 years ago

comment:1 @DD327 years ago

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

comment:2 @DD327 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

     
    4545 
    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); 
    4950 
    5051        if ( $page_hook ) { 
    5152                do_action('load-' . $page_hook); 

comment:3 @DD327 years ago

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

comment:4 @ryan7 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

comment:5 @thee177 years ago

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