rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -46,8 +46,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
return;
}
// If we're not in wp-admin and the post has been published and preview nonce
// is non-existent or invalid then no need for preview in query.
/*
* If we're not in wp-admin and the post has been published and preview nonce
* is non-existent or invalid then no need for preview in query.
*/
if ( is_preview() && get_query_var( 'p' ) && 'publish' === get_post_status( get_query_var( 'p' ) ) ) {
if ( ! isset( $_GET['preview_id'] )
|| ! isset( $_GET['preview_nonce'] )
@@ -389,7 +391,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
}
}
} elseif ( is_single() && strpos( $wp_rewrite->permalink_structure, '%category%' ) !== false ) {
} elseif ( is_single() && str_contains( $wp_rewrite->permalink_structure, '%category%' ) ) {
$category_name = get_query_var( 'category_name' );
if ( $category_name ) {
@@ -518,7 +520,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
if ( ! empty( $addl_path )
&& $wp_rewrite->using_index_permalinks()
&& strpos( $redirect['path'], '/' . $wp_rewrite->index . '/' ) === false
&& ! str_contains( $redirect['path'], '/' . $wp_rewrite->index . '/' )
) {
$redirect['path'] = trailingslashit( $redirect['path'] ) . $wp_rewrite->index . '/';
}
@@ -677,7 +679,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
// Strip multiple slashes out of the URL.
if ( strpos( $redirect['path'], '//' ) > -1 ) {
if ( str_contains( $redirect['path'], '//' ) ) {
$redirect['path'] = preg_replace( '|/+|', '/', $redirect['path'] );
}
@@ -689,8 +691,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
$original_host_low = strtolower( $original['host'] );
$redirect_host_low = strtolower( $redirect['host'] );
// Ignore differences in host capitalization, as this can lead to infinite redirects.
// Only redirect no-www <=> yes-www.
/*
* Ignore differences in host capitalization, as this can lead to infinite redirects.
* Only redirect no-www <=> yes-www.
*/
if ( $original_host_low === $redirect_host_low
|| ( 'www.' . $original_host_low !== $redirect_host_low
&& 'www.' . $redirect_host_low !== $original_host_low )
@@ -737,7 +741,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
// Hex-encoded octets are case-insensitive.
if ( false !== strpos( $requested_url, '%' ) ) {
if ( str_contains( $requested_url, '%' ) ) {
if ( ! function_exists( 'lowercase_octets' ) ) {
/**
* Converts the first hex-encoded octet match to lowercase.