Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using Sidebar Generator in all my themes.

The plugin works perfectly normal from "plugins" directory, but I want to embed it somehow to my themes, so it won't display on Installed Plugins list.

I've just copied sidebar_generator.php (the whole code is luckily in one file) to mytheme/plugins and included it in functions.php

require_once (MY_PLUGINS . '/sidebar_generator.php');  

Now, it worked for all other plugins, but not for this one! This way when I click on "Sidebars" it refreshes the actual page instead of loading plugin's admin_page.

Any ideas why is it happening and how to make it working?

I believe the problem lays here:

add_submenu_page('themes.php', 'Sidebars', 'Sidebars', 'manage_options', __FILE__, array('sidebar_generator','admin_page'));

Chaning FILE to something else helps, but I'm not sure how to point this submenu link at the actual plugins admin page.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

It should work (and does when I test on a new WP install) with __FILE__, though it's not recommended because it exposes the server path and is just generally an ugly URL. You can replace it with a unique identifier like 'sb-generator-options' or whatever really, as long as it's unique. the important part is the last param that tells it what function to use to render the page.

Are you maybe moving add_submenu_page out of the plugin file, or are you just editing it in place?

share|improve this answer

Example :

var_dump(dirname(__FILE__);

var_dump(__DIR__);

__LINE__ The current line number of the file.

__FILE__ The full path and filename of the file.

__DIR__ The directory of the file.

share|improve this answer
    
Please add an explanation to your answer: why could that solve the problem? –  toscho Aug 5 '13 at 8:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.