You make it the wrong way.
First, you do double work. Enqueue inside enqueue. You don’t need wp_enqueue_scripts()
:
wp_enqueue_style(
'color-admin-bar',
PATH_TO_CSS,
array( 'admin-bar' )
);
Second. Don’t use anonymous functions with WordPress Actions. Once-for-all-time is OK, but while the project is growing up you can collide with the inability to dequeue that style when you’ll want to.
The solution.
Make a copy of the admin-bar.css
and correct it to fit your needs. Then minimize it using any tool you can google for (optionally).
Dequeue the original admin bar:
<?php
add_action('admin_init', 'my_remove_admin_bar');
function my_remove_admin_bar() {
wp_dequeue_style('admin-bar')
}
And enqueue your new-laid my-admin-bar.css
Slight hitch. You can face the problem when the whole admin bar gets updated to the new look with the new WordPress version.
Related Posts:
- How to add crossorigin and integrity to wp_register_style? (Font Awesome 5)
- How to add extra attribute to stylesheet link?
- How to force stylesheet to load before anything else in header?
- To enqueue or not to enqueue
- Enqueued Stylesheet Version Number Not Being Appended
- I want to include my style.css in function.php file?
- Never Enqueued Stylehsheet
- Changes in enqueued / registered stylesheet paths not updating—why?
- Which is the best way to incorporate custom fonts?
- Additional CSS – crashing with javascript-html minifier?
- How do I view registered syles and scripts for enqueue
- stylesheet in header or functions?
- What is the difference between the different ways of linking stylesheets
- Enqueuing a stylesheet and ensuring it’s loaded before (not after) the theme’s stylesheet
- How to properly add my styles overriding current styles
- Can’t Workout Dependency of Stylesheets
- Homepage not loading correctly, but then loads when refreshing
- Why wp_register_style() is important while I’m using a complete wp_enqueue_style()? [duplicate]
- Is it ever okay to include inline CSS in plugins?
- How important is it to enqueue a theme’s stylesheet?
- How can I get a list of all enqueued scripts and styles?
- Style custom columns in admin panels (especially to adjust column cell widths)
- Remove Open Sans from Twenty Twelve theme
- How to load scripts/styles specific for a page
- WordPress Admin Bar Overlapping Twitter Bootstrap Navigation [closed]
- Enqueue Google Web Fonts Without Messing Up Symbols In URL
- Inbuilt style for jquery-ui-datepicker
- Why is style.css not being enqueued?
- How to enqueue the style using wp_enqueue_style()
- How to conditionally enqueue a stylesheet only for a certain page(s)?
- Enqueue a stylesheet for login page and make it appear in head element
- How to enqueue style before style.css
- WordPress admin stylesheet
- How to add stylesheets only to pages with specific shortcode?
- What is the correct way to enqueue multiple CSS files?
- How does one load style.css into a theme?
- Why is the Child Theme Stylesheet Not Loading?
- Loading a child-theme’s style.css after the parent’s
- Add ‘title’ attribute to stylesheets with wp_enqueue_style()
- Remove top admin bar
- wp_enqueue_style for Plugin with multiple stylesheets
- Remove wp_add_inline_style
- how to include other plugins css files in a shortcode?
- Is it possible to enqueue a raw CSS string directly from within a template file?
- Why I can’t add a CSS style in this WordPress theme?
- How to use wp_dequeue_style() for style enqueued in WP_Widget class
- Avoid to load default WP styles in login screen
- Give priority to child theme stylesheet
- Why my CSS file is not being registered in functions.php? [closed]
- How Would You Enqueue A Google Web Font?
- Does wordpress wp_enqueue_style support noscript?
- How can I dequeue a Plugin Stylesheet?
- Use wp_enqueue_scripts, not wp_print_styles?
- Enqueue a css using negative conditional tags
- Duplicated CSS files using wp_enqueue_style()
- Remove inline css added by wp_add_inline_css
- Enqueue styles through the wp_enqueue_style function vs link tag inside header.php
- Stylesheet from wp_enqueue_style is overwritten by plugin
- How to add the main style.css to my index.php?
- How to Add Admin Bar and Admin Menu or Submenu Notification Bubbles?
- Why isn’t my theme processing SASS?
- Add Font Awesome Embed CDN Script To WordPress
- TinyMCE custom stylesheets for different post types
- wp_add_inline_style in plugin not working
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- Adding style sheet to specific page
- Adding inline styles from a widget
- How do I load custom scripts and styles for a page?
- My child theme CSS get called twice
- “wp_enqueue_style();” don’t load new edited style
- wp_enqueue_style in Plugin [duplicate]
- How Can I Use A Child Theme Effectively When Parent’s CSS Is Located in a ‘CSS folder’?
- Disable child theme css on certain pages
- Child Theme Not Overriding Parent Theme
- How can I enqueue a style only when a particular widget is active?
- Hide Front-End Admin Bar Including 32 px Spacing
- Style.css in child theme is loaded before Bootstrap
- When enqueing a stylesheet, is it possible to remove the type attribute? [duplicate]
- How to keep theme layout the same when admin gray bar is present?
- Enqueued Stylesheets Effecting Admin Styles
- Enqueue stylesheet depending on template
- Enqueue styles after a plugin
- Google fonts enqueue only imports last font family
- I register and enqueue stylesheet but nothing is rendered
- Deregister CSS style link ‘open-sans-css’
- Prevent CSS/JS loading when plugin is not used
- Understanding child theme functions.php
- Load custom css after bootstrap
- wp_enqueue_style with style.php and WordPress functions
- Is it possible to use the featured image of a page as a css background without inlining?
- De-registering parent style sheet css recommended?
- Enqueue style for Password Reset page
- Creating Admin Options Page where users can make changes to a theme
- The correct way to include JavaScript and CSS in my WordPress Themes
- How to dequeue wp_get_custom_css in Twenty Twenty Theme
- wp_enqueue_style specifics for overwriting plugin styles
- Is it possible to change the path of a css file that is registered through wp_enqueue_style()?
- Dequeue theme stylesheets but keep widget styling on custom page template
- Relative path instead of absolute for wp_enqueue_script
- Can’t make wp_enqueue work