Make WordPress Core


Ignore:
Timestamp:
06/24/2023 09:50:34 AM (11 months ago)
Author:
SergeyBiryukov
Message:

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

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

WordPress core includes a polyfill for str_ends_with() on PHP < 8.0 as of WordPress 5.9.

Follow-up to [55990].

See #58220.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r55703 r56014  
    468468        // nginx only allows HTTP/1.0 methods when redirecting from / to /index.php.
    469469        // To work around this, we manually add index.php to the URL, avoiding the redirect.
    470         if ( 'index.php' !== substr( $url, 9 ) ) {
     470        if ( ! str_ends_with( $url, 'index.php' ) ) {
    471471            $url .= 'index.php';
    472472        }
Note: See TracChangeset for help on using the changeset viewer.