您只需要两个步骤:
加入行动admin_menu
, 使用回调函数注册页面以打印内容在回调函数中,从加载文件plugin_dir_path( __FILE__ ) . "included.html"
.演示代码:
add_action( \'admin_menu\', \'wpse_91693_register\' );
function wpse_91693_register()
{
add_menu_page(
\'Include Text\', // page title
\'Include Text\', // menu title
\'manage_options\', // capability
\'include-text\', // menu slug
\'wpse_91693_render\' // callback function
);
}
function wpse_91693_render()
{
global $title;
print \'<div class="wrap">\';
print "<h1>$title</h1>";
$file = plugin_dir_path( __FILE__ ) . "included.html";
if ( file_exists( $file ) )
require $file;
print "<p class=\'description\'>Included from <code>$file</code></p>";
print \'</div>\';
}
我在演示插件中添加了一个示例
T5 Admin Menu Demo 在子菜单和OOP样式中演示如何执行此操作。