WP_Interactivity_API::extract_prefix_and_suffix()privateWP 6.5.0

Extracts the directive attribute name to separate and return the directive prefix and an optional suffix.

The suffix is the string after the first double hyphen and the prefix is everything that comes before the suffix.

Example:

extract_prefix_and_suffix( 'data-wp-interactive' )   => array( 'data-wp-interactive', null )
extract_prefix_and_suffix( 'data-wp-bind--src' )     => array( 'data-wp-bind', 'src' )
extract_prefix_and_suffix( 'data-wp-foo--and--bar' ) => array( 'data-wp-foo', 'and--bar' )

Метод класса: WP_Interactivity_API{}

Хуков нет.

Возвращает

Массив. An array containing the directive prefix and optional suffix.

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

// private - только в коде основоного (родительского) класса
$result = $this->extract_prefix_and_suffix( $directive_name ): array;
$directive_name(строка) (обязательный)
The directive attribute name.

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

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

Код WP_Interactivity_API::extract_prefix_and_suffix() WP 6.7.1

private function extract_prefix_and_suffix( string $directive_name ): array {
	return explode( '--', $directive_name, 2 );
}