Opened 12 years ago
Closed 9 years ago
#22141 closed enhancement (wontfix)
add_submenu_page file callback
Reported by: | BenRacicot | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4.2 |
Component: | Plugins | Keywords: | needs-patch |
Focuses: | administration | Cc: |
Description
Under the recommendation of the community I have decided to file a track regarding add_submenu_page. It currently allows for a callback function in which a dev could include a file but how about allowing add_submenu_page an argument to include a file in replacement of a callback function? This would remove several lines of code and clean up many developers functions.php files as well as custom admin page files.
Thanks for listening and I hope I can help.
-Ben
Change History (8)
#2
follow-up:
↓ 3
@
12 years ago
I actually don't really like the idea of using a file here. Unfortunately, it makes it very easy for bad developers to expose a form to the point where direct file POSTs could essentially result in CSRF.
Note: See
TracTickets for help on using
tickets.
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:
And here's how the implementation of _delayed_load() would look like:
This only works in PHP 5.3, but it can be made to work for PHP 5.2 by using a helper class.