Make WordPress Core

Ticket #15761: garyc40-15761.2.diff

File garyc40-15761.2.diff, 14.7 KB (added by garyc40, 14 years ago)

patch refreshed, give proper href attribute to Bulk Edit Cancel link

  • wp-admin/edit.php

    diff --git wp-admin/edit.php wp-admin/edit.php
    index 39424ac..1427ef8 100644
    if ( 'post' != $post_type ) { 
    4747
    4848$doaction = $wp_list_table->current_action();
    4949
    50 if ( $doaction ) {
     50if ( $doaction && ! $wp_list_table->is_bulk_edit_form() ) {
    5151        check_admin_referer('bulk-posts');
    5252
    5353        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
    if ( $doaction ) { 
    6666                $post_ids = explode( ',', $_REQUEST['ids'] );
    6767        } elseif ( !empty( $_REQUEST['post'] ) ) {
    6868                $post_ids = array_map('intval', $_REQUEST['post']);
     69        } elseif ( ! empty( $_REQUEST['bulk_post'] ) ) {
     70                $post_ids = array_map( 'intval', $_REQUEST['bulk_post'] );
    6971        }
    70 
     72       
    7173        if ( !isset( $post_ids ) ) {
    7274                wp_redirect( $sendback );
    7375                exit;
    if ( $doaction ) { 
    8688                                $trashed++;
    8789                        }
    8890                        $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback );
     91                        $sendback = remove_query_arg( array( 'updated' ), $sendback );
    8992                        break;
    9093                case 'untrash':
    9194                        $untrashed = 0;
    if ( $doaction ) { 
    127130                                $done['skipped'] = count( $done['skipped'] );
    128131                                $done['locked'] = count( $done['locked'] );
    129132                                $sendback = add_query_arg( $done, $sendback );
     133                                $sendback = remove_query_arg( array( 'bulk_post' ), $sendback );
    130134                        }
     135
    131136                        break;
    132137        }
    133138
    134139        $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view'), $sendback );
    135 
    136140        wp_redirect($sendback);
    137141        exit();
    138142} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
    $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated' 
    256260
    257261<?php
    258262if ( $wp_list_table->has_items() )
    259         $wp_list_table->inline_edit();
     263        if ( $wp_list_table->is_bulk_edit_form() ) {
     264                $wp_list_table->inline_edit( 'inline' );
     265        } else {
     266                $wp_list_table->inline_edit();
     267        }
    260268?>
    261269
    262270<div id="ajax-response"></div>
  • wp-admin/includes/class-wp-list-table.php

    diff --git wp-admin/includes/class-wp-list-table.php wp-admin/includes/class-wp-list-table.php
    index bd5c546..0ac1e17 100644
    class WP_List_Table { 
    714714        </tr>
    715715        </tfoot>
    716716
     717        <?php do_action( 'wp_list_table_tbody' ); ?>
     718
    717719        <tbody id="the-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
    718720                <?php $this->display_rows_or_placeholder(); ?>
    719721        </tbody>
  • wp-admin/includes/class-wp-posts-list-table.php

    diff --git wp-admin/includes/class-wp-posts-list-table.php wp-admin/includes/class-wp-posts-list-table.php
    index e623ab5..76ee6f8 100644
    class WP_Posts_List_Table extends WP_List_Table { 
    1717         * @access protected
    1818         */
    1919        var $hierarchical_display;
     20       
     21        /**
     22         * Whether the bulk edit form should be displayed (when JavaScript is disabled)
     23         *
     24         * @since 3.1.0
     25         * @var bool
     26         * @access protected
     27         */
     28        var $bulk_edit_display = false;
    2029
    2130        /**
    2231         * Holds the number of pending comments for each post
    class WP_Posts_List_Table extends WP_List_Table { 
    8493
    8594                return current_user_can( $post_type_object->cap->edit_posts );
    8695        }
     96       
     97        function is_bulk_edit_form() {
     98                return $this->bulk_edit_display;
     99        }
     100       
     101        function display_bulk_edit_form() {
     102                $this->inline_edit( 'bulk' );
     103        }
    87104
    88105        function prepare_items() {
    89106                global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode;
    class WP_Posts_List_Table extends WP_List_Table { 
    237254                if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
    238255                        return 'delete_all';
    239256
    240                 return parent::current_action();
     257                if ( isset( $_REQUEST['bulk_post'] ) ) {
     258                        return 'edit';
     259                }
     260
     261                $action = parent::current_action();
     262
     263                if ( $action == 'edit' && ! isset( $_REQUEST['bulk_edit']) ) {                 
     264                        $this->bulk_edit_display = true;
     265                        add_action( 'wp_list_table_tbody', array( &$this, 'display_bulk_edit_form' ) );
     266                }
     267               
     268                return $action;
    241269        }
    242270
    243271        function pagination( $which ) {
    class WP_Posts_List_Table extends WP_List_Table { 
    496524                        switch ( $column_name ) {
    497525
    498526                        case 'cb':
     527                                $checked = ( isset( $_REQUEST['post'] ) && in_array( $post->ID, $_REQUEST['post'] ) ) ? ' checked="checked"' : '';
    499528                        ?>
    500                         <th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
     529                        <th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>"<?php echo $checked; ?> /><?php } ?></th>
    501530                        <?php
    502531                        break;
    503532
    class WP_Posts_List_Table extends WP_List_Table { 
    684713        }
    685714
    686715        /**
    687          * Outputs the hidden row displayed when inline editing
     716         * Outputs inline editing forms
    688717         *
    689718         * @since 3.1.0
     719         *
     720         * @param string $which Specify which form to be output. Can be one of the following: 'inline', 'bulk', or 'both'
    690721         */
    691         function inline_edit() {
     722        function inline_edit( $which = 'both' ) {
    692723                global $mode;
    693724
    694725                $screen = get_current_screen();
    class WP_Posts_List_Table extends WP_List_Table { 
    714745                $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
    715746                $can_publish = current_user_can( $post_type_object->cap->publish_posts );
    716747                $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
    717 
     748                $as_tbody = ( $which == 'bulk' && $this->bulk_edit_display );
     749               
     750                if ( $as_tbody && empty( $_REQUEST['post'] ) )
     751                        return;
     752               
     753                $style = ( $as_tbody ) ? '' : ' style="display:none;"';
    718754        ?>
    719755
    720         <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
     756        <?php if ( ! $as_tbody ): ?>
     757        <form method="get" action=""><table<?php echo $style; ?>><?php endif; ?>
     758                <tbody id="inlineedit">
    721759                <?php
    722760                $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
    723761                $bulk = 0;
    724                 while ( $bulk < 2 ) { ?>
    725 
    726                 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
     762                $max = 2;
     763               
     764                if ( $which == 'bulk' )
     765                        $bulk = 1;
     766               
     767                if ( $which == 'inline' )
     768                        $max = 1;
     769               
     770                while ( $bulk < $max ) { ?>
     771
     772                <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-editor inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
    727773                        echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
    728                 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
     774                ?>"<?php echo $style; ?>><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
    729775
    730776                <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
    731777                        <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
    class WP_Posts_List_Table extends WP_List_Table { 
    734780        if ( post_type_supports( $screen->post_type, 'title' ) ) :
    735781                if ( $bulk ) : ?>
    736782                        <div id="bulk-title-div">
    737                                 <div id="bulk-titles"></div>
     783                                <div id="bulk-titles">
     784                                        <?php
     785                                        if ( $as_tbody ) {
     786                                                $post_ids = $_REQUEST['post'];
     787                                               
     788                                                foreach ( $post_ids as $post_id ) {
     789                                                        $post = get_post( $post_id );
     790                                                        $title = esc_html( apply_filters( 'the_title', $post->post_title ) );
     791                                                        $delete_link = add_query_arg( array( 'post' => array_diff( $post_ids, array( $post_id ) ) ), $_SERVER['REQUEST_URI'] );
     792                                                        ?>
     793                                                                <div id="ttle<?php echo $post_id; ?>">
     794                                                                        <a id="_<?php echo $post_id; ?>" class="ntdelbutton" title="Remove From Bulk Edit" href="<?php echo $delete_link; ?>">X</a>
     795                                                                        <?php echo $title; ?>
     796                                                                        <input type="hidden" name="bulk_post[]" value="<?php echo $post_id; ?>" />
     797                                                                </div>
     798                                                        <?php
     799                                                }
     800                                        }
     801                                        ?>
     802                                </div>
    738803                        </div>
    739804
    740805        <?php else : // $bulk ?>
    class WP_Posts_List_Table extends WP_List_Table { 
    812877
    813878                </div></fieldset>
    814879
    815         <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
     880        <?php if ( count( $hierarchical_taxonomies ) && ( !$bulk || $as_tbody ) ) : ?>
    816881
    817882                <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
    818883
    class WP_Posts_List_Table extends WP_List_Table { 
    831896
    832897                </div></fieldset>
    833898
    834         <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
     899        <?php endif; // count( $hierarchical_taxonomies ) && ( !$bulk || $as_tbody ) ?>
    835900
    836901                <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
    837902
    838         <?php
    839                 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
    840                         echo $authors_dropdown;
    841         ?>
    842 
    843903        <?php if ( $post_type_object->hierarchical ) : ?>
    844904
    845905                        <label>
    class WP_Posts_List_Table extends WP_List_Table { 
    878938                endif; // post_type_supports page-attributes
    879939        endif; // $post_type_object->hierarchical ?>
    880940
    881         <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
     941        <?php if ( count( $flat_taxonomies ) && ( !$bulk || $as_tbody ) ) : ?>
    882942
    883943        <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
    884944
    class WP_Posts_List_Table extends WP_List_Table { 
    889949
    890950        <?php endforeach; //$flat_taxonomies as $taxonomy ?>
    891951
    892         <?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
     952        <?php endif; // count( $flat_taxonomies ) && ( !$bulk || $as_tbody )  ?>
     953       
     954        <?php
     955                if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
     956                        echo $authors_dropdown;
     957        ?>
    893958
    894959        <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
    895960                if ( $bulk ) : ?>
    class WP_Posts_List_Table extends WP_List_Table { 
    9921057                }
    9931058        ?>
    9941059                <p class="submit inline-edit-save">
    995                         <a accesskey="c" href="#inline-edit" title="<?php _e( 'Cancel' ); ?>" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
     1060                        <a accesskey="c" href="<?php echo esc_url( remove_query_arg( 'post', wp_get_referer() ) ); ?>" title="<?php _e( 'Cancel' ); ?>" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
    9961061                        <?php if ( ! $bulk ) {
    9971062                                wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
    9981063                                $update_text = __( 'Update' );
    class WP_Posts_List_Table extends WP_List_Table { 
    10021067                        <?php } else {
    10031068                                submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
    10041069                        } ?>
     1070                       
    10051071                        <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
    10061072                        <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
    10071073                        <br class="clear" />
    class WP_Posts_List_Table extends WP_List_Table { 
    10111077                $bulk++;
    10121078                }
    10131079?>
    1014                 </tbody></table></form>
     1080                </tbody>
     1081                <?php if ( ! $as_tbody ): ?> </table></form> <?php endif; ?>
    10151082<?php
    10161083        }
    10171084}
  • wp-admin/includes/post.php

    diff --git wp-admin/includes/post.php wp-admin/includes/post.php
    index 510d59f..f595f2b 100644
    function bulk_edit_posts( $post_data = null ) { 
    255255        if ( empty($post_data) )
    256256                $post_data = &$_POST;
    257257
     258        if ( isset( $post_data['bulk_post'] ) ) {
     259                $post_data['post'] = array_unique( array_merge( $post_data['post'], $post_data['bulk_post'] ) );
     260        }
     261
    258262        if ( isset($post_data['post_type']) )
    259263                $ptype = get_post_type_object($post_data['post_type']);
    260264        else
  • wp-admin/js/inline-edit-post.dev.js

    diff --git wp-admin/js/inline-edit-post.dev.js wp-admin/js/inline-edit-post.dev.js
    index 96b36fe..8f6fbf5 100644
     
    11(function($) {
    22inlineEditPost = {
     3        bulkEditing : false,
    34
    45        init : function(){
    56                var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
    inlineEditPost = { 
    4647                        inlineEditPost.edit(this);
    4748                        return false;
    4849                });
     50               
     51                $('.check-column input').live('click', function(){
     52                        var id;
     53                        if (inlineEditPost.bulkEditing) {
     54                                id = $(this).val();
     55                                if ($(this).attr('checked')) {
     56                                        inlineEditPost.addToBulk(id);
     57                                } else {
     58                                        inlineEditPost.removeFromBulk(id);
     59                                }
     60                        }
     61                });
     62               
     63                $('#bulk-titles a').live('click', function(){
     64                        var id = $(this).attr('id').substr(1);
     65                        inlineEditPost.removeFromBulk(id);
     66                });
    4967
    5068                $('#bulk-title-div').parents('fieldset').after(
    5169                        $('#inline-edit fieldset.inline-edit-categories').clone()
    inlineEditPost = { 
    84102                var t = this;
    85103                $(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
    86104        },
     105       
     106        addToBulk : function(id) {
     107                var theTitle, item;
     108                theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
     109                item = '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
     110                $('#bulk-titles').append(item);
     111        },
     112       
     113        removeFromBulk : function(id) {
     114                $('table.widefat input[value="'+id+'"]').attr('checked', '');
     115                $('#ttle'+id).remove();
     116        },
    87117
    88118        setBulk : function(){
    89                 var te = '', type = this.type, tax, c = true;
     119                var type = this.type, tax, c = true;
    90120                this.revert();
     121                this.bulkEditing = true;
    91122
    92123                $('#bulk-edit td').attr('colspan', $('.widefat:first thead th:visible').length);
    93124                $('table.widefat tbody').prepend( $('#bulk-edit') );
    inlineEditPost = { 
    96127                $('tbody th.check-column input[type="checkbox"]').each(function(i){
    97128                        if ( $(this).attr('checked') ) {
    98129                                c = false;
    99                                 var id = $(this).val(), theTitle;
    100                                 theTitle = $('#inline_'+id+' .post_title').text() || inlineEditL10n.notitle;
    101                                 te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
     130                                var id = $(this).val();
     131                                inlineEditPost.addToBulk(id);
    102132                        }
    103133                });
    104134
    105135                if ( c )
    106136                        return this.revert();
    107137
    108                 $('#bulk-titles').html(te);
    109                 $('#bulk-titles a').click(function(){
    110                         var id = $(this).attr('id').substr(1);
    111 
    112                         $('table.widefat input[value="'+id+'"]').attr('checked', '');
    113                         $('#ttle'+id).remove();
    114                 });
     138//              $('#bulk-titles').html(te);
    115139
    116140                // enable autocomplete for tags
    117141                if ( 'post' == type ) {
    inlineEditPost = { 
    268292                                $('table.widefat #bulk-edit').removeClass('inline-editor').hide();
    269293                                $('#bulk-titles').html('');
    270294                                $('#inlineedit').append( $('#bulk-edit') );
     295                                this.bulkEditing = false;
    271296                        } else {
    272297                                $('#'+id).remove();
    273298                                id = id.substr( id.lastIndexOf('-') + 1 );
  • wp-admin/post.php

    diff --git wp-admin/post.php wp-admin/post.php
    index 0dae46d..3bfcb1a 100644
    case 'trash': 
    221221
    222222        if ( ! wp_trash_post($post_id) )
    223223                wp_die( __('Error in moving to Trash.') );
     224        $sendback = remove_query_arg( 'updated', $sendback );
    224225
    225226        wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
    226227        exit();