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've used almost all of the Wordpress example code but it still doesn't work. I've put the php file under wp-content/plugins/menuitem/ .The code is simple

<?php add_action('admin_menu', 'donations_overview_menu');
function donations_overview_menu() {
    add_options_page('Donations overview', 'Donations overview', 'manage_options', 'donations-overview', 'donations_overview');}

function donations_overview() {
    if (!current_user_can('manage_options'))  {
        wp_die( __('You do not have sufficient permissions to access this page.') );
    }
    echo '<div class="wrap">';
    echo '<p>Here is where the form would go if I actually had options.</p>';
    echo '</div>';
}
?>
share|improve this question

2 Answers 2

up vote 1 down vote accepted

The code itself is fine. But you would need to activate the plug-in: you can't simply place the file in the plug-ins directory. You will need to give the plug-in a 'header' too. See the Codex.

Alternatively, place the code in your theme's functions.php, but really it should be in a plug-in.

share|improve this answer
    
I thought that I was missing something, rather than writing wrong code, thank you. –  Andrija Jan 19 '12 at 19:46

add_options_page adds a page to the Settings tab of the dashboard, not its own tab. I just copied your code and pasted into a plugin and verified that it is adding Donations overview to the Settings tab.

Also as Stephen Harris said, your plugin needs to have the valid plugin headers and be activated in order for any code inside of it to run.

share|improve this answer
    
I know, I wanted to add it to the Settings; thanks for checking it out. –  Andrija Jan 19 '12 at 19:47

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.