From f010e00284b393879db079eed12707549a42c5d4 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Sat, 30 Jun 2012 09:28:15 +0000 Subject: [PATCH] Prevent child pages from being visually promoted to the top level after Quick Edit. props ssamture. fixes #18615 git-svn-id: http://core.svn.wordpress.org/trunk@21192 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 13 ++++++++++++- wp-admin/includes/class-wp-posts-list-table.php | 12 +++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index e47fb11fb3..9daafed22e 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1368,7 +1368,18 @@ function wp_ajax_inline_save() { $wp_list_table = _get_list_table('WP_Posts_List_Table'); $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(); } diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 80e52cac9e..151fe36c65 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -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; if ( empty( $posts ) ) @@ -311,11 +311,11 @@ class WP_Posts_List_Table extends WP_List_Table { if ( $this->hierarchical_display ) { $this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); } else { - $this->_display_rows( $posts ); + $this->_display_rows( $posts, $level ); } } - function _display_rows( $posts ) { + function _display_rows( $posts, $level = 0 ) { global $post, $mode; // 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 ); foreach ( $posts as $post ) - $this->single_row( $post ); + $this->single_row( $post, $level ); } function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { @@ -524,8 +524,10 @@ class WP_Posts_List_Table extends WP_List_Table { } else { $attributes = 'class="post-title page-title column-title"' . $style; + + $pad = str_repeat( '— ', $level ); ?> - >post_status != 'trash' ) { ?> + >post_status != 'trash' ) { ?> ID ) ) the_excerpt();