added cache_pages to avoid making 1+X queries everytime wp_list_pages is called, where X is the number of pages

git-svn-id: https://develop.svn.wordpress.org/trunk@2354 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
michelvaldrighi
2005-02-16 15:12:04 +00:00
parent 68d7c93974
commit efc4b4e54d
2 changed files with 46 additions and 33 deletions

View File

@@ -941,10 +941,14 @@ function remove_action($tag, $function_to_remove, $priority = 10) {
remove_filter($tag, $function_to_remove, $priority);
}
function get_page_uri($page) {
global $wpdb;
$page = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$page'");
function get_page_uri($page_id) {
global $wpdb, $cache_pages;
if (!isset($cache_pages[$page_id])) {
$cache_pages[$page_id] = $wpdb->get_row("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = '$page_id'");
}
$page = $cache_pages[$page_id];
$uri = urldecode($page->post_name);
// A page cannot be it's own parent.