[wp-cvs] wordpress/wp-includes template-functions-category.php, 1.31, 1.32 template-functions-links.php, 1.16, 1.17

Ryan Boren rboren at users.sourceforge.net
Thu Jun 3 21:36:48 CDT 2004


Update of /cvsroot/cafelog/wordpress/wp-includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21509

Modified Files:
	template-functions-category.php template-functions-links.php 
Log Message:
Add %category% support to get_permalink.

Index: template-functions-links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-links.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** template-functions-links.php	2 Jun 2004 21:43:18 -0000	1.16
--- template-functions-links.php	4 Jun 2004 02:36:46 -0000	1.17
***************
*** 39,79 ****
  		'%second%',
          '%postname%',
!         '%post_id%'
      );
!     if (!$id) {
!         if ('' != get_settings('permalink_structure')) {
! 	    $unixtime = strtotime($post->post_date);
!             $rewritereplace = array(
!                 date('Y', $unixtime),
!                 date('m', $unixtime),
!                 date('d', $unixtime),
! 				date('H', $unixtime),
! 				date('i', $unixtime),
! 				date('s', $unixtime),
!                 $post->post_name,
!                 $post->ID
!             );
!             return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
!         } else { // if they're not using the fancy permalink option
!             return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$post->ID;
!         }
!     } else { // if an ID is given
!         $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $wpdb->posts WHERE ID = $id");
!         if ('' != get_settings('permalink_structure')) {
  	    $unixtime = strtotime($idpost->post_date);
!             $rewritereplace = array(
!                 date('Y', $unixtime),
!                 date('m', $unixtime),
!                 date('d', $unixtime),
! 				date('H', $unixtime),
! 				date('i', $unixtime),
! 				date('s', $unixtime),
!                 $idpost->post_name,
!                 $id
!             );
!             return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
!         } else {
!             return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$id;
!         }
      }
  }
--- 39,72 ----
  		'%second%',
          '%postname%',
!         '%post_id%',
!         '%category%'
      );
! 
!     if ($id) {
!         $idpost = $wpdb->get_row("SELECT ID, post_date, post_name FROM $wpdb->posts WHERE ID = $id");
!     } else {
!         $idpost = $post;
!     }
!        
!     if ('' != get_settings('permalink_structure')) {
  	    $unixtime = strtotime($idpost->post_date);
! 
!         $cats = get_the_category($idpost->ID);
!         $category = $cats[0]->category_nicename;
! 
!         $rewritereplace = array(
!                                 date('Y', $unixtime),
!                                 date('m', $unixtime),
!                                 date('d', $unixtime),
!                                 date('H', $unixtime),
!                                 date('i', $unixtime),
!                                 date('s', $unixtime),
!                                 $idpost->post_name,
!                                 $idpost->ID,
!                                 $category
!                                 );
!         return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
!     } else { // if they're not using the fancy permalink option
!         return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
      }
  }

Index: template-functions-category.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-category.php,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** template-functions-category.php	31 May 2004 22:09:38 -0000	1.31
--- template-functions-category.php	4 Jun 2004 02:36:46 -0000	1.32
***************
*** 1,13 ****
  <?php
  
! function get_the_category() {
      global $post, $wpdb, $category_cache;
!     if ($category_cache[$post->ID]) {
!         return $category_cache[$post->ID];
      } else {
          $categories = $wpdb->get_results("
              SELECT category_id, cat_name, category_nicename, category_description, category_parent
              FROM  $wpdb->categories, $wpdb->post2cat
!             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $post->ID
              ");
      
--- 1,18 ----
  <?php
  
! function get_the_category($id = false) {
      global $post, $wpdb, $category_cache;
! 
!     if (! $id) {
!         $id = $post->ID;
!     }
! 
!     if ($category_cache[$id]) {
!         return $category_cache[$id];
      } else {
          $categories = $wpdb->get_results("
              SELECT category_id, cat_name, category_nicename, category_description, category_parent
              FROM  $wpdb->categories, $wpdb->post2cat
!             WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $id
              ");
      




More information about the cvs mailing list