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.


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' )

Method of the class: WP_Interactivity_API{}

No Hooks.


Array. An array containing the directive prefix and optional suffix.


// private - for code of main (parent) class only
$result = $this->extract_prefix_and_suffix( $directive_name ): array;
$directive_name(string) (required)
The directive attribute name.


Since 6.5.0 Introduced.

WP_Interactivity_API::extract_prefix_and_suffix() code WP 6.5.4

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