[wp-trac] [WordPress Trac] #22141: add_submenu_page file callback
WordPress Trac
wp-trac at lists.automattic.com
Tue Oct 9 17:02:04 UTC 2012
#22141: add_submenu_page file callback
-------------------------+------------------------------
Reporter: BenRacicot | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.4.2
Severity: normal | Resolution:
Keywords: 2nd-opinion |
-------------------------+------------------------------
Changes (by scribu):
* keywords: dev-feedback => 2nd-opinion
Comment:
Hey Ben,
First, some context:
The whole API related to add_submenu_page() needs a lot of work. The logic
is spread all over the place and is mixed with the menu generating code
#12718.
Also, add_submenu_page() already has 6 parameters. If we want to add
another parameter, we should think about converting them to an associative
array first.
Instead of adding yet another parameter that only works for this function
and create an inconsistency with add_menu_page(), we could add a helper
callback that just loads a file you specify.
Example usage:
{{{
add_submenu_page( 'tools.php', 'My Utility', 'My Utility',
'manage_options', 'my-utility', _delayed_load( 'my_template_file.php' ) );
}}}
And here's how the implementation of _delayed_load() would look like:
{{{
function _delayed_load( $file ) {
return function() use ($file) {
include( $file );
};
}
}}}
This only works in PHP 5.3, but it can be made to work for PHP 5.2 by
using a helper class.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22141#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list