WordPress.org

Ready to get started?Download WordPress

Forums

I am making a wordpress admin theme: how override wp-admin.css? (26 posts)

  1. Alberto Ziveri
    Member
    Posted 4 years ago #

    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');
  2. Alberto Ziveri
    Member
    Posted 4 years ago #

    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');
  3. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    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)

  4. Alberto Ziveri
    Member
    Posted 4 years ago #

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

  5. Alberto Ziveri
    Member
    Posted 4 years ago #

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

  6. Alberto Ziveri
    Member
    Posted 4 years ago #

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

  7. s_ha_dum
    Member
    Posted 4 years ago #

    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.

  8. s_ha_dum
    Member
    Posted 4 years ago #

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

  9. Alberto Ziveri
    Member
    Posted 4 years ago #

    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..

  10. s_ha_dum
    Member
    Posted 4 years ago #

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

  11. Alberto Ziveri
    Member
    Posted 4 years ago #

    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

  12. kz
    Member
    Posted 4 years ago #

    WordPress 2.9.1

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

  13. s_ha_dum
    Member
    Posted 4 years ago #

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

  14. kz
    Member
    Posted 4 years ago #

    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

  15. s_ha_dum
    Member
    Posted 4 years ago #

    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. :)

  16. kz
    Member
    Posted 4 years ago #

    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.

  17. Alberto Ziveri
    Member
    Posted 4 years ago #

    Thank you to apljdi and kz, tomorrow I will try the kz solution. So if you send me your websites I will thank you in the article that I will do in my blog and in the (future) plugin's page. My mail is alby(at)skimbu(dot)it

  18. s_ha_dum
    Member
    Posted 4 years ago #

    The kz solution is the solution I explained in my first post, and which you rejected. But it is the best way to go.

  19. Alberto Ziveri
    Member
    Posted 4 years ago #

    I already designed and coded the admin theme, and I tried to put it in the wp-admin folder, so it worked.. But as you know it presents various bugs if I create the plugin that insert the calls to my css files. Can I send you the images and css files I created (and the plugin page)? So you can see the errors..

  20. s_ha_dum
    Member
    Posted 4 years ago #

    Find somewhere online to post the images and put the css in the WP pastebin (or any other pastebin you feel like). Maybe I or somebody else will spot something. I have to reiterate my feeling that you are going about this incorrectly. You should be keeping the default stylesheet as a base and overwriting what you don't like. I think you are making this hard on yourself both now and in the future when you try to upgrade.

  21. Alberto Ziveri
    Member
    Posted 4 years ago #

    I'm trying from many days to overwrite what I don't like in the default CSS, but it is a big work..
    I uploaded edited css files..
    WP-ADMIN.CSS : http://wordpress.pastebin.com/m7aa7b003
    COLORS-CLASSIC.CSS : http://wordpress.pastebin.com/mc71f246

    I also edited global.css and widgets.css but it does not create errors..

  22. s_ha_dum
    Member
    Posted 4 years ago #

    What errors are you getting exactly? Sorry, but I'm not digging through nearly 700 lines of css. You have to provide better guidance. Perhaps a diff of the default stylesheets and your stylesheets?

  23. Alberto Ziveri
    Member
    Posted 4 years ago #

    I understood that there is no solution to overwrite the default css, I will resolve all the CSS problems...
    Thank you for your help.

  24. shawnkhall
    Member
    Posted 3 years ago #

    You could probably use this to deactivate the default styles:
    remove_action('admin_print_styles', 'print_admin_styles', 20);

  25. Avnish Awasthi
    Member
    Posted 3 years ago #

    how to make css for wordpress admin theme??? can anyone give examples

  26. DPoncy
    Member
    Posted 3 years ago #

    I am also having a problem with this. The plugin is working, and the footer text shows up. But the link to the stylesheet does not even show up in my source code.

    function my_wp_admin_css() {
     echo '
      // use the "admin-simplified" style
    <link rel="stylesheet" type="text/css" href="/wp-content/mu-plugins/as-css/wp-admin.css" />
     ';
    }
    
    function admin_simplified_footer() {
       echo 'Admin Simplified theme by <a href="http://fictionworks.net/dev/">Duane Poncy</a>.';
    }
    
    add_action('wp_admin_css','my_wp_admin_css');
    add_action('admin_footer', 'admin_simplified_footer');

    I followed the instructions in the codex to a tee, other than placing it in my mu-plugins folder instead of the regular plugins. My /as-css/ folder is in the correct place, as well as the wp-admin.css file. I have checked this over several times, but it just doesn't seem to work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags