mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Fixed %post_id% token handling. Fixed pingback link detection.
git-svn-id: http://svn.automattic.com/wordpress/trunk@640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
75f9641bb1
commit
c8604702fc
@ -104,19 +104,22 @@ $rewritecode = array(
|
|||||||
'%year%',
|
'%year%',
|
||||||
'%monthnum%',
|
'%monthnum%',
|
||||||
'%day%',
|
'%day%',
|
||||||
'%postname%'
|
'%postname%',
|
||||||
|
'%post_id%'
|
||||||
);
|
);
|
||||||
$rewritereplace = array(
|
$rewritereplace = array(
|
||||||
'([0-9]{4})?',
|
'([0-9]{4})?',
|
||||||
'([0-9]{1,2})?',
|
'([0-9]{1,2})?',
|
||||||
'([0-9]{1,2})?',
|
'([0-9]{1,2})?',
|
||||||
'([0-9a-z-]+)?'
|
'([0-9a-z-]+)?',
|
||||||
|
'([0-9]+)?'
|
||||||
);
|
);
|
||||||
$queryreplace = array (
|
$queryreplace = array (
|
||||||
'year=',
|
'year=',
|
||||||
'monthnum=',
|
'monthnum=',
|
||||||
'day=',
|
'day=',
|
||||||
'name='
|
'name=',
|
||||||
|
'p='
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,13 +493,15 @@ function url_to_postid($url = '') {
|
|||||||
'%year%',
|
'%year%',
|
||||||
'%monthnum%',
|
'%monthnum%',
|
||||||
'%day%',
|
'%day%',
|
||||||
'%postname%'
|
'%postname%',
|
||||||
|
'%post_id%'
|
||||||
);
|
);
|
||||||
$rewritereplace = array(
|
$rewritereplace = array(
|
||||||
'([0-9]{4})?',
|
'([0-9]{4})?',
|
||||||
'([0-9]{1,2})?',
|
'([0-9]{1,2})?',
|
||||||
'([0-9]{1,2})?',
|
'([0-9]{1,2})?',
|
||||||
'([0-9a-z-]+)?'
|
'([0-9a-z-]+)?',
|
||||||
|
'([0-9]+)?'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Turn the structure into a regular expression
|
// Turn the structure into a regular expression
|
||||||
@ -516,18 +518,23 @@ function url_to_postid($url = '') {
|
|||||||
$name = $tokens[1][$i];
|
$name = $tokens[1][$i];
|
||||||
$value = $values[$i+1];
|
$value = $values[$i+1];
|
||||||
|
|
||||||
// Create a variable named $year, $monthnum, $day, or $postname:
|
// Create a variable named $year, $monthnum, $day, $postname, or $post_id:
|
||||||
$$name = $value;
|
$$name = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a WHERE clause, making the values safe along the way:
|
// If using %post_id%, we're done:
|
||||||
|
if (intval($post_id)) return intval($post_id);
|
||||||
|
|
||||||
|
// Otherwise, build a WHERE clause, making the values safe along the way:
|
||||||
if ($year) $where .= " AND YEAR(post_date) = " . intval($year);
|
if ($year) $where .= " AND YEAR(post_date) = " . intval($year);
|
||||||
if ($monthnum) $where .= " AND MONTH(post_date) = " . intval($monthnum);
|
if ($monthnum) $where .= " AND MONTH(post_date) = " . intval($monthnum);
|
||||||
if ($day) $where .= " AND DAYOFMONTH(post_date) = " . intval($day);
|
if ($day) $where .= " AND DAYOFMONTH(post_date) = " . intval($day);
|
||||||
if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
|
if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
|
||||||
|
|
||||||
// Run the query to get the post ID:
|
// Run the query to get the post ID:
|
||||||
return intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
|
$id = intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
|
||||||
|
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,7 +419,8 @@ function get_permalink($id=false) {
|
|||||||
date('Y', $unixtime),
|
date('Y', $unixtime),
|
||||||
date('n', $unixtime),
|
date('n', $unixtime),
|
||||||
date('j', $unixtime),
|
date('j', $unixtime),
|
||||||
$post->post_name
|
$post->post_name,
|
||||||
|
$post->ID
|
||||||
);
|
);
|
||||||
return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||||
} else { // if they're not using the fancy permalink option
|
} else { // if they're not using the fancy permalink option
|
||||||
|
Loading…
Reference in New Issue
Block a user