diff --git a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php index ed1ee6c1..ea2fa210 100644 --- a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php @@ -122,6 +122,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa $content = strings($content)->{'containsAll'}(isset($vars[0]) ? explode($itemsDelimeter, $vars[0]) : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : true) ? "true" : "false"; } + if ($key == 'containsAny') { + $content = strings($content)->{'containsAny'}(isset($vars[0]) ? explode($itemsDelimeter, $vars[0]) : '', isset($vars[1]) ? strings($vars[1])->toBoolean() : true) ? "true" : "false"; + } + if ($key == 'count') { $content = (string) strings($content)->{'count'}(); } diff --git a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php index c9554aba..b9bb8a24 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php @@ -72,6 +72,12 @@ test('[strings] shortcode', function () { $this->assertEquals("false", parsers()->shortcodes()->parse('[strings containsAll=SG-1,XXX-3C3]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); $this->assertEquals("true", parsers()->shortcodes()->parse('[strings containsAll=sg-1,P9Y-3C3|false]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); + // containsAny + $this->assertEquals("true", parsers()->shortcodes()->parse('[strings containsAny=SG-1]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); + $this->assertEquals("true", parsers()->shortcodes()->parse('[strings containsAny=SG-1,P9Y-3C3]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); + $this->assertEquals("true", parsers()->shortcodes()->parse('[strings containsAny=SG-1,XXX-3C3]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); + $this->assertEquals("true", parsers()->shortcodes()->parse('[strings containsAny=sg-1,P9Y-3C3|false]SG-1 returns from an off-world mission to P9Y-3C3[/strings]')); + // count $this->assertEquals(49, parsers()->shortcodes()->parse('[strings count]SG-1 returns from an off-world mission to P9Y-3C3[/strings]'));