diff --git a/src/esi.cls.php b/src/esi.cls.php index 25e724acb..185b07cda 100644 --- a/src/esi.cls.php +++ b/src/esi.cls.php @@ -915,10 +915,35 @@ public function load_esi_shortcode($params) $atts_ori[] = is_string($k) ? "$k='" . addslashes($v) . "'" : $v; } + // Clear registered styles and scripts + global $wp_scripts, $wp_styles; + if($wp_scripts){ + foreach($wp_styles->registered as $registered) wp_deregister_style($registered->handle); + } + if($wp_styles){ + foreach($wp_scripts->registered as $registered) wp_deregister_script($registered->handle); + } + Tag::add(Tag::TYPE_ESI . "esi.$shortcode"); // Output original shortcode final content echo do_shortcode("[$shortcode " . implode(' ', $atts_ori) . ' ]'); + + // Add registered styles and scripts from shortcode. + if(count($wp_styles->registered) > 0){ + foreach($wp_styles->registered as $style_tag){ + if( !is_bool($style_tag->src) && !empty($style_tag->src)){ + echo '