Alpha functionality of new permalink structure as per previous discussions.

git-svn-id: https://develop.svn.wordpress.org/trunk@470 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg
2003-10-26 05:25:26 +00:00
parent 53ed0b4b61
commit 15bfb2b1fb
6 changed files with 203 additions and 27 deletions
+24 -19
View File
@@ -1405,6 +1405,29 @@ function trackback_rdf($timezone = 0) {
/***** Permalink tags *****/
function get_permalink($id=false) {
global $post;
if (!$id) {
if (get_settings('permalink_structure')) {
$unixtime = strtotime($post->post_date);
$rewritecode = array(
'%year%',
'%monthnum%',
'%day%',
'%postname%'
);
$rewritereplace = array(
date('Y', $unixtime),
date('n', $unixtime),
date('j', $unixtime),
$post->post_name
);
return str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
} else { // if they're not using the fancy permalink option
return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
}
}
}
function permalink_anchor($mode = 'id') {
global $id, $post;
@@ -1434,25 +1457,7 @@ function permalink_link($file='', $mode = 'id') {
$anchor = $id;
break;
}
$archive_mode = get_settings('archive_mode');
switch($archive_mode) {
case 'daily':
echo $file.$querystring_start.'m'.$querystring_equal.substr($post->post_date,0,4).substr($post->post_date,5,2).substr($postdata['Date'],8,2).'#post-'.$anchor;
break;
case 'monthly':
echo $file.$querystring_start.'m'.$querystring_equal.substr($post->post_date,0,4).substr($post->post_date,5,2).'#post-'.$anchor;
break;
case 'weekly':
if((!isset($cacheweekly)) || (empty($cacheweekly[$postdata['Date']]))) {
$cacheweekly[$post->post_date] = $wpdb->get_var("SELECT WEEK('$post->post_date')");
++$querycount;
}
echo $file.$querystring_start.'m'.$querystring_equal.substr($post->post_date,0,4).$querystring_separator.'w'.$querystring_equal.$cacheweekly[$post->post_date].'#post-'.$anchor;
break;
case 'postbypost':
echo $file.$querystring_start.'p'.$querystring_equal.$id;
break;
}
echo get_permalink();
}
function permalink_single($file='') {