More url_to_postid() fixes.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-05-18 02:27:43 +00:00
parent a95277a8c5
commit ec0f80aa43
1 changed files with 9 additions and 5 deletions

View File

@ -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;