From 8068b213e12b0c68eebda0fa43b23a48ec24caeb Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Mon, 27 Oct 2003 02:32:53 +0000 Subject: [PATCH] Updated get_permalink to take ID argument. git-svn-id: https://develop.svn.wordpress.org/trunk@484 602fd350-edb4-49c9-b593-d223f7449a82 --- b2-include/b2template.functions.php | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 706d6ba97d..0b00d4145a 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -1406,16 +1406,16 @@ function trackback_rdf($timezone = 0) { /***** Permalink tags *****/ function get_permalink($id=false) { - global $post; + global $post, $wpdb, $tableposts; + $rewritecode = array( + '%year%', + '%monthnum%', + '%day%', + '%postname%' + ); if (!$id) { - if (get_settings('permalink_structure')) { + if ('' != get_settings('permalink_structure')) { $unixtime = strtotime($post->post_date); - $rewritecode = array( - '%year%', - '%monthnum%', - '%day%', - '%postname%' - ); $rewritereplace = array( date('Y', $unixtime), date('n', $unixtime), @@ -1426,6 +1426,20 @@ function get_permalink($id=false) { } else { // if they're not using the fancy permalink option 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; + } } }