WP_Token_Map::contains
Indicates if a given word is a lookup key in the map.
Example:
true === $smilies->contains( ':)' ); false === $smilies->contains( 'simile' );
Метод класса: WP_Token_Map{}
Хуков нет.
Возвращает
true|false
. Whether there's an entry for the given word in the map.
Использование
$WP_Token_Map = new WP_Token_Map(); $WP_Token_Map->contains( $word, $case_sensitivity ): bool;
- $word(строка) (обязательный)
- Determine if this word is a lookup key in the map.
- $case_sensitivity(строка)
- Pass 'ascii-case-insensitive' to ignore ASCII case when matching.
По умолчанию: 'case-sensitive'
Список изменений
С версии 6.6.0 | Введена. |
Код WP_Token_Map::contains() WP Token Map::contains WP 6.8.1
public function contains( string $word, string $case_sensitivity = 'case-sensitive' ): bool { $ignore_case = 'ascii-case-insensitive' === $case_sensitivity; if ( $this->key_length >= strlen( $word ) ) { if ( 0 === strlen( $this->small_words ) ) { return false; } $term = str_pad( $word, $this->key_length + 1, "\x00", STR_PAD_RIGHT ); $word_at = $ignore_case ? stripos( $this->small_words, $term ) : strpos( $this->small_words, $term ); if ( false === $word_at ) { return false; } return true; } $group_key = substr( $word, 0, $this->key_length ); $group_at = $ignore_case ? stripos( $this->groups, $group_key ) : strpos( $this->groups, $group_key ); if ( false === $group_at ) { return false; } $group = $this->large_words[ $group_at / ( $this->key_length + 1 ) ]; $group_length = strlen( $group ); $slug = substr( $word, $this->key_length ); $length = strlen( $slug ); $at = 0; while ( $at < $group_length ) { $token_length = unpack( 'C', $group[ $at++ ] )[1]; $token_at = $at; $at += $token_length; $mapping_length = unpack( 'C', $group[ $at++ ] )[1]; $mapping_at = $at; if ( $token_length === $length && 0 === substr_compare( $group, $slug, $token_at, $token_length, $ignore_case ) ) { return true; } $at = $mapping_at + $mapping_length; } return false; }