+ + +
', 'number'); ?> + +
diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 9d63ca3ee3..b6fa1d1ccb 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -416,7 +416,8 @@ function get_permalink($id=false) { '%year%', '%monthnum%', '%day%', - '%postname%' + '%postname%', + '%post_id%' ); if (!$id) { if ('' != get_settings('permalink_structure')) { @@ -440,7 +441,8 @@ function get_permalink($id=false) { date('Y', $unixtime), date('n', $unixtime), date('j', $unixtime), - $idpost->post_name + $idpost->post_name, + $id ); return $siteurl . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); } else { @@ -1223,26 +1225,54 @@ function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Ne /***** Category tags *****/ -function get_category_link($echo = false, $file='') { - global $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename; - $cat_ID = $post->post_category; - if ($file == '') { - $file = "$siteurl/$blogfilename"; - } - if ('http:' != substr($file,0,5)) { - $file = "$siteurl/$file"; - } - $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; - if ($echo) - echo($link); - return $link; +function get_the_category() { + global $post, $tablecategories, $tablepost2cat, $wpdb; + $categories = $wpdb->get_results(" + SELECT category_id, cat_name, category_nicename + FROM $tablecategories, $tablepost2cat + WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID + "); + + return $categories; } -function the_category() { - $category = get_the_category(); - $category = apply_filters('the_category', $category); - echo convert_chars($category, 'html'); +function get_category_link($echo = false, $category_id) { + global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $siteurl, $blogfilename; + $cat_ID = $category_id; + $permalink_structure = get_settings('permalink_structure'); + + if ('' == $permalink_structure) { + $file = "$siteurl/$blogfilename"; + $link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID; + } else { + $category_nicename = $wpdb->get_var("SELECT category_nicename FROM $tablecategories WHERE cat_ID = $category_id"); + // Get any static stuff from the front + $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); + $link = $front . 'category/' . $category_nicename; + } + + if ($echo) echo $link; + return $link; } + +function the_category($seperator = '') { + $categories = get_the_category(); + if ('' == $seperator) { + echo '
Sorry, no posts matched your criteria.
diff --git a/wp-admin/upgrade-072-to-080.php b/wp-admin/upgrade-072-to-080.php index 7bd5cbeeea..056c81ca9c 100644 --- a/wp-admin/upgrade-072-to-080.php +++ b/wp-admin/upgrade-072-to-080.php @@ -42,14 +42,14 @@ switch($step) { case 0: ?>This file seeks to upgrade you to the latest version of WordPress. If you are upgrading from any version other than .72, you should run the previous upgrade files to get everything up to date before running this.
-If you’re all ready, let's go!
+If you’re all ready, let's go!
If it isn’t there already, let’s add a field new to this version.
+If it isn’t there already, let’s add fields new to this version.
hide_errors(); $wpdb->query("ALTER TABLE `$tableposts` ADD INDEX (`post_name`)"); $wpdb->show_errors(); + + + +// Create category_nicename field +$query = "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL"; +maybe_add_column($tablecategories, 'category_nicename', $query); + +// Create index if it isn't there already, suppress errors if it is +$wpdb->hide_errors(); +$wpdb->query("ALTER TABLE `$tablecategories` ADD INDEX (`category_nicename`)"); +$wpdb->show_errors(); + +// Create category description field +$query = "ALTER TABLE `$tablecategories` ADD `category_description` TEXT NOT NULL"; +maybe_add_column($tablecategories, 'category_description', $query); + +// Create category parent field +$query = "ALTER TABLE `$tablecategories` ADD `category_parent` INT(4) NOT NULL"; +maybe_add_column($tablecategories, 'category_parent', $query); ?> -Done.
-Now let's populate the new field.
+Groovy.
+Now let’s populate the new fields.
Working get_results("SELECT cat_ID, cat_name, category_nicename FROM $tablecategories"); +foreach ($categories as $category) { + if ('' == $category->category_nicename) { + $newtitle = sanitize_title($category->cat_name); + $wpdb->query("UPDATE $tablecategories SET category_nicename = '$newtitle' WHERE cat_ID = $category->cat_ID"); + } + echo ' .'; + flush(); +} + if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'permalink_structure'")) { // If it's not already there $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`) @@ -84,7 +113,7 @@ if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = ' } ?> Done with the name game. Now a little option action.
-Now on to step 2.
+Now on to step 2.
show_errors(); ?>Comment spammers should now watch out for you.
-See, that didn’t hurt a bit (again). Now on to the final step.
+See, that didn’t hurt a bit (again). Now on to the final step.
%monthnum% --- Two digit month, for example 05
%day% --- Day of the month, for example 28%postname% --- A sanitized version of the title of the post. So "This Is A Great Post!" becomes "this-is-a-great-post" %category% --- Category name of the post. For example "general". Not done yet. %post_id% --- The unique ID # of the post. So for example a value like /%year%/%monthnum%/%day%/%postname%/ could give you a permalink like /2003/05/23/my-cheese-sandwich . For this to work you'll need mod_rewrite installed on your server for the rule generation rule to work below. In the future there may be other options.
So for example a value like /archives/%year%/%monthnum%/%day%/%postname%/ could give you a permalink like /archives/2003/05/23/my-cheese-sandwich/ . For this to work you'll need mod_rewrite installed on your server for the rule generation rule to work below. In the future there may be other options.