Make WordPress Core


Ignore:
Timestamp:
06/24/2023 04:48:25 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Use str_starts_with() and str_ends_with() in a few more places.

str_starts_with() and str_ends_with() were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).

WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.

Follow-up to [55990], [56014].

See #58220.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r54891 r56019  
    11381138
    11391139            // Unquote quoted filename, but after trimming.
    1140             if ( substr( $filename, 0, 1 ) === '"' && substr( $filename, -1, 1 ) === '"' ) {
     1140            if ( str_starts_with( $filename, '"' ) && str_ends_with( $filename, '"' ) ) {
    11411141                $filename = substr( $filename, 1, -1 );
    11421142            }
Note: See TracChangeset for help on using the changeset viewer.