src/includes/classes/Core/Tokenizer.php
protected function maybeTokenizeShortcodes()
    {
        if (!in_array('shortcodes', $this->tokenize, true)) {
            return; // Not tokenizing these.
        } elseif (mb_strpos($this->string, '[') === false) {
            return; // No `[` shortcodes.
        } elseif (mb_strpos($this->string, ']') === false) {
            return; // No `[` shortcodes.
        }
        if ($this->args['shortcode_tag_names']) {
            $shortcode_tag_names = $this->args['shortcode_tag_names'];
        } elseif (!empty($GLOBALS['shortcode_tags']) && is_array($GLOBALS['shortcode_tags'])) {
            $shortcode_tag_names = array_keys($GLOBALS['shortcode_tags']);
        }
        if (empty($shortcode_tag_names) || !$this->c::isWordPress() || !$this->c::canCallFunc('get_shortcode_regex')) {
            return; // Not possible at this time.
        }
        if ($this->args['shortcode_unautop_compat_tag_name']) {
            $this->shortcode_unautop_compat_tag_name = $this->args['shortcode_unautop_compat_tag_name'];
        } else { // Any registered shortcode tag name; for `shortcode_unautop_compat` mode.
            $this->shortcode_unautop_compat_tag_name = $shortcode_tag_names[0];
        } // This prevents WordPress from wrapping a stand-alone token with `<p></p>`.

        $regex = '/'.get_shortcode_regex($shortcode_tag_names).'/us'; // Dot matches new line.
        // See: <https://developer.wordpress.org/reference/functions/get_shortcode_regex/>

        $this->string = preg_replace_callback($regex, function ($m) {
            // If excluding escaped shortcodes, check here before we continue.
            if ($this->args['exclude_escaped_shortcode'] && $m[1] === '[' && $m[6] === ']') {
                return $m[0]; // Exclude from tokenization.
            }
            $this->tokens[] = $m[0]; // Original data for token.
            // i.e., The entire shortcode (w/ possible escape brackets).

            if ($this->args['shortcode_unautop_compat']) {
                return $token = '['.$this->shortcode_unautop_compat_tag_name.' _is_token=⁅⒯⁆]'.
                                    '⁅⒯'.$this->id.'⒯'.(count($this->tokens) - 1).'⒯⁆'.
                                '[/'.$this->shortcode_unautop_compat_tag_name.']';
            } else { // Default behavior.
                return $token = '⁅⒯'.$this->id.'⒯'.(count($this->tokens) - 1).'⒯⁆';
            }
        }, $this->string); // Shortcodes replaced by tokens.
    }
protected function maybeTokenizeShortcodes()
    {
        if (!in_array('shortcodes', $this->tokenize, true)) {
            return; // Not tokenizing these.
        } elseif (mb_strpos($this->string, '[') === false) {
            return; // No `[` shortcodes.
        } elseif (mb_strpos($this->string, ']') === false) {
            return; // No `[` shortcodes.
        }
        if ($this->args['shortcode_tag_names']) {
            $shortcode_tag_names = $this->args['shortcode_tag_names'];
        } elseif (!empty($GLOBALS['shortcode_tags']) && is_array($GLOBALS['shortcode_tags'])) {
            $shortcode_tag_names = array_keys($GLOBALS['shortcode_tags']);
        }
        if (empty($shortcode_tag_names) || !$this->c::isWordPress() || !$this->c::canCallFunc('get_shortcode_regex')) {
            return; // Not possible at this time.
        }
        if ($this->args['shortcode_unautop_compat_tag_name']) {
            $this->shortcode_unautop_compat_tag_name = $this->args['shortcode_unautop_compat_tag_name'];
        } else { // Any registered shortcode tag name; for `shortcode_unautop_compat` mode.
            $this->shortcode_unautop_compat_tag_name = $shortcode_tag_names[0];
        } // This prevents WordPress from wrapping a stand-alone token with `<p></p>`.

        $regex = '/'.get_shortcode_regex($shortcode_tag_names).'/us'; // Dot matches new line.
        // See: <https://developer.wordpress.org/reference/functions/get_shortcode_regex/>

        $this->string = preg_replace_callback($regex, function ($m) {
            // If excluding escaped shortcodes, check here before we continue.
            if ($this->args['exclude_escaped_shortcode'] && $m[1] === '[' && $m[6] === ']') {
                return $m[0]; // Exclude from tokenization.
            }
            $this->tokens[] = $m[0]; // Original data for token.
            // i.e., The entire shortcode (w/ possible escape brackets).

            if ($this->args['shortcode_unautop_compat']) {
                return $token = '['.$this->shortcode_unautop_compat_tag_name.' _is_token=⁅⒯⁆]'.
                                    '⁅⒯'.$this->id.'⒯'.(count($this->tokens) - 1).'⒯⁆'.
                                '[/'.$this->shortcode_unautop_compat_tag_name.']';
            } else { // Default behavior.
                return $token = '⁅⒯'.$this->id.'⒯'.(count($this->tokens) - 1).'⒯⁆';
            }
        }, $this->string); // Shortcodes replaced by tokens.
    }
Maybe tokenize shortcodes.

@since 150424 Initial release.