Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I followed instruction on the wordpress codex site on creating an admin theme via a plugin. I activated the plugin, but my stylesheet isn't being included in the <head>..

Here's my code:

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 */
}
share|improve this question
    
do you want to use your admin theme only on your plugin's page? –  Mamaduka Aug 26 '11 at 19:28
add comment

1 Answer

You are missing the hyphen in your admin_print_styles hook.

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' );
}
share|improve this answer
    
I just added the hyphen and actually tried it with the hyphen before, but still nothing... –  MF1 May 27 '11 at 11:49
    
I didn't tested the code but it was just hyphen that I found while going through your code, I will test the code as soon as I get on my dev machine and will let you know. –  Hameedullah Khan May 27 '11 at 12:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.