Changeset 57452 for branches/4.7/src/wp-includes/functions.php
- Timestamp:
- 01/30/2024 06:03:42 PM (11 months ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
- Property svn:mergeinfo changed
/trunk merged: 52040,56015-56016
- Property svn:mergeinfo changed
-
branches/4.7/src/wp-includes/functions.php
r54566 r57452 5 5 * @package WordPress 6 6 */ 7 8 /* 9 These next two functions are in this file due to compat.php having `__autoload` 10 in it and the PHP linter auto failing on it. 11 */ 12 13 if ( ! function_exists( 'str_starts_with' ) ) { 14 /** 15 * Polyfill for `str_starts_with()` function added in PHP 8.0. 16 * 17 * Performs a case-sensitive check indicating if 18 * the haystack begins with needle. 19 * 20 * @since 5.9.0 21 * 22 * @param string $haystack The string to search in. 23 * @param string $needle The substring to search for in the `$haystack`. 24 * @return bool True if `$haystack` starts with `$needle`, otherwise false. 25 */ 26 function str_starts_with( $haystack, $needle ) { 27 if ( '' === $needle ) { 28 return true; 29 } 30 31 return 0 === strpos( $haystack, $needle ); 32 } 33 } 34 35 if ( ! function_exists( 'str_ends_with' ) ) { 36 /** 37 * Polyfill for `str_ends_with()` function added in PHP 8.0. 38 * 39 * Performs a case-sensitive check indicating if 40 * the haystack ends with needle. 41 * 42 * @since 5.9.0 43 * 44 * @param string $haystack The string to search in. 45 * @param string $needle The substring to search for in the `$haystack`. 46 * @return bool True if `$haystack` ends with `$needle`, otherwise false. 47 */ 48 function str_ends_with( $haystack, $needle ) { 49 if ( '' === $haystack ) { 50 return '' === $needle; 51 } 52 53 $len = strlen( $needle ); 54 55 return substr( $haystack, -$len, $len ) === $needle; 56 } 57 } 7 58 8 59 require( ABSPATH . WPINC . '/option.php' );
Note: See TracChangeset
for help on using the changeset viewer.