Changeset 2479
- Timestamp:
- 03/27/2005 09:56:10 PM (20 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r2478 r2479 576 576 } 577 577 578 // Retrieves page data given a page ID or page object. 579 // Handles page caching. 580 function &get_page(&$page, $output = OBJECT) { 581 global $page_cache, $wpdb; 582 583 if ( empty($page) ) { 584 if ( isset($GLOBALS['page']) ) 585 $page = & $GLOBALS['page']; 586 else 587 $page = null; 588 } elseif (is_object($page) ) { 589 if (! isset($page_cache[$page->ID])) 590 $page_cache[$page->ID] = &$page; 591 $page = & $page_cache[$page->ID]; 592 } else { 593 if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) ) 594 $page = & $GLOBALS['page']; 595 elseif (isset($page_cache[$page])) 596 $page = & $page_cache[$page]; 597 else { 598 $query = "SELECT * FROM $wpdb->posts WHERE ID=$page"; 599 $page_cache[$page] = & $wpdb->get_row($query); 600 $page = & $page_cache[$page]; 601 } 602 } 603 604 if ( $output == OBJECT ) { 605 return $page; 606 } elseif ( $output == ARRAY_A ) { 607 return get_object_vars($page); 608 } elseif ( $output == ARRAY_N ) { 609 return array_values(get_object_vars($page)); 610 } else { 611 return $page; 612 } 613 } 614 578 615 // Retrieves category data given a category ID or category object. 579 616 // The category cache is fully populated by the blog header, so we don't … … 1047 1084 1048 1085 function get_page_uri($page_id) { 1049 $page = get_p ost($page_id);1086 $page = get_page($page_id); 1050 1087 $uri = urldecode($page->post_name); 1051 1088 … … 1056 1093 1057 1094 while ($page->post_parent != 0) { 1058 $page = get_p ost($page->post_parent);1095 $page = get_page($page->post_parent); 1059 1096 $uri = urldecode($page->post_name) . "/" . $uri; 1060 1097 } … … 1100 1137 for ($i = 0; $i < count($posts); $i++) { 1101 1138 $post_cache[$posts[$i]->ID] = &$posts[$i]; 1139 } 1140 } 1141 1142 function update_page_cache(&$pages) { 1143 global $page_cache; 1144 1145 if ( !$pages ) 1146 return; 1147 1148 for ($i = 0; $i < count($pages); $i++) { 1149 $page_cache[$pages[$i]->ID] = &$pages[$i]; 1102 1150 } 1103 1151 } -
trunk/wp-includes/template-functions-post.php
r2478 r2479 252 252 253 253 function &get_pages($args = '') { 254 global $wpdb, $ cache_pages;254 global $wpdb, $page_cache; 255 255 256 256 parse_str($args, $r); … … 282 282 "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); 283 283 284 if ( empty($pages) ) 285 return array(); 286 284 287 // Update cache. 285 update_post_cache($pages); 286 287 if ( empty($pages) ) 288 $pages = array(); 288 update_page_cache($pages); 289 289 290 290 return $pages;
Note: See TracChangeset
for help on using the changeset viewer.