mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +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%',
|
||||
'%monthnum%',
|
||||
'%day%',
|
||||
'%postname%'
|
||||
'%postname%',
|
||||
'%post_id%'
|
||||
);
|
||||
$rewritereplace = array(
|
||||
'([0-9]{4})?',
|
||||
'([0-9]{1,2})?',
|
||||
'([0-9]{1,2})?',
|
||||
'([0-9a-z-]+)?'
|
||||
'([0-9a-z-]+)?',
|
||||
'([0-9]+)?'
|
||||
);
|
||||
$queryreplace = array (
|
||||
'year=',
|
||||
'monthnum=',
|
||||
'day=',
|
||||
'name='
|
||||
'name=',
|
||||
'p='
|
||||
);
|
||||
|
||||
|
||||
|
@ -493,13 +493,15 @@ function url_to_postid($url = '') {
|
||||
'%year%',
|
||||
'%monthnum%',
|
||||
'%day%',
|
||||
'%postname%'
|
||||
'%postname%',
|
||||
'%post_id%'
|
||||
);
|
||||
$rewritereplace = array(
|
||||
'([0-9]{4})?',
|
||||
'([0-9]{1,2})?',
|
||||
'([0-9]{1,2})?',
|
||||
'([0-9a-z-]+)?'
|
||||
'([0-9a-z-]+)?',
|
||||
'([0-9]+)?'
|
||||
);
|
||||
|
||||
// Turn the structure into a regular expression
|
||||
@ -516,18 +518,23 @@ function url_to_postid($url = '') {
|
||||
$name = $tokens[1][$i];
|
||||
$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;
|
||||
}
|
||||
|
||||
// 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 ($monthnum) $where .= " AND MONTH(post_date) = " . intval($monthnum);
|
||||
if ($day) $where .= " AND DAYOFMONTH(post_date) = " . intval($day);
|
||||
if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
|
||||
|
||||
// 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('n', $unixtime),
|
||||
date('j', $unixtime),
|
||||
$post->post_name
|
||||
$post->post_name,
|
||||
$post->ID
|
||||
);
|
||||
return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||
} else { // if they're not using the fancy permalink option
|
||||
|
Loading…
Reference in New Issue
Block a user