[wp-cvs] wordpress/wp-includes classes.php, 1.4, 1.5 functions.php, 1.140, 1.141 template-functions-category.php, 1.38, 1.39 template-functions-links.php, 1.23, 1.24

Ryan Boren rboren at users.sourceforge.net
Tue Aug 10 05:36:01 UTC 2004


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

Modified Files:
	classes.php functions.php template-functions-category.php 
	template-functions-links.php 
Log Message:
Static pages.  Take 1.

Index: template-functions-links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-links.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** template-functions-links.php	7 Aug 2004 18:12:54 -0000	1.23
--- template-functions-links.php	10 Aug 2004 05:35:59 -0000	1.24
***************
*** 40,53 ****
          '%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);
  
--- 40,60 ----
          '%postname%',
          '%post_id%',
!         '%category%',
!         '%pagename%'
      );
  
      if ($id) {
!         $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status FROM $wpdb->posts WHERE ID = $id");
      } else {
          $idpost = $post;
      }
! 
!     $permalink = get_settings('permalink_structure');
! 
!     if ('' != $permalink) {
!         if ($idpost->post_status == 'static') {
!             $permalink = page_permastruct();
!         }
! 
  	    $unixtime = strtotime($idpost->post_date);
  
***************
*** 64,72 ****
                                  $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;
      }
  }
--- 71,83 ----
                                  $idpost->post_name,
                                  $idpost->ID,
!                                 $category,
!                                 $idpost->post_name,
                                  );
!         return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink);
      } else { // if they're not using the fancy permalink option
!         $permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID;
!         if ($idpost->post_status == 'static') {
!             $permalink .=  $querystring_separator . "static=1";
!         }
      }
  }

Index: functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions.php,v
retrieving revision 1.140
retrieving revision 1.141
diff -C2 -d -r1.140 -r1.141
*** functions.php	9 Aug 2004 07:54:23 -0000	1.140
--- functions.php	10 Aug 2004 05:35:59 -0000	1.141
***************
*** 1176,1179 ****
--- 1176,1197 ----
  }
  
+ 
+ function page_permastruct() {
+     $permalink_structure = get_settings('permalink_structure');
+         
+     if (empty($permalink_structure)) {
+         return '';
+     }
+ 
+     $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));    
+     $index = get_settings('blogfilename');
+     $prefix = '';
+     if (preg_match('#^/*' . $index . '#', $front)) {
+         $prefix = $index . '/';
+     }
+ 
+     return '/' . $prefix . 'site/%pagename%';    
+ }
+ 
  function generate_rewrite_rules($permalink_structure = '', $matches = '') {
      $rewritecode = 
***************
*** 1188,1192 ****
  	'%post_id%',
      '%category%',
!     '%author%'
  	);
  
--- 1206,1211 ----
  	'%post_id%',
      '%category%',
!     '%author%',
! 	'%pagename%'
  	);
  
***************
*** 1202,1206 ****
  	'([0-9]+)',
  	'([/_0-9a-z-]+)',
! 	'([_0-9a-z-]+)'
  	);
  
--- 1221,1226 ----
  	'([0-9]+)',
  	'([/_0-9a-z-]+)',
! 	'([_0-9a-z-]+)',
! 	'([_0-9a-z-]+)',
  	);
  
***************
*** 1216,1220 ****
  	'p=',
      'category_name=',
!     'author_name='
  	);
  
--- 1236,1241 ----
  	'p=',
      'category_name=',
!     'author_name=',
! 	'static=1&name=',    
  	);
  
***************
*** 1356,1361 ****
      $author_rewrite = generate_rewrite_rules($author_structure, $matches);
  
      // Put them together.
!     $rewrite = $site_rewrite + $category_rewrite + $author_rewrite;
  
      // Add on archive rewrite rules if needed.
--- 1377,1386 ----
      $author_rewrite = generate_rewrite_rules($author_structure, $matches);
  
+     // Site static pages
+     $page_structure = $prefix . 'site/%pagename%';
+     $page_rewrite = generate_rewrite_rules($page_structure, $matches);
+ 
      // Put them together.
!     $rewrite = $site_rewrite + $page_rewrite + $category_rewrite + $author_rewrite;
  
      // Add on archive rewrite rules if needed.
***************
*** 1465,1470 ****
          WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
          
!     foreach ($dogs as $catt) {
!         $category_cache[$catt->ID][] = $catt;
      }
  
--- 1490,1497 ----
          WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
          
!     if (!empty($dogs)) {
!         foreach ($dogs as $catt) {
!             $category_cache[$catt->ID][] = $catt;
!         }
      }
  

Index: classes.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/classes.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** classes.php	8 Aug 2004 15:31:50 -0000	1.4
--- classes.php	10 Aug 2004 05:35:59 -0000	1.5
***************
*** 455,463 ****
              $distinct = 'DISTINCT';
          }
!         $where .= ' AND (post_status = "publish"';
  
          // Get private posts
          if (isset($user_ID) && ('' != intval($user_ID)))
!             $where .= " OR post_author = $user_ID AND post_status != 'draft')";
          else
              $where .= ')';
--- 455,468 ----
              $distinct = 'DISTINCT';
          }
! 
! 	if ('' != $q['static']) {
! 	  $where .= ' AND (post_status = "static"';
! 	} else {
! 	  $where .= ' AND (post_status = "publish"';
! 	}
  
          // Get private posts
          if (isset($user_ID) && ('' != intval($user_ID)))
!             $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
          else
              $where .= ')';

Index: template-functions-category.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-category.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** template-functions-category.php	27 Jul 2004 14:58:30 -0000	1.38
--- template-functions-category.php	10 Aug 2004 05:35:59 -0000	1.39
***************
*** 65,68 ****
--- 65,73 ----
  function the_category($seperator = '', $parents='') {
      $categories = get_the_category();
+     if (empty($categories)) {
+         _e('Uncategorized');
+         return;
+     }
+ 
      $thelist = '';
      if ('' == $seperator) {




More information about the cvs mailing list