We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have some pages on my site that I need to redirect to the home page (due to legacy SEO).
However redirecting to "/" causes an error in wp-admin.
A PHP Error was encountered Severity: Notice Message: Uninitialized string offset: 1 Filename: classes/plugin.php Line Number: 799
This is the function where the error occurs:
public static function absolute_url( $url ) { // Convert server- and protocol-relative URLs to absolute URLs. if ( '/' === $url[0] ) { // Protocol-relative. if ( '/' === $url[1] ) { $url = set_url_scheme( 'http:' . $url ); } else { // Host-relative. $url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $url ); } } if ( 'mailto' !== parse_url( $url, PHP_URL_SCHEME ) ) { $url = str_replace( '@', '%40', $url ); } return $url; }
My proposed fix is to first check the length of the string before checking if it is protocol-relative, as follows:
public static function absolute_url( $url ) { // Convert server- and protocol-relative URLs to absolute URLs. if ( '/' === $url[0] ) { // Protocol-relative. if ( strlen($url) > 1 && '/' === $url[1] ) { $url = set_url_scheme( 'http:' . $url ); } else { // Host-relative. $url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $url ); } } if ( 'mailto' !== parse_url( $url, PHP_URL_SCHEME ) ) { $url = str_replace( '@', '%40', $url ); } return $url; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have some pages on my site that I need to redirect to the home page (due to legacy SEO).
However redirecting to "/" causes an error in wp-admin.
This is the function where the error occurs:
My proposed fix is to first check the length of the string before checking if it is protocol-relative, as follows:
The text was updated successfully, but these errors were encountered: