Prevent child pages from being visually promoted to the top level after Quick Edit. props ssamture. fixes #18615

git-svn-id: https://develop.svn.wordpress.org/trunk@21192 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2012-06-30 09:28:15 +00:00
parent 5268552d72
commit 183f814884
2 changed files with 19 additions and 6 deletions

View File

@ -1368,7 +1368,18 @@ function wp_ajax_inline_save() {
$wp_list_table = _get_list_table('WP_Posts_List_Table'); $wp_list_table = _get_list_table('WP_Posts_List_Table');
$mode = $_POST['post_view']; $mode = $_POST['post_view'];
$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
$level = 0;
$request_post = array( get_post( $_POST['post_ID'] ) );
$parent = $request_post[0]->post_parent;
while ( $parent > 0 ) {
$parent_post = get_post( $parent );
$parent = $parent_post->post_parent;
$level++;
}
$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ), $level );
wp_die(); wp_die();
} }

View File

@ -300,7 +300,7 @@ class WP_Posts_List_Table extends WP_List_Table {
); );
} }
function display_rows( $posts = array() ) { function display_rows( $posts = array(), $level = 0 ) {
global $wp_query, $post_type_object, $per_page; global $wp_query, $post_type_object, $per_page;
if ( empty( $posts ) ) if ( empty( $posts ) )
@ -311,11 +311,11 @@ class WP_Posts_List_Table extends WP_List_Table {
if ( $this->hierarchical_display ) { if ( $this->hierarchical_display ) {
$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
} else { } else {
$this->_display_rows( $posts ); $this->_display_rows( $posts, $level );
} }
} }
function _display_rows( $posts ) { function _display_rows( $posts, $level = 0 ) {
global $post, $mode; global $post, $mode;
// Create array of post IDs. // Create array of post IDs.
@ -327,7 +327,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$this->comment_pending_count = get_pending_comments_num( $post_ids ); $this->comment_pending_count = get_pending_comments_num( $post_ids );
foreach ( $posts as $post ) foreach ( $posts as $post )
$this->single_row( $post ); $this->single_row( $post, $level );
} }
function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
@ -524,8 +524,10 @@ class WP_Posts_List_Table extends WP_List_Table {
} }
else { else {
$attributes = 'class="post-title page-title column-title"' . $style; $attributes = 'class="post-title page-title column-title"' . $style;
$pad = str_repeat( '— ', $level );
?> ?>
<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states( $post ); ?></strong> <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong>
<?php <?php
if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
the_excerpt(); the_excerpt();