From 239462c3268996ad78e234f0ba5d413413094970 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 18 May 2005 02:27:43 +0000 Subject: [PATCH] More url_to_postid() fixes. git-svn-id: https://develop.svn.wordpress.org/trunk@2611 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 82dc2585a2..012b04877c 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -172,7 +172,7 @@ function get_usernumposts($userid) { // examine a url (supposedly from this blog) and try to // determine the post ID it represents. -function url_to_postid($url = '') { +function url_to_postid($url) { global $wp_rewrite; // First, check to see if there is a 'p=N' or 'page_id=N' to match against: @@ -187,11 +187,15 @@ function url_to_postid($url = '') { return 0; $req_uri = $url; - $home_path = parse_url(get_settings('home')); - $home_path = $home_path['path']; - $req_uri = str_replace(get_settings('home'), '', $req_uri); - $req_uri = str_replace($home_path, '', $req_uri); + if ( false !== strpos($req_uri, get_settings('home')) ) { + $req_uri = str_replace(get_settings('home'), '', $req_uri); + } else { + $home_path = parse_url(get_settings('home')); + $home_path = $home_path['path']; + $req_uri = str_replace($home_path, '', $req_uri); + } + $req_uri = trim($req_uri, '/'); $request = $req_uri;