rebase on oct-10-2023
This commit is contained in:
@@ -210,7 +210,8 @@ function add_permastruct( $name, $struct, $args = array() ) {
|
||||
if ( ! is_array( $args ) ) {
|
||||
$args = array( 'with_front' => $args );
|
||||
}
|
||||
if ( func_num_args() == 4 ) {
|
||||
|
||||
if ( func_num_args() === 4 ) {
|
||||
$args['ep_mask'] = func_get_arg( 3 );
|
||||
}
|
||||
|
||||
@@ -542,12 +543,12 @@ function url_to_postid( $url ) {
|
||||
$url = set_url_scheme( $url, $scheme );
|
||||
|
||||
// Add 'www.' if it is absent and should be there.
|
||||
if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
|
||||
if ( str_contains( home_url(), '://www.' ) && ! str_contains( $url, '://www.' ) ) {
|
||||
$url = str_replace( '://', '://www.', $url );
|
||||
}
|
||||
|
||||
// Strip 'www.' if it is present and shouldn't be.
|
||||
if ( false === strpos( home_url(), '://www.' ) ) {
|
||||
if ( ! str_contains( home_url(), '://www.' ) ) {
|
||||
$url = str_replace( '://www.', '://', $url );
|
||||
}
|
||||
|
||||
@@ -572,7 +573,7 @@ function url_to_postid( $url ) {
|
||||
$url = str_replace( $wp_rewrite->index . '/', '', $url );
|
||||
}
|
||||
|
||||
if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
|
||||
if ( str_contains( trailingslashit( $url ), home_url( '/' ) ) ) {
|
||||
// Chop off http://domain.com/[path].
|
||||
$url = str_replace( home_url(), '', $url );
|
||||
} else {
|
||||
@@ -598,9 +599,11 @@ function url_to_postid( $url ) {
|
||||
$request_match = $request;
|
||||
foreach ( (array) $rewrite as $match => $query ) {
|
||||
|
||||
// If the requesting file is the anchor of the match,
|
||||
// prepend it to the path info.
|
||||
if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
|
||||
/*
|
||||
* If the requesting file is the anchor of the match,
|
||||
* prepend it to the path info.
|
||||
*/
|
||||
if ( ! empty( $url ) && ( $url !== $request ) && str_starts_with( $match, $url ) ) {
|
||||
$request_match = $url . '/' . $request;
|
||||
}
|
||||
|
||||
@@ -620,8 +623,10 @@ function url_to_postid( $url ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Got a match.
|
||||
// Trim the query of everything up to the '?'.
|
||||
/*
|
||||
* Got a match.
|
||||
* Trim the query of everything up to the '?'.
|
||||
*/
|
||||
$query = preg_replace( '!^.+\?!', '', $query );
|
||||
|
||||
// Substitute the substring matches into the query.
|
||||
|
||||
Reference in New Issue
Block a user