向Wordpress仪表板添加新按钮

时间:2014-05-26 09:21:57

标签: wordpress

我可以在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');

如何在“设置”按钮下添加新按钮。我不想在设置菜单中使用它,而是在它下面有一个单独的按钮。

3 个答案:

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

Reference

答案 1 :(得分:0)

答案 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
    }

}
?>