0

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>';
}
?>

2 Answers 2

2

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.

1
  • I thought that I was missing something, rather than writing wrong code, thank you.
    – Andrija
    Jan 19, 2012 at 19:46
0

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.

1
  • I know, I wanted to add it to the Settings; thanks for checking it out.
    – Andrija
    Jan 19, 2012 at 19:47

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.