Changeset 6380
- Timestamp:
- 12/14/2007 06:20:42 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-pages.php
r6213 r6380 69 69 70 70 <?php 71 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"); 71 $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"; 72 $query_str = apply_filters('manage_pages_query', $query_str); 73 wp($query_str); 72 74 73 75 $all = !( $h2_search || $post_status_q ); … … 86 88 </thead> 87 89 <tbody id="the-list" class="list:page"> 88 <?php page_rows(0, 0, $posts, $all); ?> 90 <?php page_rows($posts); ?> 89 91 </tbody> 90 92 </table> -
trunk/wp-admin/includes/template.php
r6363 r6380 226 226 } 227 227 228 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 229 global $class, $post; 230 231 if (!$pages ) 232 $pages = get_pages( 'sort_column=menu_order' ); 233 234 if (! $pages ) 235 return false; 236 237 foreach ( $pages as $post) { 238 setup_postdata( $post); 239 if ( $hierarchy && ($post->post_parent != $parent) ) 240 continue; 241 242 $post->post_title = wp_specialchars( $post->post_title ); 243 $pad = str_repeat( '— ', $level ); 244 $id = (int) $post->ID; 245 $class = ('alternate' == $class ) ? '' : 'alternate'; 228 /* 229 * display one row if the page doesn't have any children 230 * otherwise, display the row and its children in subsequent rows 231 */ 232 function display_page_row( $page, &$children_pages, $level = 0 ) { 233 global $post; 234 static $class; 235 236 $post = $page; 237 setup_postdata($page); 238 239 $page->post_title = wp_specialchars( $page->post_title ); 240 $pad = str_repeat( '— ', $level ); 241 $id = (int) $page->ID; 242 $class = ('alternate' == $class ) ? '' : 'alternate'; 243 246 244 ?> 247 245 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> 248 <th scope="row" style="text-align: center"><?php echo $p ost->ID; ?></th>246 <th scope="row" style="text-align: center"><?php echo $page->ID; ?></th> 249 247 <td> 250 <?php echo $pad; ?><?php the_title() ?>248 <?php echo $pad; ?><?php the_title(); ?> 251 249 </td> 252 250 <td><?php the_author() ?></td> 253 <td><?php if ( '0000-00-00 00:00:00' ==$p ost->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td>251 <td><?php if ( '0000-00-00 00:00:00' ==$page->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $page->post_modified ); ?></td> 254 252 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td> 255 253 <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> … … 258 256 259 257 <?php 260 if ( $hierarchy ) 261 page_rows( $id, $level + 1, $pages ); 262 } 258 259 if ( ! $children_pages ) 260 return true; 261 262 for ( $i=0; $i < count($children_pages); $i++ ) { 263 264 $child = $children_pages[$i]; 265 266 if ( $child->post_parent == $id ) { 267 array_splice($children_pages, $i, 1); 268 display_page_row($child, $children_pages, $level+1); 269 $i--; 270 } 271 } 272 } 273 274 /* 275 * displays pages in hierarchical order 276 */ 277 function page_rows( $pages ) { 278 if ( ! $pages ) 279 $pages = get_pages( 'sort_column=menu_order' ); 280 281 if ( ! $pages ) 282 return false; 283 284 // splice pages into two parts: those without parent and those with parent 285 286 $top_level_pages = array(); 287 $children_pages = array(); 288 289 foreach ( $pages as $page ) { 290 if ( 0 == $page->post_parent ) 291 $top_level_pages[] = $page; 292 else 293 $children_pages[] = $page; 294 } 295 296 foreach ( $top_level_pages as $page ) 297 display_page_row($page, $children_pages, 0); 298 299 /* 300 * display the remaining children_pages which are orphans 301 * having orphan requires parental attention 302 */ 303 if ( count($children_pages) > 0 ) { 304 $empty_array = array(); 305 foreach ($children_pages as $orphan_page) 306 display_page_row($orphan_page, $empty_array, 0); 307 } 263 308 } 264 309 265 310 function user_row( $user_object, $style = '' ) { 266 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )311 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 267 312 $user_object = new WP_User( (int) $user_object ); 268 313 $email = $user_object->user_email; -
trunk/wp-includes/query.php
r6377 r6380 1114 1114 } else { 1115 1115 // Used to filter values 1116 $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order' );1116 $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order', 'parent', 'ID'); 1117 1117 $q['orderby'] = urldecode($q['orderby']); 1118 1118 $q['orderby'] = addslashes_gpc($q['orderby']); … … 1124 1124 // Only allow certain values for safety 1125 1125 $orderby = $orderby_array[$i]; 1126 if ( 'menu_order' != $orderby)1126 if ( !('menu_order' == $orderby || 'ID' == $orderby )) 1127 1127 $orderby = 'post_' . $orderby; 1128 1128 if ( in_array($orderby_array[$i], $allowed_keys) ) 1129 $q['orderby'] .= (($i == 0) ? '' : ',') . "$orderby {$q['order']}"; 1130 } 1129 $q['orderby'] .= (($i == 0) ? '' : ',') . $orderby; 1130 } 1131 /* append ASC or DESC at the end */ 1132 if ( !empty($q['orderby'])){ 1133 $q['orderby'] .= " {$q['order']}"; 1134 } 1135 1131 1136 if ( empty($q['orderby']) ) 1132 1137 $q['orderby'] = 'post_date '.$q['order'];
Note: See TracChangeset
for help on using the changeset viewer.