Advertisement
fahimmurshed

How to Remove Inline CSS from Astra theme

Aug 25th, 2020
2,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. // The following filter will remove inline CSS generated by the Astra theme and Astra Pro plugin.
  2. // Paste the following code into child theme’s functions.php file
  3. function astra_force_remove_style() {
  4.     add_filter( 'print_styles_array', function($styles) {
  5.  
  6.         // Set styles to remove.
  7.         $styles_to_remove = array('astra-theme-css', 'astra-addon-css');
  8.         if(is_array($styles) AND count($styles) > 0){
  9.             foreach($styles AS $key => $code){
  10.                 if(in_array($code, $styles_to_remove)){
  11.                     unset($styles[$key]);
  12.                 }
  13.             }
  14.         }
  15.         return $styles;
  16.     });
  17. }
  18. add_action('wp_enqueue_scripts', 'astra_force_remove_style', 99);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement