diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 34ec0a52a..222fa1fc7 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -25,8 +25,12 @@ require_once('./optionhandler.php'); if ($_POST['submit']) { update_option('permalink_structure', $_POST['permalink_structure']); $permalink_structure = $_POST['permalink_structure']; + + update_option('category_base', $_POST['category_base']); + $category_base = $_POST['category_base']; } else { $permalink_structure = get_settings('permalink_structure'); + $category_base = get_settings('category_base'); } @@ -43,13 +47,42 @@ if ($_POST['submit']) {

WordPress offers you the ability to create a custom URI structure for your permalinks and archives. The following “tags” are available:

')?> - + +
+
%year%
+
+ 2004') ?> +
+
%monthnum%
+
+ 05') ?> +
+
%day%
+
+ 28') ?> +
+
%hour%
+
+ 15') ?> +
+
%minute%
+
+ 43') ?> +
+
%second%
+
+ 33') ?> +
+
%postname%
+
+ this-is-a-great-post” in the URI') ?> +
+
%post_id%
+
+ 423') ?> +
+
+ So for example a value like:

/archives/%year%/%monthnum%/%day%/%postname%/

would give you a permalink like:

@@ -58,10 +91,14 @@ if ($_POST['submit']) {

/index.php/archives/%year%/%monthnum%/%day%/%postname%/

If you use this option you can ignore the mod_rewrite rules.

') ?>
- Use the template tags above to create a virtual site structure:

') ?> +

+

FIXME[THIS WORDING MAKES NO SENSE]

+

+ +

diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 3e5114deb..c578e8648 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -803,6 +803,11 @@ function upgrade_110() { $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('home', 3, '', 8)"); } + // Option for category base + if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'category_base'")) { + $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '', 8)"); + } + // Delete unused options $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file'); foreach ($unusedoptions as $option) : diff --git a/wp-blog-header.php b/wp-blog-header.php index c489b95b1..d89dab486 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -50,7 +50,7 @@ if (! empty($_SERVER['PATH_INFO'])) { } } -$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'); +$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'); for ($i=0; $i5) - $where .= ' AND MONTH(post_date)='.substr($m,4,2); + $where .= ' AND MONTH(post_date)=' . substr($m, 4, 2); if (strlen($m)>7) - $where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2); + $where .= ' AND DAYOFMONTH(post_date)=' . substr($m, 6, 2); if (strlen($m)>9) - $where .= ' AND HOUR(post_date.)='.substr($m,8,2); + $where .= ' AND HOUR(post_date)=' . substr($m, 8, 2); if (strlen($m)>11) - $where .= ' AND MINUTE(post_date)='.substr($m,10,2); + $where .= ' AND MINUTE(post_date)=' . substr($m, 10, 2); if (strlen($m)>13) - $where .= ' AND SECOND(post_date)='.substr($m,12,2); - + $where .= ' AND SECOND(post_date)=' . substr($m, 12, 2); } -if ($year != '') { +if ('' != $hour) { + $hour = '' . intval($hour); + $where .= " AND HOUR(post_date)='$hour'"; +} + +if ('' != $minute) { + $minute = '' . intval($minute); + $where .= " AND MINUTE(post_date)='$minute'"; +} + +if ('' != $second) { + $second = '' . intval($second); + $where .= " AND SECOND(post_date)='$second'"; +} + +if ('' != $year) { $year = '' . intval($year); $where .= " AND YEAR(post_date)='$year'"; } -if ($monthnum != '') { +if ('' != $monthnum) { $monthnum = '' . intval($monthnum); $where .= " AND MONTH(post_date)='$monthnum'"; } -if ($day != '') { +if ('' != $day) { $day = '' . intval($day); $where .= " AND DAYOFMONTH(post_date)='$day'"; } -if ($name != '') { +if ('' != $name) { $name = preg_replace('/[^a-z0-9-]/', '', $name); $where .= " AND post_name = '$name'"; } -if ($w != '') { +if ('' != $w) { $w = ''.intval($w); $where .= " AND WEEK(post_date, 1)='$w'"; } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 193cb346f..47e3517cb 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -246,6 +246,9 @@ function url_to_postid($url = '') { '%year%', '%monthnum%', '%day%', + '%hour%', + '%minute%', + '%second%', '%postname%', '%post_id%' ); @@ -253,6 +256,9 @@ function url_to_postid($url = '') { '([0-9]{4})?', '([0-9]{1,2})?', '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', '([_0-9a-z-]+)?', '([0-9]+)?' ); @@ -282,6 +288,9 @@ function url_to_postid($url = '') { if ($year) $where .= " AND YEAR(post_date) = '" . intval($year) . "'"; if ($monthnum) $where .= " AND MONTH(post_date) = '" . intval($monthnum) . "'"; if ($day) $where .= " AND DAYOFMONTH(post_date) = '" . intval($day) . "'"; + if ($hour) $where .= " AND HOUR(post_date) = '" . intval($hour) . "'"; + if ($minute) $where .= " AND MINUTE(post_date) = '" . intval($minute) . "'"; + if ($second) $where .= " AND SECOND(post_date) = '" . intval($second) . "'"; if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' "; // Run the query to get the post ID: @@ -1187,29 +1196,41 @@ function rewrite_rules($matches = '', $permalink_structure = '') { } } - $rewritecode = array( - '%year%', - '%monthnum%', - '%day%', - '%postname%', - '%post_id%' - ); + $rewritecode = + array( + '%year%', + '%monthnum%', + '%day%', + '%hour%', + '%minute%', + '%second%', + '%postname%', + '%post_id%' + ); - $rewritereplace = array( - '([0-9]{4})?', - '([0-9]{1,2})?', - '([0-9]{1,2})?', - '([_0-9a-z-]+)?', - '([0-9]+)?' - ); + $rewritereplace = + array( + '([0-9]{4})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([0-9]{1,2})?', + '([_0-9a-z-]+)?', + '([0-9]+)?' + ); - $queryreplace = array ( - 'year=', - 'monthnum=', - 'day=', - 'name=', - 'p=' - ); + $queryreplace = + array ( + 'year=', + 'monthnum=', + 'day=', + 'hour=', + 'minute=', + 'second=', + 'name=', + 'p=' + ); $match = str_replace('/', '/?', $permalink_structure); @@ -1263,7 +1284,7 @@ function rewrite_rules($matches = '', $permalink_structure = '') { // Code for nice categories and authors, currently not very flexible $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); - $catmatch = $front . 'category/'; + $catmatch = get_settings( 'category_base' ) . '/'; $catmatch = preg_replace('|^/+|', '', $catmatch); $catfeedmatch = $catmatch . '(.*)/' . $feedregex; diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index de5893907..87a4fb49d 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -24,8 +24,9 @@ function get_category_link($echo = false, $category_id, $category_nicename) { $file = get_settings('home') . '/' . get_settings('blogfilename'); $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; } else { - if ('' == $category_nicename) $category_nicename = $cache_categories[$category_id]->category_nicename; - // Get any static stuff from the front + $category_nicename = $cache_categories[$category_id]->cat_name; + $category_nicename = preg_replace( '|[^a-z0-9-]|i', '', $category_nicename ); + // Get any static stuff from the front $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); $link = get_settings('home') . $front . 'category/'; if ($parent=$cache_categories[$category_id]->category_parent) $link .= get_category_parents($parent, FALSE, '/', TRUE); diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index 2943e48b9..dfd9cde95 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -50,6 +50,9 @@ function get_permalink($id=false) { '%year%', '%monthnum%', '%day%', + '%hour%', + '%minute%', + '%second%', '%postname%', '%post_id%' ); @@ -60,6 +63,9 @@ function get_permalink($id=false) { date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), + date('H', $unixtime), + date('i', $unixtime), + date('s', $unixtime), $post->post_name, $post->ID ); @@ -75,6 +81,9 @@ function get_permalink($id=false) { date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), + date('H', $unixtime), + date('i', $unixtime), + date('s', $unixtime), $idpost->post_name, $id );