Answers:
您只需要两个步骤:
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样式中执行此操作。