WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do I add css to admin backend to display:none specific menu items? (14 posts)

  1. Pete
    Member
    Posted 4 years ago #

    How do I add css stuff to the admin backend to "display:none" on specific menu items? (I want to hide some menu items as the plugin Adminimize isn't doing what it should ).

    Thanks heaps :)

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    I pop this in my functions.php to do all sorts of styling in my admin area

    // THIS GIVES US SOME OPTIONS FOR STYLING THE ADMIN AREA
    function custom_colors() {
       echo '<style type="text/css">
               #wphead{background:#592222}
               #footer{background:#592222}
               #footer-upgrade{background:#592222}
             </style>';
    }
    
    add_action('admin_head', 'custom_colors');
  3. Pete
    Member
    Posted 4 years ago #

    Thats cool.. but is there another function to add ANY css changes to the admin area, not just colors?

  4. Logically, if you add in CSS changes in the section between the style calls in RVoodoo's example, yes.

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    yeah, you can add anything you want. My css is actually about 50 lines long, I just didn't want to post the whole thing.

    I use firebug in FF, or developer toolbar in IE to find the class/id of whatever element I want to affect and then add that line to the css

    the function is just named custom colors....but its for working over the css as a whole, not just colours

  6. Pete
    Member
    Posted 4 years ago #

    coooool :)

  7. Pete
    Member
    Posted 4 years ago #

    if I could just stretch the friendship that little bit more here and ask how i could apply those css changes to all users EXCEPT the admin... thanks.

    Love Pete xxx

  8. mjjinvincible
    Member
    Posted 4 years ago #

    Checking first if the user level is not the admin one (i.e. 10):

    function custom_colors() {
    	global $user_level;
    	if ($user_level != '10' ) {
    	   echo '<style type="text/css">
    		   /* Styles here! */
    		 </style>';
       }
    }
    
    add_action('admin_head', 'custom_colors');
  9. Pete
    Member
    Posted 4 years ago #

    Thanks for that :)

  10. Pete
    Member
    Posted 4 years ago #

    This is an awesome piece of code. I wish there was a plugin that could insert a simple text field in there from the admin backend into where the /* Styles here! */ are

  11. Pete
    Member
    Posted 4 years ago #

    What add_action would I use to have this function apply css to the theme?

  12. Pete
    Member
    Posted 4 years ago #

    This?

    function custom_colors() {
    	global $user_level;
    	if ($user_level != '10' ) {
    	   echo '<style type="text/css">
    		   /* Styles here! */
    		 </style>';
       }
    }
    
    add_action('wp_head', 'custom_colors');
  13. Pete
    Member
    Posted 3 years ago #

    This is an awesome piece of code. I wish there was a plugin that could insert a simple text field in there from the admin backend into where the /* Styles here! */ are

    It appears there is a plugin that does exactly this...
    http://wordpress.org/extend/plugins/enhancing-css/

  14. mattcass
    Member
    Posted 3 years ago #

    take a look at the pretty slick plugin Adminimize which handles the hiding of admin elements from different users.

Topic Closed

This topic has been closed to new replies.

About this Topic