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.

2 Answers 2


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?


The __FILE__ will return full path with filename of the file. It's magic method of PHP.

  • 1
    Please add an explanation to your answer: why could that solve the problem?
    – fuxia
    Aug 5, 2013 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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