From 7626ff89567155e3f89fc7ba379313574f9a61ce Mon Sep 17 00:00:00 2001 From: Timotei Date: Mon, 15 Apr 2024 14:03:18 +0300 Subject: [PATCH 1/2] ESI - enqueued scripts/styles --- src/esi.cls.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/esi.cls.php b/src/esi.cls.php index 25e724acb..b63d15bad 100644 --- a/src/esi.cls.php +++ b/src/esi.cls.php @@ -915,10 +915,31 @@ 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; + foreach($wp_styles->registered as $registered) wp_deregister_style($registered->handle); + 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 '