From c2aa33de6aed863627b6ea5414bb7b8c5bc4a6d3 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 25 Sep 2013 00:47:09 +0000 Subject: [PATCH] Clean up the path calculations in wp::parse_request(). props evansolomon for initial cleanup. fixes #22209. Built from https://develop.svn.wordpress.org/trunk@25617 git-svn-id: http://core.svn.wordpress.org/trunk@25534 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index e7191b6161..c3b9bf1d90 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -141,22 +141,13 @@ class WP { $error = '404'; $this->did_permalink = true; - if ( isset($_SERVER['PATH_INFO']) ) - $pathinfo = $_SERVER['PATH_INFO']; - else - $pathinfo = ''; - $pathinfo_array = explode('?', $pathinfo); - $pathinfo = str_replace("%", "%25", $pathinfo_array[0]); - $req_uri = $_SERVER['REQUEST_URI']; - $req_uri_array = explode('?', $req_uri); - $req_uri = $req_uri_array[0]; + $pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : ''; + list( $pathinfo ) = explode( '?', $pathinfo ); + $pathinfo = str_replace( "%", "%25", $pathinfo ); + + list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); $self = $_SERVER['PHP_SELF']; - $home_path = parse_url(home_url()); - if ( isset($home_path['path']) ) - $home_path = $home_path['path']; - else - $home_path = ''; - $home_path = trim($home_path, '/'); + $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); // Trim path info from the end and the leading home path from the // front. For path info requests, this leaves us with the requesting