_get_wptexturize_shortcode_regex()WP 4.4.0

Retrieves the regular expression for shortcodes.

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

Строку. The regular expression

Использование

_get_wptexturize_shortcode_regex( $tagnames );
$tagnames(string[]) (обязательный)
Array of shortcodes to find.

Список изменений

С версии 4.4.0 Введена.

Код _get_wptexturize_shortcode_regex() 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;
}