Ticket #12684: 12684.4.patch
File 12684.4.patch, 10.7 KB (added by , 6 years ago) |
---|
-
src/wp-admin/edit-tags.php
144 144 wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); 145 145 exit; 146 146 147 case '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 147 169 case 'editedtag': 148 170 $tag_ID = (int) $_POST['tag_ID']; 149 171 check_admin_referer( 'update-tag_' . $tag_ID ); -
src/wp-admin/includes/class-wp-terms-list-table.php
156 156 $actions['delete'] = __( 'Delete' ); 157 157 } 158 158 159 if ( is_taxonomy_hierarchical( $this->screen->taxonomy ) ) { 160 $actions['edit'] = __( 'Edit' ); 161 } 162 159 163 return $actions; 160 164 } 161 165 … … 164 168 * @return string 165 169 */ 166 170 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'] ) ) { 168 172 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 } 169 176 170 177 return parent::current_action(); 171 178 } … … 585 592 return; 586 593 ?> 587 594 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 590 597 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 ); 606 599 607 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true);600 list( $columns ) = $this->get_column_info(); 608 601 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; 610 605 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 } 614 613 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 ) { 619 616 ?> 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 ) : ?> 620 620 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 ?> 632 696 </tbody></table></form> 633 697 <?php 634 698 } -
src/wp-admin/js/inline-edit-tax.js
62 62 }); 63 63 64 64 /** 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 /** 65 72 * @summary Saves the inline edits when clicking the save button. 66 73 */ 67 74 $( '.save', row ).click( function() { … … 84 91 $( '#posts-filter input[type="submit"]' ).mousedown( function() { 85 92 t.revert(); 86 93 }); 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 }); 87 107 }, 88 108 89 109 /** … … 105 125 }, 106 126 107 127 /** 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 /** 108 168 * Shows the quick editor 109 169 * 110 170 * @since 2.7.0 … … 255 315 revert : function() { 256 316 var id = $('table.widefat tr.inline-editor').attr('id'); 257 317 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 ) { 259 323 $( 'table.widefat .spinner' ).removeClass( 'is-active' ); 260 324 $('#'+id).siblings('tr.hidden').addBack().remove(); 261 325 id = id.substr( id.lastIndexOf('-') + 1 );