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.

git-svn-id: https://develop.svn.wordpress.org/trunk@56014 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2023-06-24 09:50:34 +00:00
parent e628c736c8
commit b1ebb813bf
5 changed files with 5 additions and 5 deletions

View File

@@ -467,7 +467,7 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
// nginx only allows HTTP/1.0 methods when redirecting from / to /index.php.
// To work around this, we manually add index.php to the URL, avoiding the redirect.
if ( 'index.php' !== substr( $url, 9 ) ) {
if ( ! str_ends_with( $url, 'index.php' ) ) {
$url .= 'index.php';
}