WP_Interactivity_API::extract_prefix_and_suffix()
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' )
Method of the class: WP_Interactivity_API{}
No Hooks.
Returns
Array
. An array containing the directive prefix and optional suffix.
Usage
// 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.
Changelog
Since 6.5.0 | Introduced. |
WP_Interactivity_API::extract_prefix_and_suffix() WP Interactivity API::extract prefix and suffix code WP 6.8.1
private function extract_prefix_and_suffix( string $directive_name ): array { return explode( '--', $directive_name, 2 ); }