Make WordPress Core

Changeset 470


Ignore:
Timestamp:
10/26/2003 05:25:26 AM (22 years ago)
Author:
saxmatt
Message:

Alpha functionality of new permalink structure as per previous discussions.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2template.functions.php

    r469 r470  
    14061406
    14071407/***** Permalink tags *****/
     1408function get_permalink($id=false) {
     1409    global $post;
     1410    if (!$id) {
     1411        if (get_settings('permalink_structure')) {
     1412            $unixtime = strtotime($post->post_date);
     1413            $rewritecode = array(
     1414                '%year%',
     1415                '%monthnum%',
     1416                '%day%',
     1417                '%postname%'
     1418            );
     1419            $rewritereplace = array(
     1420                date('Y', $unixtime),
     1421                date('n', $unixtime),
     1422                date('j', $unixtime),
     1423                $post->post_name
     1424            );
     1425            return str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
     1426        } else { // if they're not using the fancy permalink option
     1427            return $file.$querystring_start.'p'.$querystring_equal.$post->ID;
     1428        }
     1429    }
     1430}
    14081431
    14091432function permalink_anchor($mode = 'id') {
     
    14351458            break;
    14361459    }
    1437     $archive_mode = get_settings('archive_mode');
    1438     switch($archive_mode) {
    1439         case 'daily':
    1440             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;
    1441             break;
    1442         case 'monthly':
    1443             echo $file.$querystring_start.'m'.$querystring_equal.substr($post->post_date,0,4).substr($post->post_date,5,2).'#post-'.$anchor;
    1444             break;
    1445         case 'weekly':
    1446             if((!isset($cacheweekly)) || (empty($cacheweekly[$postdata['Date']]))) {
    1447                 $cacheweekly[$post->post_date] = $wpdb->get_var("SELECT WEEK('$post->post_date')");
    1448                 ++$querycount;
    1449             }
    1450             echo $file.$querystring_start.'m'.$querystring_equal.substr($post->post_date,0,4).$querystring_separator.'w'.$querystring_equal.$cacheweekly[$post->post_date].'#post-'.$anchor;
    1451             break;
    1452         case 'postbypost':
    1453             echo $file.$querystring_start.'p'.$querystring_equal.$id;
    1454             break;
    1455     }
     1460    echo get_permalink();
    14561461}
    14571462
  • trunk/blog.header.php

    r404 r470  
    1414require_once ($curpath.$b2inc.'/xmlrpcs.inc');
    1515
    16 $b2varstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby');
     16$b2varstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'monthnum');
    1717
    1818    for ($i=0; $i<count($b2varstoreset); $i += 1) {
     
    8383}
    8484
     85if ($year != '') {
     86    $year = '' . intval($year);
     87    $where .= ' AND YEAR(post_date)=' . $year;
     88}
     89
     90if ($monthnum != '') {
     91    $monthnum = '' . intval($monthnum);
     92    $where .= ' AND MONTH(post_date)=' . $monthnum;
     93}
     94
     95if ($day != '') {
     96    $hay = '' . intval($day);
     97    $where .= ' AND DAYOFMONTH(post_date)=' . $day;
     98}
     99
     100if ($name != '') {
     101    $name = preg_replace('/[^a-z0-9-]/', '', $name);
     102    $where .= " AND post_name = '$name'";
     103}
     104
    85105if ($w != '') {
    86106    $w = ''.intval($w);
    87     $where .= ' AND WEEK(post_date,1)='.$w;
     107    $where .= ' AND WEEK(post_date, 1)=' . $w;
    88108}
    89109
     
    207227}
    208228
    209 if ( !empty($postend) && ($postend > $poststart) && (!$m) &&(!$w) && (!$whichcat) && (!$s) && (!$p)) {
     229if ( !empty($postend) && ($postend > $poststart) && (!$m) && !$month && !$year && !$day &&(!$w) && (!$whichcat) && (!$s) && (!$p)) {
    210230    if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) {
    211231        $poststart = intval($poststart);
     
    244264        }
    245265    }
    246     elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author)) {
     266    elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author) || $month || $year || $day) {
    247267        $limits = '';
    248268    }
     
    282302}
    283303
    284 //error_log("$request");
    285 //echo $request;
     304// error_log("$request");
     305// echo $request;
    286306$posts = $wpdb->get_results($request);
     307
     308if (1 == count($posts)) {
     309    $more = 1; $c = 1; $single = 1;
     310}
    287311?>
  • trunk/index.php

    r415 r470  
    5656<?php include($abspath . 'b2comments.php'); ?>
    5757
    58 <?php } } // end foreach, end if any posts ?>
    59 
     58<?php } } else { // end foreach, end if any posts ?>
     59<p>Sorry, no posts matched your criteria.</p>
     60<?php } ?>
    6061</div>
    6162
  • trunk/wp-admin/upgrade-072-to-073.php

    r467 r470  
    66if (!$step) $step = 0;
    77if (!step) $step = 0;
     8update_option('blogdescription', 'hahahah');
    89?>
    910<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    7778}
    7879
     80$wpdb->query("INSERT INTO `$tableoptions` (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`) VALUES ('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', 'How the permalinks for your site are constructed.', '8');");
    7981?>
    8082  <strong>Done.</strong> </p>
  • trunk/wp-admin/wp-options.php

    r344 r470  
    120120    } // end for each group
    121121?>
     122<li><a href="wp-options-permalink.php">Permalinks</a></li>
    122123</ul>
    123124    <br clear="all" />
Note: See TracChangeset for help on using the changeset viewer.