我遵循wordpress codex网站上关于通过插件创建管理主题的说明。我激活了插件,但我的样式表没有包含在<head>
..
这是我的代码:
add_action( \'admin_init\', \'kd_plugin_admin_init\' );
add_action( \'admin_menu\', \'kd_plugin_admin_menu\' );
function kd_plugin_admin_init() {
/* Register our stylesheet. */
wp_register_style( \'kdPluginStylesheet\', WP_PLUGIN_URL . \'/admin-theme.css\' );
}
function kd_plugin_admin_menu() {
/* Register our plugin page */
$page = add_submenu_page( \'edit.php\',
__( \'KD Plugin\', \'kdPlugin\' ),
__( \'KD Plugin\', \'kdPlugin\' ),
\'administrator\',
__FILE__,
\'kd_plugin_manage_menu\' );
/* Using registered $page handle to hook stylesheet loading */
add_action( \'admin_print_styles\' . $page, \'kd_plugin_admin_styles\' );
}
function kd_plugin_admin_styles() {
/*
* It will be called only on your plugin admin page, enqueue our stylesheet here
*/
wp_enqueue_style( \'kdPluginStylesheet\' );
}
function kd_plugin_manage_menu() {
/* Output our admin page */
}
SO网友:Hameedullah Khan
admin\\u print\\u styles挂钩中缺少连字符。
function kd_plugin_admin_menu() {
/* Register our plugin page */
$page = add_submenu_page( \'edit.php\',
__( \'KD Plugin\', \'kdPlugin\' ),
__( \'KD Plugin\', \'kdPlugin\' ),
\'administrator\',
__FILE__,
\'kd_plugin_manage_menu\' );
/* Using registered $page handle to hook stylesheet loading */
add_action( \'admin_print_styles-\' . $page, \'kd_plugin_admin_styles\' );
}