2014-08-29 84 views
0

您好我想使用的功能,我得到这个错误功能显示错误

Parse error: syntax error, unexpected 'function' (T_FUNCTION) on line 3 

连接

<?php 

add_action('admin_menu', 'zkr_my_theme_menu_first'); // we need this action to create  the menu 
// this makes the menu 
function zkr_my_theme_menu_first() 
{ 
$page_title = "Theme Settings"; 
$menu_title = "Theme Settings"; 
$capability = "administrator"; 
$menu_slug = "zkr-theme-settings"; 
$function = "zkr_main_theme_menu"; 
$icon_url = get_template_directory_uri() . "/zkrframework/images/settings_icon.gif"; 

add_menu_page($page_title,$menu_title,$capability,$menu_slug, $function, $icon_url); 

} 
// this shows the menu html think of it as the view. 
function zkr_main_theme_menu() 
{ 
$current_user = wp_get_current_user(); 
$user_id = $current_user->ID; 
if (!user_can($user_id, 'create_users')) 
    return false; 
?> 

<div class="wrap"> 

<h2>Hello Menu</h2> 

</div> 

<?php 
} 

?> 

我想菜单添加到我的WordPress管理面板的代码我得到这个错误

我该如何解决这个错误?

+0

在这一刻我测试你的代码,结果是好的。请再试一次。 – 2014-08-29 20:10:05

回答

0

您可以在第3行调用函数addAction(),但是您尚未在您提供的代码示例中声明它。

在声明它之前调用函数是可以的,但是在调用一个未定义的函数时,解释器会在隐喻性的'wtf'中耸肩。

+1

add_action是一个内置的Wordpress函数。 – 2014-08-29 15:53:19