Make WordPress Core

Changeset 1227


Ignore:
Timestamp:
05/05/2004 07:34:41 AM (20 years ago)
Author:
saxmatt
Message:

Some style cleanup. Category base and additional URI options from Jay McCarthy.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r1203 r1227  
    2626    update_option('permalink_structure', $_POST['permalink_structure']);
    2727    $permalink_structure = $_POST['permalink_structure'];
     28
     29    update_option('category_base', $_POST['category_base']);
     30    $category_base = $_POST['category_base'];
    2831} else {
    2932    $permalink_structure = get_settings('permalink_structure');
     33    $category_base = get_settings('category_base');
    3034}
    3135
     
    4448  <h2><?php _e('Edit Permalink Structure') ?></h2>
    4549  <?php _e('<p>WordPress offers you the ability to create a custom URI structure for your permalinks and archives. The following &#8220;tags&#8221; are available:</p>')?>
    46   <ul>
    47     <li><code>%year%</code> --- <?php _e('The year of the post, 4 digits, for example <code>2004</code>') ?> </li>
    48     <li><code>%monthnum%</code> --- <?php _e('Month of the year, for example <code>05</code>') ?></li>
    49     <li><code>%day% </code>--- <?php _e('Day of the month, for example <code>28</code>') ?></li>
    50     <li><code>%postname%</code> --- <?php _e('A sanitized version of the title of the post. So &#8220;This Is A Great Post!&#8221; becomes &#8220;<code>this-is-a-great-post</code>&#8221; in the URI') ?> </li>
    51     <li><code>%post_id%</code> --- <?php _e('The unique ID # of the post, for example <code>423</code>') ?></li>
    52   </ul>
     50
     51<dl>
     52    <dt><code>%year%</code></dt>
     53    <dd>
     54        <?php _e('The year of the post, 4 digits, for example <code>2004</code>') ?>
     55    </dd>
     56    <dt><code>%monthnum%</code></dt>
     57    <dd>
     58        <?php _e('Month of the year, for example <code>05</code>') ?>
     59    </dd>
     60    <dt><code>%day%</code></dt>
     61    <dd>
     62        <?php _e('Day of the month, for example <code>28</code>') ?>
     63    </dd>
     64    <dt><code>%hour%</code></dt>
     65    <dd>
     66        <?php _e('Hour of the day, for example <code>15</code>') ?>
     67    </dd>
     68    <dt><code>%minute%</code></dt>
     69    <dd>
     70        <?php _e('Minute of the hour, for example <code>43</code>') ?>
     71    </dd>
     72    <dt><code>%second%</code></dt>
     73    <dd>
     74        <?php _e('Second of the minute, for example <code>33</code>') ?>
     75    </dd>
     76    <dt><code>%postname%</code></dt>
     77    <dd>
     78        <?php _e('A sanitized version of the title of the post. So &#8220;This Is A Great Post!&#8221; becomes &#8220;<code>this-is-a-great-post</code>&#8221; in the URI') ?>
     79    </dd>
     80    <dt><code>%post_id%</code></dt>
     81    <dd>
     82        <?php _e('The unique ID # of the post, for example <code>423</code>') ?>
     83    </dd>
     84</dl>
     85
    5386  <?php _e('<p>So for example a value like:</p>
    5487  <p><code>/archives/%year%/%monthnum%/%day%/%postname%/</code> </p>
     
    5992  <p>If you use this option you can ignore the mod_rewrite rules. </p>') ?>
    6093  <form name="form" action="options-permalink.php" method="post">
    61     <?php _e('<p>Use the template tags above to create a virtual site structure:</p>') ?>
     94    <p><?php _e('Use the template tags above to create a virtual site structure:') ?></p>
    6295    <p>
    6396      <input name="permalink_structure" type="text" style="width: 98%;" value="<?php echo $permalink_structure; ?>" />
    6497    </p>
     98    <p><?php _e('Enter a path without templates for your categories:') ?> FIXME[THIS WORDING MAKES NO SENSE]</p>
     99    <p>
     100  <input name="category_base" type="text" style="width: 98%;" value="<?php echo $category_base; ?>" />
     101     </p>
    65102    <p class="submit">
    66103      <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>">
  • trunk/wp-admin/upgrade-functions.php

    r1206 r1227  
    804804    }
    805805
     806    // Option for category base
     807    if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'category_base'")) {
     808        $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '', 8)");
     809    }
     810
    806811    // Delete unused options
    807812    $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file');
  • trunk/wp-blog-header.php

    r1186 r1227  
    5151}
    5252
    53 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name', 'feed', 'author_name');
     53$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name');
    5454
    5555    for ($i=0; $i<count($wpvarstoreset); $i += 1) {
     
    133133$wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
    134134
    135 // if a month is specified in the querystring, load that month
    136 if ($m != '') {
    137     $m = ''.intval($m);
    138     $where .= ' AND YEAR(post_date)='.substr($m,0,4);
     135// If a month is specified in the querystring, load that month
     136if ('' != $m) {
     137    $m = '' . preg_replace('|[^0-9]|', '', $m);
     138    $where .= ' AND YEAR(post_date)=' . substr($m, 0, 4);
    139139    if (strlen($m)>5)
    140         $where .= ' AND MONTH(post_date)='.substr($m,4,2);
     140        $where .= ' AND MONTH(post_date)=' . substr($m, 4, 2);
    141141    if (strlen($m)>7)
    142         $where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2);
     142        $where .= ' AND DAYOFMONTH(post_date)=' . substr($m, 6, 2);
    143143    if (strlen($m)>9)
    144         $where .= ' AND HOUR(post_date.)='.substr($m,8,2);
     144        $where .= ' AND HOUR(post_date)=' . substr($m, 8, 2);
    145145    if (strlen($m)>11)
    146         $where .= ' AND MINUTE(post_date)='.substr($m,10,2);
     146        $where .= ' AND MINUTE(post_date)=' . substr($m, 10, 2);
    147147    if (strlen($m)>13)
    148         $where .= ' AND SECOND(post_date)='.substr($m,12,2);
    149 
    150 }
    151 
    152 if ($year != '') {
     148        $where .= ' AND SECOND(post_date)=' . substr($m, 12, 2);
     149}
     150
     151if ('' != $hour) {
     152    $hour = '' . intval($hour);
     153    $where .= " AND HOUR(post_date)='$hour'";
     154}
     155
     156if ('' != $minute) {
     157    $minute = '' . intval($minute);
     158    $where .= " AND MINUTE(post_date)='$minute'";
     159}
     160
     161if ('' != $second) {
     162    $second = '' . intval($second);
     163    $where .= " AND SECOND(post_date)='$second'";
     164}
     165
     166if ('' != $year) {
    153167    $year = '' . intval($year);
    154168    $where .= " AND YEAR(post_date)='$year'";
    155169}
    156170
    157 if ($monthnum != '') {
     171if ('' != $monthnum) {
    158172    $monthnum = '' . intval($monthnum);
    159173    $where .= " AND MONTH(post_date)='$monthnum'";
    160174}
    161175
    162 if ($day != '') {
     176if ('' != $day) {
    163177    $day = '' . intval($day);
    164178    $where .= " AND DAYOFMONTH(post_date)='$day'";
    165179}
    166180
    167 if ($name != '') {
     181if ('' != $name) {
    168182    $name = preg_replace('/[^a-z0-9-]/', '', $name);
    169183    $where .= " AND post_name = '$name'";
    170184}
    171185
    172 if ($w != '') {
     186if ('' != $w) {
    173187    $w = ''.intval($w);
    174188    $where .= " AND WEEK(post_date, 1)='$w'";
  • trunk/wp-includes/functions.php

    r1226 r1227  
    247247        '%monthnum%',
    248248        '%day%',
     249        '%hour%',
     250        '%minute%',
     251        '%second%',
    249252        '%postname%',
    250253        '%post_id%'
     
    254257        '([0-9]{1,2})?',
    255258        '([0-9]{1,2})?',
     259        '([0-9]{1,2})?',
     260        '([0-9]{1,2})?',
     261        '([0-9]{1,2})?',
    256262        '([_0-9a-z-]+)?',
    257263        '([0-9]+)?'
     
    283289    if ($monthnum) $where .= " AND MONTH(post_date) = '" . intval($monthnum) . "'";
    284290    if ($day) $where .= " AND DAYOFMONTH(post_date) = '" . intval($day) . "'";
     291    if ($hour) $where .= " AND HOUR(post_date) = '" . intval($hour) . "'";
     292    if ($minute) $where .= " AND MINUTE(post_date) = '" . intval($minute) . "'";
     293    if ($second) $where .= " AND SECOND(post_date) = '" . intval($second) . "'";
    285294    if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
    286295
     
    11881197    }
    11891198
    1190     $rewritecode = array(
    1191                          '%year%',
    1192                          '%monthnum%',
    1193                          '%day%',
    1194                          '%postname%',
    1195                          '%post_id%'
    1196                          );
    1197 
    1198     $rewritereplace = array(
    1199                             '([0-9]{4})?',
    1200                             '([0-9]{1,2})?',
    1201                             '([0-9]{1,2})?',
    1202                             '([_0-9a-z-]+)?',
    1203                             '([0-9]+)?'
    1204                             );
    1205 
    1206     $queryreplace = array (
    1207                            'year=',
    1208                            'monthnum=',
    1209                            'day=',
    1210                            'name=',
    1211                            'p='
    1212                            );
     1199    $rewritecode =
     1200    array(
     1201    '%year%',
     1202    '%monthnum%',
     1203    '%day%',
     1204    '%hour%',
     1205    '%minute%',
     1206    '%second%',
     1207    '%postname%',
     1208    '%post_id%'
     1209    );
     1210
     1211    $rewritereplace =
     1212    array(
     1213    '([0-9]{4})?',
     1214    '([0-9]{1,2})?',
     1215    '([0-9]{1,2})?',
     1216    '([0-9]{1,2})?',
     1217    '([0-9]{1,2})?',
     1218    '([0-9]{1,2})?',
     1219    '([_0-9a-z-]+)?',
     1220    '([0-9]+)?'
     1221    );
     1222
     1223    $queryreplace =
     1224    array (
     1225    'year=',
     1226    'monthnum=',
     1227    'day=',
     1228    'hour=',
     1229    'minute=',
     1230    'second=',
     1231    'name=',
     1232    'p='
     1233    );
    12131234
    12141235
     
    12641285    // Code for nice categories and authors, currently not very flexible
    12651286    $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
    1266     $catmatch = $front . 'category/';
     1287    $catmatch = get_settings( 'category_base' ) . '/';
    12671288    $catmatch = preg_replace('|^/+|', '', $catmatch);
    12681289   
  • trunk/wp-includes/template-functions-category.php

    r1217 r1227  
    2525        $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
    2626    } else {
    27         if ('' == $category_nicename) $category_nicename = $cache_categories[$category_id]->category_nicename;
    28         // Get any static stuff from the front
     27        $category_nicename = $cache_categories[$category_id]->cat_name;
     28        $category_nicename = preg_replace( '|[^a-z0-9-]|i', '', $category_nicename );
     29        // Get any static stuff from the front
    2930        $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
    3031        $link = get_settings('home') . $front . 'category/';
  • trunk/wp-includes/template-functions-links.php

    r1203 r1227  
    5151        '%monthnum%',
    5252        '%day%',
     53        '%hour%',
     54        '%minute%',
     55        '%second%',
    5356        '%postname%',
    5457        '%post_id%'
     
    6164                date('m', $unixtime),
    6265                date('d', $unixtime),
     66                date('H', $unixtime),
     67                date('i', $unixtime),
     68                date('s', $unixtime),
    6369                $post->post_name,
    6470                $post->ID
     
    7682                date('m', $unixtime),
    7783                date('d', $unixtime),
     84                date('H', $unixtime),
     85                date('i', $unixtime),
     86                date('s', $unixtime),
    7887                $idpost->post_name,
    7988                $id
Note: See TracChangeset for help on using the changeset viewer.