Admin menu sometimes has wrong menu_slug
-
Hi,
I think I’ve spotted a problem with links in the admin menu for si-contact-form.php. This only happens for installations that use symlinks, I think.
In si-contact-form.php, the line that adds the settings menu is here:
add_submenu_page(‘plugins.php’, __(‘FS Contact Form Options’, ‘si-contact-form’), __(‘FS Contact Form Options’, ‘si-contact-form’), ‘manage_options’, __FILE__,array(&$this,’si_contact_options_page’));
… This sets the menu_slug for the admin page, to whatever __FILE__ resolves to. In most systems, I think this just works out to be si-contact-form/si-contact-form.php and it is fine. However, with symlinks, it ends up resolving the symlink and giving the complete server path.
Elsewhere in si-contact-form, the menu_slug is hardwired to be si-contact-form/si-contact-form.php — so if for any reason __FILE__ doesn’t resolve to that, then the hardwired links won’t work. Instead, they’ll return the error: “You do not have sufficient permissions to access this page.” — which happens because WordPress doesn’t recognise the menu_slug in the URL (eg. it’s looking instead for whatever __FILE__ resolved to).
I think it would be better to hardwire the menu_slug too, so that this line should be written as:
add_submenu_page(‘plugins.php’, __(‘FS Contact Form Options’, ‘si-contact-form’), __(‘FS Contact Form Options’, ‘si-contact-form’), ‘manage_options’, “si-contact-form/si-contact-form.php”,array(&$this,’si_contact_options_page’));
I hope this makes sense!
Thanks
Tom
- The topic ‘Admin menu sometimes has wrong menu_slug’ is closed to new replies.