From b66fe1442b50a1a0a31435d4cffde252a3e57195 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 27 Oct 2003 02:32:53 +0000 Subject: [PATCH] Updated get_permalink to take ID argument. git-svn-id: http://svn.automattic.com/wordpress/trunk@484 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 706d6ba97..0b00d4145 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; + } } }