From e3cc3318354bfb12c40aa6f8ac7a5f3099de1b6a Mon Sep 17 00:00:00 2001 From: azaozz Date: Tue, 30 Sep 2008 10:30:56 +0000 Subject: [PATCH] Batch edit: allow removal of selected posts, prevent page parent lock. git-svn-id: http://svn.automattic.com/wordpress/trunk@9036 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/colors-classic.css | 6 +++-- wp-admin/css/colors-fresh.css | 6 +++-- wp-admin/edit-pages.php | 34 +++++++++++++++--------- wp-admin/edit.php | 38 +++++++++++++++----------- wp-admin/includes/post.php | 47 +++++++++++++++++++++++---------- wp-admin/includes/template.php | 8 +++--- wp-admin/js/inline-edit.js | 8 +++++- wp-admin/wp-admin.css | 13 +++++++++ wp-includes/script-loader.php | 4 +-- wp-includes/user.php | 7 +++-- 10 files changed, 116 insertions(+), 55 deletions(-) diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index b434430676..7622e83c96 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -532,11 +532,13 @@ input.readonly { color: #448abd; } -#tagchecklist span a { +#tagchecklist span a, +#bulk-titles div a { background: url(../images/xit.gif) no-repeat; } -#tagchecklist span a:hover { +#tagchecklist span a:hover, +#bulk-titles div a:hover { background: url(../images/xit.gif) no-repeat -10px 0; } diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index f024eb5c98..0e040b9db2 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -516,11 +516,13 @@ input.readonly { color: #448abd; } -#tagchecklist span a { +#tagchecklist span a, +#bulk-titles div a { background: url(../images/xit.gif) no-repeat; } -#tagchecklist span a:hover { +#tagchecklist span a:hover, +#bulk-titles div a:hover { background: url(../images/xit.gif) no-repeat -10px 0; } diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index 214914c241..935840e6c9 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -36,10 +36,13 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] case 'edit': if ( isset($_GET['post']) ) { check_admin_referer('bulk-pages'); - $_GET['post_status'] = $_GET['_status']; - if ( -1 == $_GET['post_author'] ) - unset($_GET['post_author']); + if ( -1 == $_GET['_status'] ) { + $_GET['post_status'] = null; + unset($_GET['_status'], $_GET['post_status']); + } else { + $_GET['post_status'] = $_GET['_status']; + } $done = bulk_edit_posts($_GET); } @@ -50,10 +53,10 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); if ( isset($done) ) { - $done['upd'] = count( $done['upd'] ); - $done['skip'] = count( $done['skip'] ); + $done['updated'] = count( $done['updated'] ); + $done['skipped'] = count( $done['skipped'] ); + $done['locked'] = count( $done['locked'] ); $sendback = add_query_arg( $done, $sendback ); - unset($done); } wp_redirect($sendback); exit(); @@ -111,16 +114,21 @@ require_once('admin-header.php'); ?>
- +

-

diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 51d615ff37..4a8f1b0759 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -36,10 +36,13 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] case 'edit': if ( isset($_GET['post']) ) { check_admin_referer('bulk-posts'); - $_GET['post_status'] = $_GET['_status']; - if ( -1 == $_GET['post_author'] ) - unset($_GET['post_author']); + if ( -1 == $_GET['_status'] ) { + $_GET['post_status'] = null; + unset($_GET['_status'], $_GET['post_status']); + } else { + $_GET['post_status'] = $_GET['_status']; + } $done = bulk_edit_posts($_GET); } @@ -51,10 +54,10 @@ if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php'); $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); if ( isset($done) ) { - $done['upd'] = count( $done['upd'] ); - $done['skip'] = count( $done['skip'] ); + $done['updated'] = count( $done['updated'] ); + $done['skipped'] = count( $done['skipped'] ); + $done['locked'] = count( $done['locked'] ); $sendback = add_query_arg( $done, $sendback ); - unset($done); } wp_redirect($sendback); exit(); @@ -100,26 +103,31 @@ else
+
+

|

- +

- +if ( (int) $_GET['skipped'] ) + unset($_GET['skipped']); + +if ( (int) $_GET['locked'] ) { + printf( __ngettext( ' %d page not updated, somebody is editing it.', ' %d pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) ); + unset($_GET['locked']); +} ?>

-
-
    get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'"); + $children = array(); + + for ( $i = 0; $i < 50 && $parent > 0; $i++ ) { + $children[] = $parent; + + foreach ( $pages as $page ) { + if ( $page->ID == $parent ) { + $parent = $page->post_parent; + break; + } + } } } - $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private' ); - foreach ( $reset as $field ) { - if ( isset($post_data[$field]) && '' == $post_data[$field] ) - unset($post_data[$field]); - } - - $updated = $skipped = array(); + $updated = $skipped = $locked = array(); foreach ( $post_IDs as $post_ID ) { - if ( wp_check_post_lock( $post_ID ) ) { + if ( isset($children) && in_array($post_ID, $children) ) { $skipped[] = $post_ID; continue; } + + if ( wp_check_post_lock( $post_ID ) ) { + $locked[] = $post_ID; + continue; + } if ( isset($new_cats) ) { $cats = (array) wp_get_post_categories($post_ID); @@ -236,7 +255,7 @@ function bulk_edit_posts( $post_data = null ) { $updated[] = wp_update_post( $post_data ); } - return array( 'upd' => $updated, 'skip' => $skipped ); + return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked ); } // Default post information to use when populating the "Write Post" form. diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 3798b77ab6..f04f1e580d 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -693,7 +693,7 @@ function inline_edit_row( $type ) {
    - + @@ -784,7 +784,7 @@ function inline_edit_row( $type ) {
    $authors, 'name' => 'post_author', 'class'=> 'authors'); + $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1); if ( $bulk ) $users_opt['show_option_none'] = __('- No Change -'); wp_dropdown_users( $users_opt ); ?>
    @@ -809,7 +809,7 @@ function inline_edit_row( $type ) {
    \n"; + $id = $multi ? "" : "id='$name'"; + + $output = "