#1599 closed defect (bug) (fixed)
Plugin: Adding Top-level menu inside folder errors
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5.2 |
Component: | Administration | Keywords: | plugin menu top-level error |
Focuses: | Cc: |
Description
Hello,
I was experimenting around with adding administration menus via plugins and found this strange error. I took the sample 'Menu Test' plugin on this page:
http://codex.wordpress.org/Adding_Administration_Menus
and placed it in two locations:
- in wp-content/plugins/
- in wp-content/plugins/menutest/
In #1, clicking 'Test Toplevel' works perfectly.
In #2, clicking 'Test Toplevel' gives the following error:
Fatal error: Cannot redeclare mt_add_pages() (previously declared in C:\Development\wordpress\wp-content\plugins\menutest\menutest.php:13) in C:\Development\wordpress\wp-content\plugins\menutest\menutest.php on line 11
I traced the problem to line 44 of /wp-admin/admin.php:
$plugin_page = plugin_basename($_GETpage?);
$page_hook = get_plugin_page_hook($plugin_page, $pagenow);
If the page variable is something like: menutest/menutest.php, magic quotes will automatically be applied on it making it:
menutestmenutest.php
When get_plugin_page_hook() is called, it returns since there is no match for the double slash () in the array, $admin_page_hooks.
A solution would be to add:
$plugin_page = stripslashes($plugin_page); Fix for having slashes in 'page' var
after line 44: $plugin_page = plugin_basename($_GETpage?);
Hope that helps!
(In [3025]) Missing semi, also fixes #1599