Changeset 57449
- Timestamp:
- 01/30/2024 05:48:27 PM (8 months ago)
- Location:
- branches/5.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
- Property svn:mergeinfo changed
/trunk merged: 52040,56015-56016
- Property svn:mergeinfo changed
-
branches/5.8/src/wp-includes/compat.php
r51508 r57449 372 372 } 373 373 374 if ( ! function_exists( 'str_starts_with' ) ) { 375 /** 376 * Polyfill for `str_starts_with()` function added in PHP 8.0. 377 * 378 * Performs a case-sensitive check indicating if 379 * the haystack begins with needle. 380 * 381 * @since 5.9.0 382 * 383 * @param string $haystack The string to search in. 384 * @param string $needle The substring to search for in the `$haystack`. 385 * @return bool True if `$haystack` starts with `$needle`, otherwise false. 386 */ 387 function str_starts_with( $haystack, $needle ) { 388 if ( '' === $needle ) { 389 return true; 390 } 391 392 return 0 === strpos( $haystack, $needle ); 393 } 394 } 395 396 if ( ! function_exists( 'str_ends_with' ) ) { 397 /** 398 * Polyfill for `str_ends_with()` function added in PHP 8.0. 399 * 400 * Performs a case-sensitive check indicating if 401 * the haystack ends with needle. 402 * 403 * @since 5.9.0 404 * 405 * @param string $haystack The string to search in. 406 * @param string $needle The substring to search for in the `$haystack`. 407 * @return bool True if `$haystack` ends with `$needle`, otherwise false. 408 */ 409 function str_ends_with( $haystack, $needle ) { 410 if ( '' === $haystack ) { 411 return '' === $needle; 412 } 413 414 $len = strlen( $needle ); 415 416 return substr( $haystack, -$len, $len ) === $needle; 417 } 418 } 419 374 420 // IMAGETYPE_WEBP constant is only defined in PHP 7.1 or later. 375 421 if ( ! defined( 'IMAGETYPE_WEBP' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.