How do I remove CSS from WordPress admin sections
I've been looking at the remove_action() call, which works for some elements, but I'm not sure it works for the CSS in the header. I could manually edit the place where the CSS is loaded, but I'd rather do it through a开发者_如何学C plugin.
wp_admin_css_color
wp_admin_css
these are hooks that supposedly work, but I can't seem to figure out how use remove_action() on the hooks.
WordPress adds two default stylesheets (colors & wp-admin) to the admin area, you can deregister any stylesheet created by WordPress core, or any stylesheet created by a plugin using wp_deregister_style('stylesheet_registered_name');
the stylesheet name is its id="stylesheet-name" in the markup
to remove the 2 default admin stylesheets you can add something like the following code to your functions.php file or to a plugin.php file make sure to replace 'your' to a collision free prefix
// this will remove the stylesheet when init fires
add_action('admin_init','your_remove_default_stylesheets');
// this is your function to deregister the default admin stylesheet
function your_remove_default_stylesheets() {
wp_deregister_style('wp-admin');
}
If this is still helpful for anyone, I was able to make admin side completely match front end easily.
1) When you enqueue your theme or plugin styles, make sure to include admin_enqueue_scripts action to any styles you want to use on the backend.
2) In your global javascript, remove the classes 'wp-ui-core' and 'wp-admin' from the body.
jQuery('body').removeClass('wp-core-ui wp-admin');
So far I have found no detrimental side-effects. The admin sidebar still loads and functions fine, and all of the admin pages look great, but now they match my theme instead of WP's design.
This covers removing actions for themes: Function Reference/remove action « WordPress Codex. Don't know how relevant it is for WP's admin area.
I actually came up with a solution to this, after much searching and trial and error. To my knowledge, it's not in the WordPress codex anywhere, and when I brought it up in the WordPress IRC channels, some scoffed, as if the idea was just ridiculous. I'll try and document it later when I have a chance, but I'll start by saying it involves creating your own functions.php file in your theme, and adding several instances of wp_deregister_style(), as well as a wp_admin_css hook to override the default theme.
Interestingly, I could not get this fix to work in a plugin, which was alright for my purposes since I have a highly modified theme, but I could imagine people wanting to just do it with a simple plugin.
精彩评论