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 trialTy Yamaguchi
25,397 PointsPlugin could not be activated because it triggered a fatal error.
When I try to activate the plugin wordpress gives me this error message:
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /wp-content/plugins/wptreehouse-badges/wptreehouse-badges.php on line 40
Here is my code:
<?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: Zac Gordon
* Author URI: http://wp.zacgordon.com
* License: GPL2
*
*/
/*
* Add a link to our plugin in the admin menu
* under 'Settings > Treehouse Badges'
*
*/
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 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>';
}
?>
Any suggestions on why this is not working?
2 Answers
Gareth Borcherds
9,372 PointsYou are missing a semi colon after add_action( 'admin_menu', 'wptreehouse_badges_menu').
Anytime you see unexpected php error, it means that you probably forgot to end another piece of code right before the line number they gave you.
Zander Curtis
10,634 PointsThanks Gareth for all you do to make the Treehouse Community the best in the market. Go TeamTreehouse! Let's go change the world.
Ty Yamaguchi
25,397 PointsTy Yamaguchi
25,397 PointsThanks Gareth! I'll remember to look for missing semi colons the next time I get an unexpected error.
Gareth Borcherds
9,372 PointsGareth Borcherds
9,372 PointsDid that resolve your issue then? Be sure to mark best answer if it's solved.