Ticket #6561: edit-pages-paged.patch
File edit-pages-paged.patch, 4.4 KB (added by , 17 years ago) |
---|
-
edit-pages.php
51 51 $post_status_q .= '&perm=readable'; 52 52 } 53 53 54 $query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"; 54 if ( !isset($_GET['post_status']) ) { 55 $_GET['post_status'] = null; 56 } 55 57 56 $query_str = apply_filters('manage_pages_query', $query_str); 57 wp($query_str);58 if (isset($_GET['page_id'])) { 59 $query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc"; 58 60 61 $query_str = apply_filters('manage_pages_query', $query_str); 62 wp($query_str); 63 } else { 64 $paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1; 65 $paged_size = 30; 66 67 $where = "post_type = 'page'"; 68 if (isset($_GET['s'])) { 69 $where .= " AND post_title LIKE '%" . $wpdb->escape($_GET['s']) . "%'"; 70 $paged = 0; 71 } 72 if (isset($_GET['post_status'])) { 73 $where .= " AND post_status = '" . $wpdb->escape($_GET['post_status']) . "'"; 74 if ($_GET['post_status'] != 'publish') $paged = 0; 75 } 76 if (isset($_GET['author'])) { 77 $where .= " AND post_author = " . $wpdb->escape($_GET['author']); 78 $paged = 0; 79 } 80 81 $total_pages = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE $where"); 82 83 $sql = "SELECT ID, post_parent, post_date, post_date_gmt, post_modified, post_modified_gmt, post_author, '' AS post_content, post_name, post_status, post_title, post_type FROM $wpdb->posts WHERE $where ORDER BY menu_order, post_title"; 84 85 $all_pages = $wpdb->get_results($sql); 86 87 if ($paged) { 88 $all_pages_by_id = array(); 89 $page_children = array(); 90 91 foreach ($all_pages as $page) { 92 $all_pages_by_id[$page->ID] = $page; 93 $page_children[$page->post_parent][] = $page; 94 } 95 96 function build_page_tree($parent_id) { 97 global $page_children; 98 $tree = array(); 99 if (isset($page_children[$parent_id])) { 100 foreach ($page_children[$parent_id] as $child) { 101 $child->children = build_page_tree($child->ID); 102 $tree[] = $child; 103 } 104 } 105 return $tree; 106 } 107 108 function build_page_array($tree) { 109 $array = array(); 110 foreach ($tree as $page) { 111 $array[] = $page; 112 $array = array_merge($array, build_page_array($page->children)); 113 } 114 return $array; 115 } 116 117 $page_tree = build_page_tree(0); 118 $page_array = build_page_array($page_tree); 119 $posts = array_slice($page_array, ($paged - 1) * $paged_size, $paged_size); 120 121 if ($posts) { 122 while ($posts[0]->post_parent) { 123 $parent = $all_pages_by_id[$posts[0]->post_parent]; 124 $parent->post_title .= ' (continued)'; 125 $posts = array_merge(array($parent), $posts); 126 } 127 } 128 } else { 129 $posts = $all_pages; 130 } 131 } 132 59 133 if ( is_singular() ) 60 134 wp_enqueue_script( 'admin-comments' ); 61 135 require_once('admin-header.php'); … … 111 185 ?> 112 186 113 187 <p id="post-search"> 114 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes( $_GET['s'])); ?>" />188 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes(isset($_GET['s']) ? $_GET['s'] : '')); ?>" /> 115 189 <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" /> 116 190 </p> 117 191 118 192 <div class="tablenav"> 119 193 194 <?php 195 $page_links = null; 196 if ($paged) { 197 $page_links = paginate_links( array( 198 'base' => add_query_arg( 'paged', '%#%' ), 199 'format' => '', 200 'total' => $total_pages / $paged_size + 1, 201 'current' => $paged 202 )); 203 } 204 if ( $page_links ) 205 echo "<div class='tablenav-pages'>$page_links</div>"; 206 ?> 207 120 208 <div class="alignleft"> 121 209 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" /> 122 210 <?php wp_nonce_field('bulk-pages'); ?> … … 168 256 ?> 169 257 170 258 <div class="tablenav"> 259 260 <?php 261 if ( $page_links ) 262 echo "<div class='tablenav-pages'>$page_links</div>"; 263 ?> 264 171 265 <br class="clear" /> 172 266 </div> 173 267 268 <br class="clear" /> 269 174 270 <?php 175 271 176 272 if ( 1 == count($posts) && is_singular() ) :