Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hrenaud/bc3dec4b4658d8c3d9c7f3a97893d487 to your computer and use it in GitHub Desktop.

Select an option

Save hrenaud/bc3dec4b4658d8c3d9c7f3a97893d487 to your computer and use it in GitHub Desktop.
// https://wpastra.com/docs/remove-inline-css-from-astra/
// https://klbtheme.com/elementor-if-the-page-is_elementor/
function astra_force_remove_style() {
add_filter( 'print_styles_array', function($styles) {
// Set styles to remove.
$styles_to_remove = array('astra-theme-css', 'astra-addon-css', 'la-moissonniere-astra-child-theme-css');
$id = get_the_ID();
if( is_singular() && Elementor\Plugin::instance()->db->is_built_with_elementor( get_the_ID()) ) {
if(is_array($styles) AND count($styles) > 0){
foreach($styles AS $key => $code){
if(in_array($code, $styles_to_remove)){
unset($styles[$key]);
}
}
}
}
return $styles;
});
}
add_action('wp_enqueue_scripts', 'astra_force_remove_style', 99);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment