【问题标题】:unable to add menu in wordpress无法在wordpress中添加菜单
【发布时间】:2016-02-02 06:48:40
【问题描述】:
    $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:\wamp\www\wp\wp-includes\plugin.php 中第 525 行的有效类名或对象

【问题讨论】:

  • 你想做什么?指定它..!!你想在标题中添加菜单吗?
  • 是.......................
  • 您想在管理面板中添加菜单和子菜单吗?或在前台。在标题中。 php。请简要说明您的问题。以及你所尝试的。

标签: php wordpress


【解决方案1】:

在 word-press 管理面板中添加菜单和子菜单 -> 试试这个

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');

它将在管理面板中添加菜单和子菜单。

您也可以参考此链接在管理面板中添加菜单和子菜单。

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

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

【讨论】:

    猜你喜欢
    • 2011-12-26
    • 2015-10-13
    • 2021-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    相关资源
    最近更新 更多