尝试将菜单页面添加到WordPress管理站点

时间:2015-05-17 15:11:19

标签: javascript php css wordpress plugins

我正在尝试将菜单页面添加到我的管理网站,以及向Word Press网站添加页脚。然而,没有任何表现。没有错误消息。我从YouTube复制了这段代码,显然这段代码适合那些正在做教程的人,但不适合我。

我安装了它,没有任何显示。请帮忙!

这是我的代码:

 <?php
    /**
    * Plugin Name: SBESS
    * Plugin URI: sbess.ca
    * Description: This plugin is to modify the email address of the current website.
    * Version: 1.0.0
    * Author: Rihao Kang
    * Author URI: sbess.ca
    * License: GPL2
    */

    ?>


    <?php
    // put the footer message into database
    function sbess_install(){
        add_option ('sbess_powerby', 'What..sup');

    }


    function sbess_deactive(){
        delete_option ('sbess_powerby');

    }

    function sbess_footer(){
        echo'<center>'.get_option('sbess_powerby').'</center>';

    }

    function sbess_menu(){

    //title of the webpage the when the title is clicked
    //actually text when it is used for the link
    //detect the perticular the user can access the menu
    //unique name provided for this particular menu, identify the menu
        add_menu_page('sbess','sbess','manage_option','sbessmenu','sbess_main_page');
    }

    function sbess_main_page(){

        echo'<h2>SBESS</h2>Welcome to SBESS ';
    }


// activation of the o
    register_activation_hook (_File, 'sbess_install');
    register_deactivation_hook (_File, 'sbess_deactive');
    add_action ('wp_footer','sbess_footer');
    add_action('admin_menu','sbess_menu');

    ?>

1 个答案:

答案 0 :(得分:0)

您采取的方法是正确的,您遇到的问题归结为一个简单的错字。

add_menu_page()的一个参数是功能,值正确值为manage_options,而在代码中,您将其设为manage_option

add_menu_page( 'sbess', 'sbess', 'manage_options', 'sbessmenu', 'sbess_main_page' );

进一步阅读:https://codex.wordpress.org/Function_Reference/add_menu_page

同样,对于激活和取消激活挂钩,第一个参数需要从_File更改为__FILE__