Make WordPress Core

Ticket #12684: 12684.4.patch

File 12684.4.patch, 10.7 KB (added by vinod dalvi, 8 years ago)

Refreshed Patch

  • src/wp-admin/edit-tags.php

     
    144144        wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
    145145        exit;
    146146
     147case 'edit-parent':
     148        $parent_id = (int) $_REQUEST['parent'];
     149
     150        if ( $parent_id != -1 ) {
     151                $terms = (array) $_REQUEST['delete_tags'];
     152
     153                foreach ( $terms as $term_id ) {
     154
     155                        if ( $term_id == $parent_id ) {
     156                                continue;
     157                        }
     158
     159                        $update_parent = wp_update_term($term_id, $_REQUEST['taxonomy'], array( 'parent' => $parent_id ) );
     160
     161                        if ( $update_parent && ! is_wp_error( $update_parent ) ) {
     162                                $location = add_query_arg( 'message', 3, $location );
     163                        }
     164                }
     165        }
     166
     167        break;
     168
    147169case 'editedtag':
    148170        $tag_ID = (int) $_POST['tag_ID'];
    149171        check_admin_referer( 'update-tag_' . $tag_ID );
  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    156156                        $actions['delete'] = __( 'Delete' );
    157157                }
    158158
     159                if ( is_taxonomy_hierarchical( $this->screen->taxonomy ) ) {
     160                        $actions['edit'] = __( 'Edit' );
     161                }
     162
    159163                return $actions;
    160164        }
    161165
     
    164168         * @return string
    165169         */
    166170        public function current_action() {
    167                 if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) )
     171                if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) {
    168172                        return 'bulk-delete';
     173                } else if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'edit' == $_REQUEST['action'] || 'edit-category' == $_REQUEST['screen'] ) ) {
     174                        return 'edit-parent';
     175                }
    169176
    170177                return parent::current_action();
    171178        }
     
    585592                        return;
    586593?>
    587594
    588         <form method="get"><table style="display: none"><tbody id="inlineedit">
    589                 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
     595                <form method="get"><table style="display: none"><tbody id="inlineedit">
     596<?php
    590597
    591                         <fieldset>
    592                                 <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend>
    593                                 <div class="inline-edit-col">
    594                                 <label>
    595                                         <span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
    596                                         <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
    597                                 </label>
    598         <?php if ( !global_terms_enabled() ) { ?>
    599                                 <label>
    600                                         <span class="title"><?php _e( 'Slug' ); ?></span>
    601                                         <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
    602                                 </label>
    603         <?php } ?>
    604                         </div></fieldset>
    605         <?php
     598                        $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
    606599
    607                 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
     600                        list( $columns ) = $this->get_column_info();
    608601
    609                 list( $columns ) = $this->get_column_info();
     602                        foreach ( $columns as $column_name => $column_display_name ) {
     603                                        if ( isset( $core_columns[$column_name] ) )
     604                                                        continue;
    610605
    611                 foreach ( $columns as $column_name => $column_display_name ) {
    612                         if ( isset( $core_columns[$column_name] ) )
    613                                 continue;
     606                                        if ( $bulk ) {
     607                                                do_action( 'bulk_edit_custom_box', $column_name, $this->screen->taxonomy );
     608                                        } else {
     609                                                /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
     610                                                do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
     611                                        }
     612                        }
    614613
    615                         /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
    616                         do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
    617                 }
    618 
     614                        $bulk = 0;
     615                        while ( $bulk < 2 ) {
    619616        ?>
     617                        <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "inline-edit-" . $this->screen->taxonomy; echo $bulk ? " bulk-edit-row bulk-edit-row bulk-edit-{$this->screen->taxonomy}" : " quick-edit-row quick-edit-row inline-edit-{$this->screen->taxonomy}"; ?>" style="display: none">
     618                                <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
     619                                        <?php if ( $bulk ) : ?>
    620620
    621                 <p class="inline-edit-save submit">
    622                         <button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button>
    623                         <button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button>
    624                         <span class="spinner"></span>
    625                         <span class="error" style="display:none;"></span>
    626                         <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
    627                         <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
    628                         <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
    629                         <br class="clear" />
    630                 </p>
    631                 </td></tr>
     621                                                <fieldset class="inline-edit-col-left">
     622                                                        <legend class="inline-edit-legend"><?php echo __( 'Bulk Edit' ); ?></legend>
     623                                                        <div class="inline-edit-col">
     624                                                                <div id="bulk-title-div">
     625                                                                        <div id="bulk-titles"></div>
     626                                                                </div>
     627                                                        </div>
     628                                                </fieldset>
     629                                                <fieldset class="inline-edit-col-left">
     630                                                        <span class="title inline-edit-categories-label"><?php _e( 'Parent Category' ) ?></span>
     631                                                        <div class="inline-edit-col">
     632                                                                <div class="bulk-edit-col">
     633                                                                        <?php
     634
     635                                                                                wp_dropdown_categories( array(
     636                                                                                        'hide_empty'       => 0,
     637                                                                                        'hide_if_empty'    => false,
     638                                                                                        'name'             => 'parent',
     639                                                                                        'orderby'          => 'name',
     640                                                                                        'taxonomy'         => $this->screen->taxonomy,
     641                                                                                        'hierarchical'     => true,
     642                                                                                        'show_option_none' => __( 'None' )
     643                                                                                ) );
     644
     645                                                                        ?>
     646                                                                </div>
     647                                                        </div>
     648                                                        </div>
     649                                                </fieldset>
     650                                        <?php else :  ?>
     651                                                <fieldset>
     652                                                        <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
     653                                                        <div class="inline-edit-col">
     654                                                                <label>
     655                                                                        <span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
     656                                                                        <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
     657                                                                </label>
     658                                                                <?php if ( ! global_terms_enabled() ) { ?>
     659                                                                        <label>
     660                                                                                <span class="title"><?php _e( 'Slug' ); ?></span>
     661                                                                                <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
     662                                                                        </label>
     663                                                                <?php } ?>
     664                                                        </div>
     665                                                </fieldset>
     666                                        <?php endif; ?>
     667
     668                                        <p class="inline-edit-save submit">
     669                                                <a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
     670
     671                                                <?php
     672                                                if ( $bulk ) :
     673                                                        submit_button( __( 'Update' ), 'button-primary alignright', 'edit-parent', false );
     674                                                else :
     675                                                ?>
     676                                                <a href="#inline-edit" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></a>
     677                                                <?php endif;?>
     678
     679                                                <span class="spinner"></span>
     680                                                <span class="error" style="display:none;"></span>
     681                                                <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
     682
     683                                                <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
     684                                                <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
     685                                                <?php if ( $bulk ) { ?>
     686                                                                <input type="hidden" name="screen" value="<?php echo esc_attr( $this->screen->id ); ?>" />
     687                                                <?php } ?>
     688                                                <br class="clear" />
     689                                        </p>
     690                                 </td>
     691                        </tr>
     692                        <?php
     693                                $bulk++;
     694                        }
     695                        ?>
    632696                </tbody></table></form>
    633697        <?php
    634698        }
  • src/wp-admin/js/inline-edit-tax.js

     
    6262                });
    6363
    6464                /**
     65                 * @summary Cancels bulk editing when clicking the cancel button on bulk edit form.
     66                 */
     67                $( '.cancel' ).click( function() {
     68                        return inlineEditTax.revert();
     69                });
     70
     71                /**
    6572                 * @summary Saves the inline edits when clicking the save button.
    6673                 */
    6774                $( '.save', row ).click( function() {
     
    8491                $( '#posts-filter input[type="submit"]' ).mousedown( function() {
    8592                        t.revert();
    8693                });
     94
     95                /**
     96                 * @summary Saves the bulk edits on submitting the bulk edit form.
     97                 */
     98                $( '#doaction, #doaction2' ).click( function( e ) {
     99                        var n = $(this).attr( 'id' ).substr(2);
     100                        if ( 'edit' === $( 'select[name="' + n + '"]' ).val() ) {
     101                                e.preventDefault();
     102                                t.setBulk();
     103                        } else if ( $( 'form#posts-filter tr.inline-editor' ).length > 0 ) {
     104                                t.revert();
     105                        }
     106                });
    87107        },
    88108
    89109        /**
     
    105125        },
    106126
    107127        /**
     128         * Saves the bulk edits.
     129         *
     130         * @since 4.7.4
     131         *
     132         * @this inlineEditTax
     133         * @memberof inlineEditTax
     134         * @returns {void}
     135         */
     136        setBulk : function() {
     137                var te = '', c = true;
     138                this.revert();
     139                $( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
     140                $( 'table.widefat tbody' ).prepend( $( '#bulk-edit' ) ).prepend( '<tr class="hidden"></tr>' );
     141                $( '#bulk-edit' ).addClass( 'inline-editor' ).show();
     142
     143                $( 'tbody th.check-column input[type="checkbox"]' ).each( function() {
     144                        if ( $(this).prop( 'checked' ) ) {
     145                                c = false;
     146                                var id = $(this).val(), theTitle;
     147                                theTitle = $('#tag-'+id+' .row-title').html() || inlineEditL10n.notitle;
     148                                te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+inlineEditL10n.ntdeltitle+'">X</a>'+theTitle+'</div>';
     149                        }
     150                });
     151
     152                if ( c ) {
     153                        return this.revert();
     154                }
     155
     156                $( '#bulk-titles' ).html(te);
     157
     158                $( '#bulk-titles a' ).click( function() {
     159                        var id = $(this).attr( 'id' ).substr(1);
     160                        $( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
     161                        $( '#ttle' + id ).remove();
     162                })
     163
     164                $( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
     165        },
     166
     167        /**
    108168         * Shows the quick editor
    109169         *
    110170         * @since 2.7.0
     
    255315        revert : function() {
    256316                var id = $('table.widefat tr.inline-editor').attr('id');
    257317
    258                 if ( id ) {
     318                if ( 'bulk-edit' === id ) {
     319                        $( 'table.widefat #bulk-edit' ).removeClass( 'inline-editor' ).hide().siblings( 'tr.hidden' ).remove();
     320                        $( '#bulk-titles' ).empty();
     321                        $( '#inlineedit' ).append( $( '#bulk-edit' ) );
     322                } else if ( id ) {
    259323                        $( 'table.widefat .spinner' ).removeClass( 'is-active' );
    260324                        $('#'+id).siblings('tr.hidden').addBack().remove();
    261325                        id = id.substr( id.lastIndexOf('-') + 1 );