2014-08-29 77 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