Make WordPress Core

Changeset 9036


Ignore:
Timestamp:
09/30/2008 10:30:56 AM (15 years ago)
Author:
azaozz
Message:

Batch edit: allow removal of selected posts, prevent page parent lock.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/colors-classic.css

    r9028 r9036  
    533533}
    534534
    535 #tagchecklist span a {
     535#tagchecklist span a,
     536#bulk-titles div a {
    536537    background: url(../images/xit.gif) no-repeat;
    537538}
    538539
    539 #tagchecklist span a:hover {
     540#tagchecklist span a:hover,
     541#bulk-titles div a:hover {
    540542    background: url(../images/xit.gif) no-repeat -10px 0;
    541543}
  • trunk/wp-admin/css/colors-fresh.css

    r9028 r9036  
    517517}
    518518
    519 #tagchecklist span a {
     519#tagchecklist span a,
     520#bulk-titles div a {
    520521    background: url(../images/xit.gif) no-repeat;
    521522}
    522523
    523 #tagchecklist span a:hover {
     524#tagchecklist span a:hover,
     525#bulk-titles div a:hover {
    524526    background: url(../images/xit.gif) no-repeat -10px 0;
    525527}
  • trunk/wp-admin/edit-pages.php

    r9032 r9036  
    3737            if ( isset($_GET['post']) ) {
    3838                check_admin_referer('bulk-pages');
    39                 $_GET['post_status'] = $_GET['_status'];
    40 
    41                 if ( -1 == $_GET['post_author'] )
    42                     unset($_GET['post_author']);
     39
     40                if ( -1 == $_GET['_status'] ) {
     41                    $_GET['post_status'] = null;
     42                    unset($_GET['_status'], $_GET['post_status']);
     43                } else {
     44                    $_GET['post_status'] = $_GET['_status'];
     45                }
    4346
    4447                $done = bulk_edit_posts($_GET);
     
    5154    $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
    5255    if ( isset($done) ) {
    53         $done['upd'] = count( $done['upd'] );
    54         $done['skip'] = count( $done['skip'] );
     56        $done['updated'] = count( $done['updated'] );
     57        $done['skipped'] = count( $done['skipped'] );
     58        $done['locked'] = count( $done['locked'] );
    5559        $sendback = add_query_arg( $done, $sendback );
    56         unset($done);
    5760    }
    5861    wp_redirect($sendback);
     
    112115<div class="wrap">
    113116
    114 <?php if ( isset($_GET['upd']) || isset($_GET['skip']) ) { ?>
     117<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) ) { ?>
    115118<div id="message" class="updated fade"><p>
    116 <?php if ( (int) $_GET['upd'] ) {
    117     printf( __ngettext( '%d page updated.', '%d pages updated.', $_GET['upd'] ), number_format_i18n( $_GET['upd'] ) );
    118     unset($_GET['upd']);
    119 }
    120 
    121 if ( (int) $_GET['skip'] ) {
    122     printf( __ngettext( ' %d page not updated. Somebody is editing it.', ' %d pages not updated. Somebody is editing them.', $_GET['skip'] ), number_format_i18n( $_GET['skip'] ) );
    123     unset($_GET['skip']);
     119<?php if ( (int) $_GET['updated'] ) {
     120    printf( __ngettext( '%d page updated.', '%d pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
     121    unset($_GET['updated']);
     122}
     123
     124if ( (int) $_GET['skipped'] ) {
     125    printf( __ngettext( ' %d page not updated, invalid parent page specified.', ' %d pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
     126    unset($_GET['skipped']);
     127}
     128
     129if ( (int) $_GET['locked'] ) {
     130    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'] ) );
     131    unset($_GET['locked']);
    124132} ?>
    125133</p></div>
  • trunk/wp-admin/edit.php

    r9032 r9036  
    3737            if ( isset($_GET['post']) ) {
    3838                check_admin_referer('bulk-posts');
    39                 $_GET['post_status'] = $_GET['_status'];
    40 
    41                 if ( -1 == $_GET['post_author'] )
    42                     unset($_GET['post_author']);
     39
     40                if ( -1 == $_GET['_status'] ) {
     41                    $_GET['post_status'] = null;
     42                    unset($_GET['_status'], $_GET['post_status']);
     43                } else {
     44                    $_GET['post_status'] = $_GET['_status'];
     45                }
    4346
    4447                $done = bulk_edit_posts($_GET);
     
    5255    $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
    5356    if ( isset($done) ) {
    54         $done['upd'] = count( $done['upd'] );
    55         $done['skip'] = count( $done['skip'] );
     57        $done['updated'] = count( $done['updated'] );
     58        $done['skipped'] = count( $done['skipped'] );
     59        $done['locked'] = count( $done['locked'] );
    5660        $sendback = add_query_arg( $done, $sendback );
    57         unset($done);
    5861    }
    5962    wp_redirect($sendback);
     
    101104</div></div>
    102105
     106<div class="wrap">
     107
    103108<?php
    104109if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
     
    107112endif; ?>
    108113
    109 <?php if ( isset($_GET['upd']) && (int) $_GET['upd'] ) { ?>
     114<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) ) { ?>
    110115<div id="message" class="updated fade"><p>
    111 <?php printf( __ngettext( '%d post updated.', '%d posts updated.', $_GET['upd'] ), number_format_i18n( $_GET['upd'] ) );
    112 unset($_GET['upd']);
    113 
    114     if ( isset($_GET['skip']) && (int) $_GET['skip'] ) {
    115         printf( __ngettext( ' %d post not updated. Somebody is editing it.', ' %d posts not updated. Somebody is editing them.', $_GET['skip'] ), number_format_i18n( $_GET['skip'] ) );
    116         unset($_GET['skip']);
    117     } ?>
     116<?php if ( (int) $_GET['updated'] ) {
     117    printf( __ngettext( '%d page updated.', '%d pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
     118    unset($_GET['updated']);
     119}
     120
     121if ( (int) $_GET['skipped'] )
     122    unset($_GET['skipped']);
     123
     124if ( (int) $_GET['locked'] ) {
     125    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'] ) );
     126    unset($_GET['locked']);
     127} ?>
    118128</p></div>
    119129<?php } ?>
    120 
    121 <div class="wrap">
    122130
    123131<ul class="subsubsub">
  • trunk/wp-admin/includes/post.php

    r8973 r9036  
    178178}
    179179
     180// updates all bulk edited posts/pages, adding (but not removing) tags and categories. Skips pages when they would be their own parent or child.
    180181function bulk_edit_posts( $post_data = null ) {
     182    global $wpdb;
    181183
    182184    if ( empty($post_data) )
     
    193195    $post_IDs = array_map( intval, (array) $post_data['post'] );
    194196
     197    $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tags_input', 'post_category' );
     198    foreach ( $reset as $field ) {
     199        if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
     200            unset($post_data[$field]);
     201    }
     202
    195203    if ( isset($post_data['post_category']) ) {
    196204        if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
     
    201209
    202210    if ( isset($post_data['tags_input']) ) {
    203         if ( ! empty($post_data['tags_input']) ) {
    204             $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim($post_data['tags_input'], ' ,') );
    205             $new_tags = explode(',', $new_tags);
    206         } else {
    207             unset($post_data['tags_input']);
    208         }
    209     }
    210 
    211     $reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private' );
    212     foreach ( $reset as $field ) {
    213         if ( isset($post_data[$field]) && '' == $post_data[$field] )
    214             unset($post_data[$field]);
    215     }
    216 
    217     $updated = $skipped = array();
     211        $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim( trim($post_data['tags_input']), ' ,' ) );
     212        $new_tags = explode(',', $new_tags);
     213    }
     214
     215    if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
     216        $pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
     217        $children = array();
     218
     219        for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
     220            $children[] = $parent;
     221
     222            foreach ( $pages as $page ) {
     223                if ( $page->ID == $parent ) {
     224                    $parent = $page->post_parent;
     225                    break;
     226                }
     227            }
     228        }
     229    }
     230
     231    $updated = $skipped = $locked = array();
    218232    foreach ( $post_IDs as $post_ID ) {
    219233
     234        if ( isset($children) && in_array($post_ID, $children) ) {
     235            $skipped[] = $post_ID;
     236            continue;
     237        }
     238       
    220239        if ( wp_check_post_lock( $post_ID ) ) {
    221             $skipped[] = $post_ID;
     240            $locked[] = $post_ID;
    222241            continue;
    223242        }
     
    237256    }
    238257
    239     return array( 'upd' => $updated, 'skip' => $skipped );
     258    return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
    240259}
    241260
  • trunk/wp-admin/includes/template.php

    r9028 r9036  
    694694                    <select name="post_parent">
    695695                        <?php if ( $bulk ) { ?>
    696                         <option value=""><?php _e('- No Change -'); ?></option>
     696                        <option value="-1"><?php _e('- No Change -'); ?></option>
    697697                        <?php } ?>
    698698                        <option value="0"><?php _e('Main Page (no parent)'); ?></option>
     
    707707                    <select name="page_template">
    708708                        <?php if ( $bulk ) { ?>
    709                         <option value=""><?php _e('- No Change -'); ?></option>
     709                        <option value="-1"><?php _e('- No Change -'); ?></option>
    710710                        <?php } ?>
    711711                        <option value="default"><?php _e('Default Template'); ?></option>
     
    785785                    <div class="in">
    786786                    <?php
    787                     $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors');
     787                    $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
    788788                    if ( $bulk ) $users_opt['show_option_none'] = __('- No Change -');
    789789                    wp_dropdown_users( $users_opt ); ?>
     
    810810                    <select name="_status">
    811811                        <?php if ( $bulk ) { ?>
    812                         <option value=""><?php _e('- No Change -'); ?></option>
     812                        <option value="-1"><?php _e('- No Change -'); ?></option>
    813813                            <?php if ( $can_publish ) { ?>
    814814                            <option value="private"><?php _e('Private') ?></option>
  • trunk/wp-admin/js/inline-edit.js

    r8981 r9036  
    9999                var id = $(this).val();
    100100                c = c == '' ? ' class="alternate"' : '';
    101                 te += '<div'+c+'>'+$('#inline_'+id+' .post_title').text()+'</div>';
     101                te += '<div'+c+' id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton">X</a>'+$('#inline_'+id+' .post_title').text()+'</div>';
    102102            }
    103103        });
    104104
    105105        $('#bulk-titles').html(te);
     106        $('#bulk-titles a').click(function() {
     107            var id = $(this).attr('id').substr(1), r = inlineEdit.type+'-'+id;
     108
     109            $('table.widefat input[value="'+id+'"]').attr('checked', '');
     110            $('#ttle'+id).remove();
     111        });
    106112
    107113        // enable autocomplete for tags
  • trunk/wp-admin/wp-admin.css

    r9021 r9036  
    23112311}
    23122312
     2313#bulk-titles div a {
     2314    cursor: pointer;
     2315    display: block;
     2316    float: left;
     2317    height: 10px;
     2318    margin: 3px 3px 0 -2px;
     2319    overflow: hidden;
     2320    position: relative;
     2321    text-indent: -9999px;
     2322    width: 10px;
     2323}
     2324
     2325
    23132326/* Media library */
    23142327#wpbody-content #media-items .describe {
  • trunk/wp-includes/script-loader.php

    r9019 r9036  
    245245        $scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' );
    246246       
    247         $scripts->add( 'inline-edit', '/wp-admin/js/inline-edit.js', array( 'jquery', 'jquery-form', 'suggest' ), '20080926' );
     247        $scripts->add( 'inline-edit', '/wp-admin/js/inline-edit.js', array( 'jquery', 'jquery-form', 'suggest' ), '20080930' );
    248248        $scripts->localize( 'inline-edit', 'inlineEditL10n', array(
    249249            'edit' => __('Double-click to edit')
     
    305305    $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'press-this-ie' );
    306306
    307     $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20080926' );
     307    $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20080930' );
    308308    $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
    309309
  • trunk/wp-includes/user.php

    r9009 r9036  
    427427 * <li>include - User IDs to include.</li>
    428428 * <li>exclude - User IDs to exclude.</li>
     429 * <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element.</li>
    429430 * <li>show - Default is 'display_name'. User table column to display.</li>
    430431 * <li>echo - Default is '1'. Whether to display or retrieve content.</li>
     
    445446        'show_option_all' => '', 'show_option_none' => '',
    446447        'orderby' => 'display_name', 'order' => 'ASC',
    447         'include' => '', 'exclude' => '',
     448        'include' => '', 'exclude' => '', 'multi' => 0,
    448449        'show' => 'display_name', 'echo' => 1,
    449450        'selected' => 0, 'name' => 'user', 'class' => ''
     
    480481    $output = '';
    481482    if ( !empty($users) ) {
    482         $output = "<select name='$name' id='$name' class='$class'>\n";
     483        $id = $multi ? "" : "id='$name'";
     484
     485        $output = "<select name='$name' $id class='$class'>\n";
    483486
    484487        if ( $show_option_all )
Note: See TracChangeset for help on using the changeset viewer.