From 2941c1df63faf643875204ac37de324683e20b5d Mon Sep 17 00:00:00 2001 From: Cyssoo Date: Mon, 23 Mar 2026 15:58:33 +0100 Subject: [PATCH] Optimize shortcode pre-check to skip non-shortcode pages --- src/Service/EverblockTools.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Service/EverblockTools.php b/src/Service/EverblockTools.php index 78d90bee..fc7605e9 100644 --- a/src/Service/EverblockTools.php +++ b/src/Service/EverblockTools.php @@ -81,8 +81,15 @@ class EverblockTools extends ObjectModel */ public static function hasShortcodeToken(string $txt): bool { + if ($txt === '') { + return false; + } + + if (strpos($txt, '[') === false && strpos($txt, '{') === false) { + return false; + } + $needles = [ - '[', '{hook h=', '{$', '{if', @@ -96,7 +103,9 @@ public static function hasShortcodeToken(string $txt): bool } } - return false; + // Shortcode shape: [tag] or [tag ...] where tag starts with a letter. + // This avoids triggering the heavy renderer on plain HTML/JS arrays. + return (bool) preg_match('/\[[a-z][a-z0-9_-]*(?:\s[^\]]*)?\]/i', $txt); } /**