From 46cb0545c25359a3c8cd6a926f30c7f236aaaded Mon Sep 17 00:00:00 2001 From: saxmatt Date: Thu, 4 Dec 2003 22:53:15 +0000 Subject: [PATCH] Alpha multiple category support. git-svn-id: http://svn.automattic.com/wordpress/trunk@565 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2-include/b2template.functions.php | 81 ++++++++++++++++++----------- index.php | 38 +++++++------- wp-admin/upgrade-072-to-080.php | 41 ++++++++++++--- wp-admin/wp-options-permalink.php | 4 +- wp-layout.css | 22 ++++++-- 5 files changed, 125 insertions(+), 61 deletions(-) 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 ''; + } else { + $i = 0; + foreach ($categories as $category) { + if (0 < $i) echo $seperator . ' '; + echo "$category->cat_name"; + ++$i; + } + } +} + function the_category_rss() { echo convert_chars(strip_tags(get_the_category()), 'xml'); } @@ -1252,18 +1282,7 @@ function the_category_unicode() { echo convert_chars($category, 'unicode'); } -function get_the_category() { - global $post, $tablecategories, $querycount, $cache_categories, $use_cache, $wpdb; - $cat_ID = $post->post_category; - if ((empty($cache_categories[$cat_ID])) OR (!$use_cache)) { - $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'"); - ++$querycount; - $cache_categories[$cat_ID] = $cat_name; - } else { - $cat_name = $cache_categories[$cat_ID]; - } - return(stripslashes($cat_name)); -} + function get_the_category_by_ID($cat_ID) { global $tablecategories, $querycount, $cache_categories, $use_cache, $wpdb; diff --git a/index.php b/index.php index 607a9cc1ed..32498d54d5 100644 --- a/index.php +++ b/index.php @@ -32,28 +32,28 @@ require_once($abspath.'wp-links/links.php');
+ ',''); ?> - -

- - [] @ -

- -
- -
- - - - + +
+

+
Filed under: @
+ +
+ +
+ + + + +

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!

Step 1

-

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.

    Use the template tags above to create a virtual site structure:

    diff --git a/wp-layout.css b/wp-layout.css index bc6901c069..94a4bfe9c7 100644 --- a/wp-layout.css +++ b/wp-layout.css @@ -55,7 +55,7 @@ cite { h2 { border-bottom: 1px dotted #ccc; font: 80% "Times New Roman", Times, serif; - letter-spacing: 0.5em; + letter-spacing: 0.2em; margin: 15px 0 2px 0; padding-bottom: 2px; } @@ -63,7 +63,6 @@ h2 { h3 { border-bottom: dotted 1px #eee; font-family: "Times New Roman", Times, serif; - letter-spacing: -0.05em; margin-top: 0; } @@ -95,12 +94,29 @@ p, li, .feedback { text-align: right; } +.meta { + font-size: .75em; +} + .meta, .meta a { color: #808080; - font-size: small; font-weight: normal; letter-spacing: 0; } +.meta ul { + display: inline; + margin: 0; + padding: 0; + list-style: none; +} + +.meta li { + display: inline; +} + +.storytitle { + margin: 0; +} .storytitle a { text-decoration: none;