Make WordPress Core

Opened 21 years ago

Closed 21 years ago

Last modified 9 years ago

#1599 closed defect (bug) (fixed)

Plugin: Adding Top-level menu inside folder errors

Reported by: mikexstudios Owned by:
Priority: normal Milestone:
Component: Administration Version: 1.5.2
Severity: normal Keywords: plugin menu top-level error
Cc: Focuses:

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:

  1. in wp-content/plugins/
  2. 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!

Change History (4)

#1 @ryan
21 years ago

  • Milestone 1.5.21.6

#2 @matt
21 years ago

  • Resolutionfixed
  • Status newclosed

(In [3025]) Missing semi, also fixes #1599

#3 @(none)
20 years ago

  • Milestone 2.0

Milestone 2.0 deleted

This ticket was mentioned in Slack in #cli by jrf. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.