wp-includes/interactivity-api/class-wp-interactivity-api.php:798Parse the directive name to extract the following parts: - Prefix: The main directive name without "data-wp-". It cannot begin with a hyphen.
$directive_namestringarray|null private function parse_directive_name( string $directive_name ): ?array { // Remove the first 8 characters (assumes "data-wp-" prefix) $name = (string) substr( $directive_name, 8 ); // Ensure the name only contains valid characters (anything a-z, A-Z, 0-9, -, or _). if ( 1 !== preg_match( '/^[a-zA-Z0-9\-_]+$/', $name ) ) { return null; } // Find the first occurrence of '--' to separate the prefix. $suffix_index = strpos( $name, '--' ); /* * A prefix cannot begin with a hyphen, so a name which does is not a directive at all. This * covers both a lone leading hyphen, as in "data-wp--bind", and a leading double hyphen, as * in "data-wp---foo", where treating the hyphens as a suffix separator would instead leave * the prefix empty. It also covers "data-wp----unique-id", where only a unique ID is supplied * without any prefix or suffix. */ if ( 0 === $suffix_index || '-' === $name[0] ) { return null; } // Without a '--' the whole name is the prefix. (This naturally also means there is no unique ID after '---'.) if ( false === $suffix_index ) { return array( 'prefix' => $name, 'suffix' => null, 'unique_id' => null, ); } $prefix = substr( $name, 0, $suffix_index ); $remaining = substr( $name, $suffix_index ); // If remaining starts with '---' but not '----', it's a unique_id if ( 3 === strspn( $remaining, '-' ) ) { $unique_id = (string) substr( $remaining, 3 ); return array( 'prefix' => $prefix, 'suffix' => null, 'unique_id' => '' === $unique_id ? null : $unique_id, ); } // Otherwise, remove the first two dashes for a potential suffix $suffix = (string) substr( $remaining, 2 ); // Look for '---' in the suffix for a unique_id $unique_id_index = strpos( $suffix, '---' ); if ( false !== $unique_id_index && '-' !== ( $suffix[ $unique_id_index + 3 ] ?? '' ) ) { $unique_id = (string) substr( $suffix, $unique_id_index + 3 ); $suffix = (string) substr( $suffix, 0, $unique_id_index ); return array( 'prefix' => $prefix, 'suffix' => '' === $suffix ? null : $suffix, 'unique_id' => '' === $unique_id ? null : $unique_id, ); } return array( 'prefix' => $prefix, 'suffix' => '' === $suffix ? null : $suffix, 'unique_id' => null, ); }Introduced in 6.9.0. One change between 6.9.7 and 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
array to array|null.verified against sourcesrc/wp-includes/interactivity-api/class-wp-interactivity-api.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.