mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-17 10:04:49 +02:00
Updated get_permalink to take ID argument.
git-svn-id: http://svn.automattic.com/wordpress/trunk@484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5751e4c587
commit
b66fe1442b
@ -1406,16 +1406,16 @@ function trackback_rdf($timezone = 0) {
|
|||||||
|
|
||||||
/***** Permalink tags *****/
|
/***** Permalink tags *****/
|
||||||
function get_permalink($id=false) {
|
function get_permalink($id=false) {
|
||||||
global $post;
|
global $post, $wpdb, $tableposts;
|
||||||
|
$rewritecode = array(
|
||||||
|
'%year%',
|
||||||
|
'%monthnum%',
|
||||||
|
'%day%',
|
||||||
|
'%postname%'
|
||||||
|
);
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
if (get_settings('permalink_structure')) {
|
if ('' != get_settings('permalink_structure')) {
|
||||||
$unixtime = strtotime($post->post_date);
|
$unixtime = strtotime($post->post_date);
|
||||||
$rewritecode = array(
|
|
||||||
'%year%',
|
|
||||||
'%monthnum%',
|
|
||||||
'%day%',
|
|
||||||
'%postname%'
|
|
||||||
);
|
|
||||||
$rewritereplace = array(
|
$rewritereplace = array(
|
||||||
date('Y', $unixtime),
|
date('Y', $unixtime),
|
||||||
date('n', $unixtime),
|
date('n', $unixtime),
|
||||||
@ -1426,6 +1426,20 @@ function get_permalink($id=false) {
|
|||||||
} else { // if they're not using the fancy permalink option
|
} else { // if they're not using the fancy permalink option
|
||||||
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
|
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
|
||||||
}
|
}
|
||||||
|
} else { // if an ID is given
|
||||||
|
$post = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
|
||||||
|
if ('' != get_settings('permalink_structure')) {
|
||||||
|
$unixtime = strtotime($post->post_date);
|
||||||
|
$rewritereplace = array(
|
||||||
|
date('Y', $unixtime),
|
||||||
|
date('n', $unixtime),
|
||||||
|
date('j', $unixtime),
|
||||||
|
$post->post_name
|
||||||
|
);
|
||||||
|
return str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
|
||||||
|
} else {
|
||||||
|
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user