[wp-hackers] Category Order

Marco Antônio Konopacki - Projeto RHODES marcok at redesol.org
Wed Apr 18 16:25:08 GMT 2007


Hi all,

It's my first post in this list and I'd like to present myself: My name 
is Marco, developer from Brazil and a Wordpress enthusiastic :D I've 
contributed for many OpenSource projects like Mono (www.go-mono.com) and 
others Brazilian projects (like JSenna, Java MVC www.jsenna.com.br).

Well. I'm writing to post one patch that I'm wrote to allow users sort 
categories by an user defined order.

I don't know if it's a priority to Wordpress project, but it is a cool 
functionality ;)

Sorry send by mail this patches, but the submit patch link is broken.

Regards..

-- 

Marco Antônio Konopacki.
Presidente da RedeSol - Rede de Excelência em Software Livre.
Programa Software Livre Paraná.

marcok at redesol.org
+55 41 9615-0715.
SKYPE: marcokonopacki
MSN: marcokonopacki at hotmail.com

-------------- next part --------------
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revisão 5282)
+++ wp-admin/admin-functions.php	(cópia de trabalho)
@@ -838,6 +838,7 @@
 		<th scope='row' style='text-align: center'>$category->cat_ID</th>
 		<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
 		<td>$category->category_description</td>
+		<td align='center'>$category->cat_order</td>
 		<td align='center'>$posts_count</td>
 		<td align='center'>$category->link_count</td>
 		<td>$edit</td>\n\t</tr>\n";
Index: wp-admin/admin-db.php
===================================================================
--- wp-admin/admin-db.php	(revisão 5282)
+++ wp-admin/admin-db.php	(cópia de trabalho)
@@ -129,10 +129,10 @@
 		$update = true;
 
 	if (!$update) {
-		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, type) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$type')");
+		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, type,cat_order) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$type','$cat_order')");
 		$cat_ID = (int) $wpdb->insert_id;
 	} else {
-		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', type = '$type' WHERE cat_ID = '$cat_ID'");
+		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', type = '$type', cat_order = '$cat_order' WHERE cat_ID = '$cat_ID'");
 	}
 
 	if ( $category_nicename == '' ) {
Index: wp-admin/edit-category-form.php
===================================================================
--- wp-admin/edit-category-form.php	(revisão 5282)
+++ wp-admin/edit-category-form.php	(cópia de trabalho)
@@ -42,6 +42,10 @@
 			<th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th>
 			<td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description); ?></textarea></td>
 		</tr>
+		<tr>
+			<th scope="row" valign="top"><label for="cat_order"><?php _e('Category Order: (optional)') ?></label></th>
+			<td><input name="cat_order" id="cat_order" value="<?php echo attribute_escape($category->cat_order); ?>" size="3"></td>
+		</tr>
 	</table>
 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
 <?php do_action('edit_category_form', $category); ?>
Index: wp-admin/categories.php
===================================================================
--- wp-admin/categories.php	(revisão 5282)
+++ wp-admin/categories.php	(cópia de trabalho)
@@ -98,6 +98,7 @@
 		<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
         <th scope="col"><?php _e('Name') ?></th>
         <th scope="col"><?php _e('Description') ?></th>
+        <th scope="col" width="90" style="text-align: center"><?php _e('Order') ?></th>
         <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
         <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
         <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
Index: wp-admin/upgrade-schema.php
===================================================================
--- wp-admin/upgrade-schema.php	(revisão 5282)
+++ wp-admin/upgrade-schema.php	(cópia de trabalho)
@@ -13,6 +13,7 @@
 $wp_queries="CREATE TABLE $wpdb->categories (
   cat_ID bigint(20) NOT NULL auto_increment,
   cat_name varchar(55) NOT NULL default '',
+  cat_order tinyint(2) NULL default '0',
   category_nicename varchar(200) NOT NULL default '',
   category_description longtext NOT NULL,
   category_parent bigint(20) NOT NULL default '0',
-------------- next part --------------
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revisão 970)
+++ wp-admin/admin-functions.php	(cópia de trabalho)
@@ -822,6 +822,7 @@
 		<th scope='row' style='text-align: center'>$category->cat_ID</th>
 		<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
 		<td>$category->category_description</td>
+		<td align='center'>$category->cat_order</td>
 		<td align='center'>$posts_count</td>
 		<td align='center'>$category->link_count</td>
 		<td>$edit</td>\n\t</tr>\n";
Index: wp-admin/admin-db.php
===================================================================
--- wp-admin/admin-db.php	(revisão 970)
+++ wp-admin/admin-db.php	(cópia de trabalho)
@@ -128,9 +128,9 @@
 	if (!$update) {
 		$maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
 		$cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
-		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
+		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private, cat_order) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private', '$cat_order')");
 	} else {
-		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
+		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private', cat_order = '$cat_order' WHERE cat_ID = '$cat_ID'");
 	}
 
 	if ( $category_nicename == '' ) {
Index: wp-admin/edit-category-form.php
===================================================================
--- wp-admin/edit-category-form.php	(revisão 970)
+++ wp-admin/edit-category-form.php	(cópia de trabalho)
@@ -38,6 +38,10 @@
 			<th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th>
 			<td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description); ?></textarea></td>
 		</tr>
+		<tr>
+			<th scope="row" valign="top"><label for="cat_order"><?php _e('Category Order: (optional)') ?></label></th>
+			<td><input name="cat_order" id="cat_order" value="<?php echo attribute_escape($category->cat_order); ?>" size="3"></td>
+		</tr>
 	</table>
 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
 <?php do_action('edit_category_form', $category); ?>
Index: wp-admin/categories.php
===================================================================
--- wp-admin/categories.php	(revisão 970)
+++ wp-admin/categories.php	(cópia de trabalho)
@@ -98,6 +98,7 @@
 		<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
         <th scope="col"><?php _e('Name') ?></th>
         <th scope="col"><?php _e('Description') ?></th>
+        <th scope="col" width="90" style="text-align: center"><?php _e('Order') ?></th>
         <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
         <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
         <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
Index: wp-admin/upgrade-schema.php
===================================================================
--- wp-admin/upgrade-schema.php	(revisão 970)
+++ wp-admin/upgrade-schema.php	(cópia de trabalho)
@@ -14,6 +14,7 @@
 $wp_queries="CREATE TABLE $wpdb->categories (
   cat_ID bigint(20) NOT NULL auto_increment,
   cat_name varchar(55) NOT NULL default '',
+  cat_order tinyint(2) NULL default '0',
   category_nicename varchar(200) NOT NULL default '',
   category_description longtext NOT NULL,
   category_parent bigint(20) NOT NULL default '0',


More information about the wp-hackers mailing list