我可以在WP后端的仪表板菜单下添加一个新链接
function new_link_display() {
echo "Echo html code for the page";
}
function new_link_page() {
if (function_exists('add_submenu_page') )
add_submenu_page('index.php', __('New Like Label'), __('New Link Label'), 'manage_options', 'new-link-display', 'new_link_display');
}
add_action('admin_menu', 'new_link_page');
}
add_action('admin_menu', 'new_link_page');
如何在“设置”按钮下添加新按钮。我不想在设置菜单中使用它,而是在它下面有一个单独的按钮。
答案 0 :(得分:1)
您应该使用add_menu_page
代替add_submenu_page
这是您的代码,可能有用。
function new_link_display() {
echo "Echo html code for the page";
}
function new_link_page() {
if (function_exists('add_submenu_page') )
add_menu_page( __('New Like Label'), __('New Link Label'), 'manage_options', 'new-link-display', 'new_link_display', $icon_url, $position);
// $position = If position is not set, menu will at the end automatically.
}
add_action('admin_menu', 'new_link_page');
}
add_action('admin_menu', 'new_link_page');
答案 1 :(得分:0)
您应该先仔细阅读这两页:
http://codex.wordpress.org/Function_Reference/add_menu_page
http://codex.wordpress.org/Function_Reference/add_submenu_page
答案 2 :(得分:0)
<?php
/**
* Plugin Name: Plugin Name
* Plugin URI: --
* Description: Plugin INfo
* Version: 1.0.0
* Author: Plugin Author
*/
$object = new Classname();
add_action('admin_menu', array($object, 'addMenu'));
class Classname{
public function addMenu(){
add_options_page('Main Menu', 'Main Menu', 'manage_options', 'page_name', array($this, 'optionPage'));
}
public function optionPage(){
//code required
}
}
?>