[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
WordPress implementation for PHP functions either missing from older PHP versions or not included by default. This file is loaded extremely early and the functions can be relied upon by drop-ins. Ergo, please ensure you do not rely on external functions when writing code for this file. Only use functions built into PHP or are defined in this file and have adequate testing and error suppression to ensure the file will run correctly and not break websites.
File Size: | 555 lines (17 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 1 file wp-includes/sodium_compat/autoload.php |
_( $message ) X-Ref |
Compat function to mimic _(), an alias of gettext(). return: string param: string $message The message being translated. |
_wp_can_use_pcre_u( $set = null ) X-Ref |
Returns whether PCRE/u (PCRE_UTF8 modifier) is available for use. param: bool $set - Used for testing only |
_is_utf8_charset( $charset_slug ) X-Ref |
Indicates if a given slug for a character set represents the UTF-8 text encoding. A charset is considered to represent UTF-8 if it is a case-insensitive match of "UTF-8" with or without the hyphen. Example: true === _is_utf8_charset( 'UTF-8' ); true === _is_utf8_charset( 'utf8' ); false === _is_utf8_charset( 'latin1' ); false === _is_utf8_charset( 'UTF 8' ); // Only strings match. false === _is_utf8_charset( [ 'charset' => 'utf-8' ] ); `is_utf8_charset` should be used outside of this file. return: bool Whether the slug represents the UTF-8 encoding. param: string $charset_slug Slug representing a text character encoding, or "charset". |
mb_substr( $string, $start, $length = null, $encoding = null ) X-Ref |
Compat function to mimic mb_substr(). return: string Extracted substring. param: string $string The string to extract the substring from. param: int $start Position to being extraction from in `$string`. param: int|null $length Optional. Maximum number of characters to extract from `$string`. param: string|null $encoding Optional. Character encoding to use. Default null. |
_mb_substr( $str, $start, $length = null, $encoding = null ) X-Ref |
Internal compat function to mimic mb_substr(). Only understands UTF-8 and 8bit. All other character sets will be treated as 8bit. For `$encoding === UTF-8`, the `$str` input is expected to be a valid UTF-8 byte sequence. The behavior of this function for invalid inputs is undefined. return: string Extracted substring. param: string $str The string to extract the substring from. param: int $start Position to being extraction from in `$str`. param: int|null $length Optional. Maximum number of characters to extract from `$str`. param: string|null $encoding Optional. Character encoding to use. Default null. |
mb_strlen( $string, $encoding = null ) X-Ref |
Compat function to mimic mb_strlen(). return: int String length of `$string`. param: string $string The string to retrieve the character length from. param: string|null $encoding Optional. Character encoding to use. Default null. |
_mb_strlen( $str, $encoding = null ) X-Ref |
Internal compat function to mimic mb_strlen(). Only understands UTF-8 and 8bit. All other character sets will be treated as 8bit. For `$encoding === UTF-8`, the `$str` input is expected to be a valid UTF-8 byte sequence. The behavior of this function for invalid inputs is undefined. return: int String length of `$str`. param: string $str The string to retrieve the character length from. param: string|null $encoding Optional. Character encoding to use. Default null. |
is_countable( $value ) X-Ref |
Polyfill for is_countable() function added in PHP 7.3. Verify that the content of a variable is an array or an object implementing the Countable interface. return: bool True if `$value` is countable, false otherwise. param: mixed $value The value to check. |
array_key_first( array $array ) X-Ref |
Polyfill for array_key_first() function added in PHP 7.3. Get the first key of the given array without affecting the internal array pointer. return: string|int|null The first key of array if the array param: array $array An array. |
array_key_last( array $array ) X-Ref |
Polyfill for `array_key_last()` function added in PHP 7.3. Get the last key of the given array without affecting the internal array pointer. return: string|int|null The last key of array if the array param: array $array An array. |
array_is_list( $arr ) X-Ref |
Polyfill for `array_is_list()` function added in PHP 8.1. Determines if the given array is a list. An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1. return: bool True if array is a list, false otherwise. param: array<mixed> $arr The array being evaluated. |
str_contains( $haystack, $needle ) X-Ref |
Polyfill for `str_contains()` function added in PHP 8.0. Performs a case-sensitive check indicating if needle is contained in haystack. return: bool True if `$needle` is in `$haystack`, otherwise false. param: string $haystack The string to search in. param: string $needle The substring to search for in the `$haystack`. |
str_starts_with( $haystack, $needle ) X-Ref |
Polyfill for `str_starts_with()` function added in PHP 8.0. Performs a case-sensitive check indicating if the haystack begins with needle. return: bool True if `$haystack` starts with `$needle`, otherwise false. param: string $haystack The string to search in. param: string $needle The substring to search for in the `$haystack`. |
str_ends_with( $haystack, $needle ) X-Ref |
Polyfill for `str_ends_with()` function added in PHP 8.0. Performs a case-sensitive check indicating if the haystack ends with needle. return: bool True if `$haystack` ends with `$needle`, otherwise false. param: string $haystack The string to search in. param: string $needle The substring to search for in the `$haystack`. |
array_find( array $array, callable $callback ) X-Ref |
Polyfill for `array_find()` function added in PHP 8.4. Searches an array for the first element that passes a given callback. return: mixed|null The first element in the array that passes the `$callback`, otherwise null. param: array $array The array to search. param: callable $callback The callback to run for each element. |
array_find_key( array $array, callable $callback ) X-Ref |
Polyfill for `array_find_key()` function added in PHP 8.4. Searches an array for the first key that passes a given callback. return: int|string|null The first key in the array that passes the `$callback`, otherwise null. param: array $array The array to search. param: callable $callback The callback to run for each element. |
array_any( array $array, callable $callback ) X-Ref |
Polyfill for `array_any()` function added in PHP 8.4. Checks if any element of an array passes a given callback. return: bool True if any element in the array passes the `$callback`, otherwise false. param: array $array The array to check. param: callable $callback The callback to run for each element. |
array_all( array $array, callable $callback ) X-Ref |
Polyfill for `array_all()` function added in PHP 8.4. Checks if all elements of an array pass a given callback. return: bool True if all elements in the array pass the `$callback`, otherwise false. param: array $array The array to check. param: callable $callback The callback to run for each element. |
Generated : Tue Jun 24 08:20:01 2025 | Cross-referenced by PHPXref |