diff --git a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php index 6f05eee7..340d4e2d 100644 --- a/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php +++ b/src/flextype/core/Parsers/Shortcodes/StringsShortcode.php @@ -20,7 +20,7 @@ use Thunder\Shortcode\Shortcode\ShortcodeInterface; use function parsers; use function registry; -// Shortcode: [strings at=1 sort=desc transform=lower,upper] +// Shortcode: [strings] strings to modify [/strings] parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterface $s) { if (! registry()->get('flextype.settings.parsers.shortcodes.shortcodes.strings.enabled')) { return ''; @@ -80,6 +80,10 @@ parsers()->shortcodes()->addHandler('strings', static function (ShortcodeInterfa if ($key == 'wordsLimit') { $content = strings($content)->{'wordsLimit'}(isset($values[0]) ? (int) $values[0] : 100, isset($values[1]) ? (string) $values[1] : '...')->toString(); } + + if ($key == 'at') { + $content = strings($content)->{'at'}((int) $values)->toString(); + } } return (string) $content; diff --git a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php index 961145ed..1ccb4473 100644 --- a/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php +++ b/tests/src/flextype/core/Parsers/Shortcodes/StringsShortcodeTest.php @@ -34,4 +34,9 @@ test('[strings] shortcode', function () { // wordsLimit $this->assertEquals("foo...", parsers()->shortcodes()->parse('[strings wordsLimit="1"]foo bar zed[/strings]')); $this->assertEquals("foo >>>", parsers()->shortcodes()->parse('[strings wordsLimit="1| >>>"]foo bar zed[/strings]')); + + // at + $this->assertEquals("a", parsers()->shortcodes()->parse('[strings at=0]abc[/strings]')); + $this->assertEquals("b", parsers()->shortcodes()->parse('[strings at=1]abc[/strings]')); + $this->assertEquals("c", parsers()->shortcodes()->parse('[strings at=2]abc[/strings]')); }); \ No newline at end of file