Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Shane McC
Shane McC
3,005 Points

Trying to make my own WP Plugin. What's wrong with my syntax?

Hi Everyone, I'm getting the below error message when I test my own WP Plugin. The error message and my syntax is below. What am I doing wrong?

Parse error: syntax error, unexpected '{' in C:\wamp\www\wp-practice\wordpress\wp-content\plugins\wp-treehousebadges\wptreehouse-badges.php on line 25

function wptreehouse_badges_menu(){

/* 
  Use the add_options_page function
  add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);
*/

add_options_page{
    'Official Teehouse Badges Plugin',
 'Treehouse Badges',
 'manage_options',
 'wptreehouse-badges',
 'wptreehouse_badges_options_page'
};

}
add_action('admin_menu','wptreehouse_badges_menu');

function wptreehouse_badges_options_page(){

if(!current_user_can('manage_options')){
wp_die('You do not have sufficient permissions to access this page.');
 }

 echo '<p>Welcome to our plugin page!</p>';

}

1 Answer

Mjolnir Silver
PLUS
Mjolnir Silver
Courses Plus Student 14,408 Points

Hint: I think you've added a curly brace instead of a bracket after "add_options_page".

Perhaps try out the below:

function wptreehouse_badges_menu() {

/*
 *  Use the add_options_page function
 *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function ) 
 *
*/

add_options_page(
    'Official Treehouse Badges',
    'Treehouse Badges',
    'manage_options',
    'wptreehouse-badges',
    'wptreehouse_badges_options_page'
);

}

Shane McC
Shane McC
3,005 Points

Thanks, working great