I have created a plugin called "add menu to dash board". For that I have created folder addmenu in wordpress's plugin folder.
In that folder my main php file of the plugin and the other
entry.php`文件存在。
通过插件,我创建了一个菜单&子菜单,信息&进入,链接和。
现在我想在单击子菜单(条目)时重定向到entry.php
文件,因为我有一个简单的html表单,我想从中将数据插入数据库。
那么有人可以帮助我吗?
我已读出require_once(),require_once()& include_once(),include()。但我不明白。
function register_my_custom_menu_page()
{
//add_menu_page('custom menu title', 'custom menu', 'add_users', 'custompage', '_custom_menu_page', null, 6);
add_menu_page("Info", "Info", 0, "info-slug", "infoPageFunction","", 6);
add_submenu_page("info-slug", "Entry", "Entry", 0, "entry-slug", "entryPageFunction");
add_submenu_page("info-slug", "Link", "Link", 0, "link-slug", "linkPageFunction");
}
add_action(' admin_menu',' register_my_custom_menu_page');
function entryPageFunction()
{
//~ echo '<script>
//~ window.location="/var/www/html/wordpress/wp-content/plugins/addmenu/entry.php";
//~ </script>';
require_once( add_Cmenu__PLUGIN_DIR . 'entry.php' );
}
我尝试了这个abve代码
也尝试过: - include( plugin_dir_path( __FILE__ ) . 'add_Cmenu/entry.php');
答案 0 :(得分:0)
试试这个。
function add_menu_info(){
add_menu_page('Info', 'Info', 'manage_options', 'Info', 'InfoFun');
add_submenu_page('Info', 'Entry', 'Entry', 'manage_options', 'entry', 'entryFun');
}
add_action('admin_menu', 'add_menu_info');
function entryFun(){
include(plugin_dir_path( __FILE__ ).'entry.php');
}