我正在尝试向我的管理站点添加一个菜单页面,以及向 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');
?>
最佳答案
您采取的方法是正确的,您遇到的问题归结为一个简单的错字。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
同样对于激活和停用 Hook ,第一个参数需要从
_File
更改。至__FILE__
.
关于javascript - 尝试将菜单页面添加到 WordPress 管理站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30288354/