Guest User

Untitled

a guest
Aug 15th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. function cybmeta_dequeue_fontawsome() {
  2.  
  3. global $wp_styles;
  4. // we use preg_match to find only the following patterns as exact matches, to prevent other stylesheets that contain font-awesome expression to be also dequeued
  5. $patterns = array(
  6. 'font-awesome.css',
  7. 'font-awesome.min.css'
  8. );
  9.  
  10. $regex = '/(' .implode('|', $patterns) .')/i';
  11.  
  12. foreach( $wp_styles -> registered as $registered ) {
  13.  
  14. if( preg_match( $regex, $registered->src) ) {
  15. wp_dequeue_style( $registered->handle );
  16. // FA was dequeued, so here we need to enqueue it again from the location we want (cdn in our code)
  17. wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' );
  18. }
  19. }
  20.  
  21. }
  22. add_action( 'wp_enqueue_scripts', 'cybmeta_dequeue_fontawsome' );
Add Comment
Please, Sign In to add comment