Support » Themes and Templates » I am making a wordpress admin theme: how override wp-admin.css?

  • Hi,
    I’m making a new clean admin theme for WordPress, I finished the design but now I have to create the plugin.
    I would like to override the wp-admin.css, How can I do it? I tried with the action “admin_print_styles” but it does not override.
    Where is the problem?

    function xxxx() {
        $url = get_settings('siteurl');
        $dir = $url . '/wp-content/plugins/sklean/';
        echo '
        <link rel="stylesheet" type="text/css" href="' . $dir . 'wp-admin.css" />
        <link rel="stylesheet" type="text/css" href="' . $dir . 'css/colors-classic.css" />
        <link rel="stylesheet" type="text/css" href="' . $dir . 'css/widgets.css" />
        <link rel="stylesheet" type="text/css" href="' . $dir . 'css/global.css" />
        ';
    }
    
    add_action('admin_print_styles', 'xxxx');

Viewing 15 replies - 1 through 15 (of 25 total)
  • up please… I tried to use this but it doesn’t replace the original wp-admin.css…

    function my_wp_admin_css() {
      echo '<link rel="stylesheet" href="/wp-content/plugins/PLUGINAME/wp-admin.css" type="text/css" />';
    }
    
    add_action('wp_admin_css','my_wp_admin_css');

    Michael

    (@alchymyth)

    Forum Moderator

    i am sure you have read this: http://codex.wordpress.org/Creating_Admin_Themes
    (because your code looks alright)

    just double check if your plugin name is right (i assume it is not PLUGINAME ?) and that your css file is uploaded to the right folder.

    (and if you have not done it, refresh the browser cache to make the effect visible – CTRL F5)

    I checked all… But I still see some styles of the original wp-admin.css

    Help!! I will thank in the credits who will help me…

    (2) Help!! I will thank in the credits who will help me…

    I checked all… But I still see some styles of the original wp-admin.css

    And you will always see styles from wp-admin.css because what you are doing is adding a css file not overwriting it. I’m not sure if there is an internal WP mechanism for completely removing the default admin stylesheet, but even if there is it doesn’t seem worth it. You’d end up re-creating much of it anyway. The thing to do is use your stylesheet to over-write the css declarations that you want to change.

    Maybe the wp_admin_css_uri hook will let you completely remove the admin stylesheet.

    Thank you very much, but I also have to overwrite colors-classic.css… and I think wp_admin_css_uri doens’t resolve my problem..

    Poke around in wp-includes/general-template.php around line 1950. There are several things in there that might point you to something useful.

    Sincerely I am not very expert in php (I am learning it, I’m 15), I tried to paste the lines of the function wp_admin_css and wp_admin_css_uri in the php file of the plugin. But it does not work.
    If you can help me, I will thank you in the homepage of my blog skimbu.it (pagerank 4) and in the (future) plugin’s page.
    Thank you

    WordPress 2.9.1

    add_action('admin_print_styles', 'xxxx', 21);

    @kz, are you saying that will completely remove/overwrite the default admin stylesheet?

    The priority of default admin stylesheet is 20.
    See line 202 of wp-includes/default-filters.php
    add_action('admin_print_styles', 'print_admin_styles', 20);

    add_action('admin_print_styles', 'xxxx', 21); means xxxx function is called after print_admin_styles function.
    The later rules are winner. See Style cascad

    The later rules are winner.

    Well, yes, but the default stylesheet still loads and Albyzzolo wants it to not load at all. I don’t personally think that’s a good idea but it is an interesting puzzle. 🙂

    If Albyzzolo’s style rules overwrite all default rules, it doesn’t matter if default styles are loaded.
    If Albyzzolo’s style rules are the subset of default rules, it means his style is incomplete. If there are not default rules, it leads layout broken.

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘I am making a wordpress admin theme: how override wp-admin.css?’ is closed to new replies.