2016-02-02 56 views
1
$page_title = "PushBIZ.IN"; 
    $menu_title = "PushBIZ.IN"; 
    $capability = 'activate_plugins'; 
    $menu_slug = "pushbiz"; 
    $function = "PushBIZIN_first"; 

    add_menu_page(__('Getting Started'), $menu_title, $capability, $menu_slug, array($this, $function), plugins_url(WPPUSH_APPNAME.'/assets/images/app20x20.png')); 
    add_submenu_page($menu_slug, __('BIZ Message'), __('BIZ Message'), $capability, 'BIZMessage', array($this, 'BIZ_Message')); 
    add_submenu_page($menu_slug, __('Business Analyst'), __('Business Analyst'), $capability, 'businessanalyst', array($this, 'business_analyst')); 
    add_submenu_page($menu_slug, __('BIZ Interests'), __('BIZ Interests'), $capability, 'BIZinterests', array($this, 'BIZ_interests')); 

警告添加菜單:call_user_func_array()預計參數1是一個有效的回調,第一陣列構件是不是有效的類名或對象在C:\瓦帕\ WWW \ WP \ WP-包括\上線525 plugin.php無法在WordPress

+0

什麼是你想怎麼辦?指定它.. !!你想在頭文件中添加菜單? –

+0

是........................ –

+0

你想在管理面板中添加菜單和子菜單嗎?或在前臺。在標題中。 PHP。請簡要解釋您的問題。和你有什麼嘗試。 –

回答

0

添加菜單和文字按管理面板子菜單 - >試試這個

function jmenu_plugin_top_menu(){ 
    add_menu_page('My Plugin', 'My Plugin', 'manage_options', __FILE__, 'jmenu_render_plugin_page', plugins_url('/img/icon.png',__DIR__)); 
    add_submenu_page(__FILE__, 'Custom', 'Custom', 'manage_options', __FILE__.'/custom', 'jmenu_render_custom_page'); 
    add_submenu_page(__FILE__, 'About', 'About', 'manage_options', __FILE__.'/about', 'jmenu_render_about_page'); 
} 
function jmenu_render_plugin_page(){ 
    ?> 
    <div class='wrap'> 
    <h2>plugin page</h2> 
    </div> 
    <?php 
} 
function jmenu_render_custom_page(){ 
    ?> 
    <div class='wrap'> 
    <h2>my sub page</h2> 
    </div> 
    <?php 
} 
function jmenu_render_about_page(){ 
    ?> 
    <div class='wrap'> 
    <h2>About my plugin page</h2> 
    </div> 
    <?php 
} 

add_action('admin_menu','jmenu_plugin_top_menu'); 

它會添加菜單和子菜單中的管理面板。

enter image description here

您也可以參考這個鏈接在管理面板添加菜單和子菜單。

http://clivern.com/adding-menus-and-submenus-for-wordpress-plugins/

https://developer.wordpress.org/reference/functions/add_submenu_page/