_get_wptexturize_shortcode_regex()
Retrieves the regular expression for shortcodes.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
String
. The regular expression
Usage
_get_wptexturize_shortcode_regex( $tagnames );
- $tagnames(string[]) (required)
- Array of shortcodes to find.
Changelog
Since 4.4.0 | Introduced. |
_get_wptexturize_shortcode_regex() get wptexturize shortcode regex code WP 6.5.2
function _get_wptexturize_shortcode_regex( $tagnames ) { $tagregexp = implode( '|', array_map( 'preg_quote', $tagnames ) ); $tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation $regex = '\[' // Find start of shortcode. . '[\/\[]?' // Shortcodes may begin with [/ or [[. . $tagregexp // Only match registered shortcodes, because performance. . '(?:' . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. . '|' . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. . ')*+' // Possessive critical. . '\]' // Find end of shortcode. . '\]?'; // Shortcodes may end with ]]. // phpcs:enable return $regex; }