我整个上午一直在看看WP Codex以及网络上的论坛帖子和Stackoverflow上的帖子到目前为止没有运气。 我正在尝试使用子菜单制作顶级菜单,我已经能够使其达到顶级菜单而不是子菜单,现在我陷入了不足的权限或一堆php错误。
链接到php错误的屏幕截图:http://prntscr.com/8f2pvw
Functions.php代码
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/* ADDING FUNCIONALITY
============================== */
// Enqueues Javascript / CSS Files
add_action( 'wp_enqueue_scripts', 'my_enqueued_assets' );
function my_enqueued_assets() {
wp_enqueue_script( 'dragoncove-js', plugin_dir_url( __FILE__ ) . '/js/dragoncove.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'dragoncove-css', plugin_dir_url( __FILE__ ) . '/css/dragoncove.css', array( 'stylesheet' ), '1.0', true );
}
/* ADDING THE ADMIN MENU
======================================== */
// NEW MENU TEST
add_action( 'admin_menu', 'dragoncove_adminmenu' );
function dragoncove_adminmenu() {
add_menu_page( 'dragoncove_adminmenu', 'Dragon Cove', 'manage_options', 'dragoncove/dragoncove.php', '', plugins_url( 'dragoncove/images/icon.png' ), 100 );
add_submenu_page( 'dragoncove_adminmenu', 'Font Awesome Page', 'Font Awesome Page', 'manage_options', 'fontawesomemenu_page', 'fontawesomemenu_page_callback' );
}
// Admin Page
function dragoncove_adminmenu_page(){
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<h2>Dragon Cove Admin Page</h2>';
echo '<form>
<div class="row">
<div class="large-12">
<input type="text" name="news" value="news_update" placeholder="news update" />
</div>
</div>
</form>';
echo '</div>';
}
// Font Awesome Page
function dragoncove_fontawesomemenu_page(){
echo '<div class="wrap">';
echo '<h2>Dragon Cove Sub Page</h2>';
echo '<form>
<div class="row">
<div class="large-12">
<p>Something will probably go here one day</p>
</div>
</div>
</form>';
echo '</div>';
}
// Font Awesome Page Callback
function fontawesomemenu_page_callback() {
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
echo '<h2>My Custom Submenu Page</h2>';
echo '</div>';
}
?>
答案 0 :(得分:0)
现在修复了参数问题。以下是其他人想要的代码。 编辑:稍微清理一下。
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/* ADDING FUNCIONALITY
====================================== */
// Enqueues Javascript / CSS Files
add_action( 'wp_enqueue_scripts', 'my_enqueued_assets' );
function my_enqueued_assets() {
wp_enqueue_script( 'dragoncove-js', plugin_dir_url( __FILE__ ) . '/js/dragoncove.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'dragoncove-css', plugin_dir_url( __FILE__ ) . '/css/dragoncove.css', array( 'stylesheet' ), '1.0', true );
}
/* ADDING THE ADMIN MENU
============================ */
// NEW MENU TEST
add_action( 'admin_menu', 'dragoncove_menu' );
function dragoncove_menu() {
add_menu_page( 'dragoncove_adminmenu', 'Dragon Cove', 'manage_options', 'dragoncove_adminmenu_page', 'dragoncove_page', plugins_url( 'dragoncove/images/icon.png' ), 100 );
add_submenu_page( 'dragoncove_adminmenu_page', 'Font Awesome Page', 'Font Awesome Page', 'manage_options', 'fontawesomemenu_page', 'fontawesomemenu_page' );
}
/* Admin Page */
function dragoncove_page() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<h2>Dragon Cove Plugin</h2>';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '<form>
<div class="row">
<div class="large-12">
<input type="text" name="news" value="news_update" placeholder="news update" />
</div>
</div>
</form>';
echo '</div>';
}
// Font Awesome Page
function fontawesomemenu_page() {
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
echo '<h2>My Custom Submenu Page</h2>';
echo '</div>';
}