[wp-cvs] wordpress/wp-includes functions.php, 1.180, 1.181 template-functions-links.php, 1.34, 1.35

Ryan Boren rboren at users.sourceforge.net
Wed Oct 6 02:18:39 UTC 2004


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

Modified Files:
	functions.php template-functions-links.php 
Log Message:
Page/subpage URIs.

Index: template-functions-links.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/template-functions-links.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** template-functions-links.php	18 Sep 2004 20:04:29 -0000	1.34
--- template-functions-links.php	6 Oct 2004 02:18:37 -0000	1.35
***************
*** 50,59 ****
  	}
  
  	$permalink = get_settings('permalink_structure');
  
  	if ('' != $permalink) {
- 		if ($idpost->post_status == 'static')
- 			$permalink = page_permastruct();
- 
  		$unixtime = strtotime($idpost->post_date);
  
--- 50,60 ----
  	}
  
+ 	if ($idpost->post_status == 'static') {
+ 		return get_page_link();
+ 	}
+ 	
  	$permalink = get_settings('permalink_structure');
  
  	if ('' != $permalink) {
  		$unixtime = strtotime($idpost->post_date);
  
***************
*** 79,88 ****
  	} else { // if they're not using the fancy permalink option
  		$permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID;
- 		if ($idpost->post_status == 'static')
- 			$permalink .=  '&static=1';
  		return $permalink;
  	}
  }
  
  function get_month_link($year, $month) {
      global $querystring_start, $querystring_equal;
--- 80,106 ----
  	} else { // if they're not using the fancy permalink option
  		$permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID;
  		return $permalink;
  	}
  }
  
+ function get_page_link($id = false) {
+ 	global $post;
+ 
+ 	if (! $id) {
+ 		$id = $post->ID;
+ 	}
+ 
+ 	$permalink = get_settings('permalink_structure');
+ 
+ 	if ('' != $permalink) {
+ 		$link = get_page_uri($id);
+ 		$link = get_settings('home') . "/$link/";
+ 	} else {
+ 		$link = get_settings('home') . "/index.php?p=$id&static=1";
+ 	}
+ 
+ 	return $link;
+ }
+ 
  function get_month_link($year, $month) {
      global $querystring_start, $querystring_equal;

Index: functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-includes/functions.php,v
retrieving revision 1.180
retrieving revision 1.181
diff -C2 -d -r1.180 -r1.181
*** functions.php	5 Oct 2004 07:36:50 -0000	1.180
--- functions.php	6 Oct 2004 02:18:37 -0000	1.181
***************
*** 1216,1219 ****
--- 1216,1244 ----
  }
  
+ function get_page_uri($page) {
+ 	global $wpdb;
+ 	$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page'");
+ 
+ 	$uri = $page->post_name;
+ 
+ 	while ($page->post_parent != 0) {
+ 		$page = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$page->post_parent'");
+ 		$uri = $page->post_name . "/" . $uri;
+ 	}
+ 
+ 	return $uri;
+ }
+ 
+ function page_rewrite_rules() {
+ 	$uris = get_settings('page_uris');
+ 
+ 	$rewrite_rules = array();
+ 	foreach ($uris as $uri => $pagename) {
+ 		$rewrite_rules += array($uri . '/?$' => "index.php?pagename=$pagename");
+ 	}
+ 
+ 	return $rewrite_rules;
+ }
+ 
  function generate_rewrite_rules($permalink_structure = '', $matches = '') {
      $rewritecode = 
***************
*** 1410,1415 ****
      $page_rewrite = generate_rewrite_rules($page_structure, $matches);
  
      // Put them together.
!     $rewrite = $site_rewrite + $page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite;
  
      // Add on archive rewrite rules if needed.
--- 1435,1443 ----
      $page_rewrite = generate_rewrite_rules($page_structure, $matches);
  
+ 		// Pages
+ 		$pages_rewrite = page_rewrite_rules();
+ 
      // Put them together.
!     $rewrite = $pages_rewrite + $site_rewrite + $page_rewrite + $search_rewrite + $category_rewrite + $author_rewrite;
  
      // Add on archive rewrite rules if needed.




More information about the cvs mailing list