Make WordPress Core

Opened 20 years ago

Closed 19 years ago

Last modified 7 years ago

#1599 closed defect (bug) (fixed)

Plugin: Adding Top-level menu inside folder errors

Reported by: mikexstudios's profile mikexstudios 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:

  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
19 years ago

  • Milestone changed from 1.5.2 to 1.6

#2 @matt
19 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

#3 @(none)
18 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

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


7 years ago

Note: See TracTickets for help on using tickets.