A WordPress-centric search engine for devs and theme authors



_get_wptexturize_shortcode_regex ›

Since4.4.0
Deprecatedn/a
_get_wptexturize_shortcode_regex ( $tagnames )
Access:
  • private
Parameters:
  • (array) $tagnames List of shortcodes to find.
    Required: Yes
Returns:
  • (string) The regular expression
Defined at:
Codex:

Retrieve the regular expression for shortcodes.



Source

function _get_wptexturize_shortcode_regex( $tagnames ) {
	$tagregexp = join( '|', 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;
}