2
<?php
/*
 *  Plugin Name: Official Treehouse Badges Plugin
 *  Plugin URI: http://wptreehouse.com/wptreehouse-badges-plugin/
 *  Description: Provides both widgets and shortcodes to help you display your Treehouse profile badges on your website.  The official Treehouse badges plugin.
 *  Version: 1.0
 *  Author: Editorial Staff
 *  Author URI: http://wp.zacgordon.com
 *  License: GPL2
 *
*/


/*---------------------------------------*/
/* 1. ASSIGN GLOBAL VARIABLE */
/*---------------------------------------*/


/*---------------------------------------*/
/* 2. PLUGIN ADMIN MENU */
/*---------------------------------------*/

function basic_treehouse_badges_menu() {
  /*
     *  Use the add_options_page function
     *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function )
     *
    */
  add_options_page(
    'Official Tree House Badges Plugin',
    'Treehouse Badges',
    'manage options',
    'wp-treehouse-badges',
    'wptreehouse_badges_option_page'
  );
}
add_action('admin_menu','basic_treehouse_badges_menu');

function wptreehouse_badges_option_page() {
  if( !current_user_can ('manage_options')) {
    wp_die('You do not have sufficient permission to acces this page.');
  }
  echo '<p> welcome to our plugin page </p>';
}    


?>

I am just a beginner and have written a very simple basic plugin structure.

What's the mistake that's causing the "Treehouse Badges" menu name not to appear under the Settings menu in the admin section of WordPress.

2

The only issue was that the capability was specified incorrectly when using add_options_page(). The capability should be manage_options. Note the underscore, no space:

function basic_treehouse_badges_menu() {
  /*
     *  Use the add_options_page function
     *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function )
     *
    */
  add_options_page(
    'Official Tree House Badges Plugin',
    'Treehouse Badges',
    'manage_options',
    'wp-treehouse-badges',
    'wptreehouse_badges_option_page'
  );
}
add_action('admin_menu','basic_treehouse_badges_menu');

function wptreehouse_badges_option_page() {
  if( !current_user_can ('manage_options')) {
    wp_die('You do not have sufficient permission to acces this page.');
  }
  echo '<p> welcome to our plugin page </p>';
}    
  • Thanks. The manage_options is a keyword or manageoptions, which is w/o the sapce, is also acceptable. – The WP Novice Dec 13 '16 at 7:47
  • 1
    You got it, Champion. The capability name is manage_options. Check this page out for more information. – Dave Romsey Dec 13 '16 at 7:52
3

There is mistake in your code you use 'manage options' instead of 'manage_options'

so correct code is

add_options_page(
    'Official Tree House Badges Plugin',
    'Treehouse Badges',
    'manage_options',
    'wp-treehouse-badges',
    'wptreehouse_badges_option_page'
  );

Here you can read more about administration menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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