Index: edit-pages.php
===================================================================
--- edit-pages.php	(revision 5772)
+++ edit-pages.php	(working copy)
@@ -11,7 +11,6 @@
 			'publish' => array(__('Published'), __('Published pages'))
 		);
 
-
 $post_status_label = _c('Pages|manage pages header');
 $post_status_q = '';
 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
@@ -21,6 +20,119 @@
 
 ?>
 
+<?php
+//Added functions to speed up Page Management page load
+function &lp_get_pages($_pages) {
+
+    // permalink stuff
+    global $wp_rewrite;
+    $pagestruct = $wp_rewrite->get_page_permastruct();
+    $home = get_settings('home');
+
+    $pages = array();
+    $deferred = array();
+
+    foreach ($_pages as $k=>$page) {
+
+        $id = $page['id'];
+        $parent = $page['post_parent'];
+
+        $_pages[$k]['root_page'] = empty($parent);
+        $_pages[$k]['children'] = array();
+
+        if (!empty($parent) && $parent != $id) {
+            if (isset($pages[$parent]))
+                $pages[$parent]['children'][$page['menu_order'] . $page['post_title']] =& $_pages[$k];
+            else
+                $deferred[$id] = array($page['menu_order'] . $page['post_title'], $parent);
+        }
+        $pages[$id] =& $_pages[$k];
+
+    }
+
+    foreach ($deferred as $id=>$details) {
+        list($title, $parent) = $details;
+        if (isset($pages[$parent]))
+            $pages[$parent]['children'][$title] =& $pages[$id];
+        else
+            $pages[$id]['parent'] = '';
+    }
+
+    /*
+    Add unpublished pages to the begining of the page list
+    */
+    $temp_pages_list = $pages;
+    $unpublished_pages = array();
+    $array_offset = 0;
+    foreach ($temp_pages_list as $id => $page)
+    {
+        if ($page['post_date'] == '0000-00-00 00:00:00')
+        {
+            $slice = array_splice($pages, $array_offset, 1);
+            $unpublished_pages[] = $slice[0];
+        }
+
+        $array_offset++;
+    }
+    $unpublished_pages = array_reverse($unpublished_pages);
+    foreach ($unpublished_pages as $unpublished_page)
+          array_unshift($pages, $unpublished_page);
+    
+
+    foreach ($pages as $id=>$page) {
+
+        $parent = $page['post_parent'];
+
+        if (empty($pagestruct)) {
+            $link = "$home/?page_id=$id";
+        } else {
+            $uri = urldecode($page['post_name']);
+            if ($parent != $id) {
+                while (!empty($parent) && isset($pages[$parent])) {
+                    $uri = urldecode($pages[$parent]['post_name']) . "/$uri";
+                    $parent = $pages[$parent]['post_parent'];
+                }
+            }
+            $link = $home . '/' . str_replace('%pagename%', $uri, $pagestruct) . '/';
+        }
+        $pages[$id]['permalink'] = apply_filters('page_link', $link, $id);
+    }
+
+    return $pages;
+}
+
+function recurse(&$tree, $padding='', $index=0) {
+
+    foreach ($tree as $post) {
+        if (empty($padding) && !empty($post['post_parent']))
+            continue;
+        $index++;
+        $title = wp_specialchars($post['post_title']);
+        $id = $post['id'];
+        $class = (($index%2)==1) ? '' : 'alternate';
+
+        ?>
+        <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+            <th scope="row" style="text-align: center"><?php echo $id; ?></th>
+            <td>
+              <?php echo $padding; ?><?php echo $title; ?>
+            </td>
+            <td><?php echo $post['display_name']; ?></td>
+            <td><?php if ( '0000-00-00 00:00:00' ==$post['post_date'] ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post['post_modified'] ); ?></td>
+            <td><a href="<?php if ('0000-00-00 00:00:00' ==$post['post_date']) echo "/?page_id=$id"; else echo $post['permalink']; ?>" rel="permalink" class="edit"><?php _e( 'View' ); ?></a></td>
+            <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td>
+            <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&amp;post=$id", 'delete-page_' . $id ) .  "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), $title ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td>
+        </tr>
+        <?php
+
+        ksort($post['children']);
+        $index = recurse($post['children'], $padding . '&#8212; ', $index);
+    }
+    return $index;
+}
+
+?>            
+
 <div class="wrap">
 
 <h2><?php
@@ -64,11 +176,24 @@
 
 <br style="clear:both;" />
 
-<?php
-wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc");
+<?php       
 
-$all = !( $h2_search || $post_status_q );
+$all = !( $h2_search || $post_status_q );       
+  
+if ($_GET['s']) {
+    wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc");
+}
+else {
+    $q = "SELECT p.id, p.post_name, p.post_title, p.post_parent, p.menu_order, p.post_modified, p.post_date, " .
+                "u.display_name " .
+                "FROM $wpdb->posts p " .
+                "INNER JOIN $wpdb->users u ON p.post_author = u.id " .
+                "WHERE p.post_type='page' " .
+                "ORDER BY p.menu_order ASC , p.post_date DESC";
 
+    $posts =& lp_get_pages($wpdb->get_results($q,  ARRAY_A));
+}  
+
 if ($posts) {
 ?>
 <table class="widefat"> 
@@ -82,7 +207,19 @@
   </tr>
   </thead>
   <tbody id="the-list">
-<?php page_rows(0, 0, $posts, $all); ?>
+<?php 
+    if ( $all == false )
+    {
+        page_rows(0, 0, $posts, $all);
+    }
+    else
+    {
+        //page_rows();
+
+        //Added to speed up Page Management page load
+        recurse($posts);
+    }
+?>
   </tbody>
 </table>
 
