Created
September 21, 2020 18:55
-
-
Save hrenaud/bc3dec4b4658d8c3d9c7f3a97893d487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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