Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



_get_wptexturize_shortcode_regex ›

Od4.4.0
Przestarzałyn/a
_get_wptexturize_shortcode_regex ( $tagnames )
Dostęp:
  • private
Parametry:
  • (array) $tagnames List of shortcodes to find.
    Wymagane: Tak
Powrót:
  • (string) The regular expression
Zdefiniowane na:
Codex:

Retrieve the regular expression for shortcodes.



Źródło

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;
}