Ticket #11302: 11302.3.patch
File 11302.3.patch, 4.3 KB (added by , 11 months ago) |
---|
-
src/js/_enqueues/admin/inline-edit-post.js
diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index e7d4496b88..9427f1a173 100644
a b window.wp = window.wp || {}; 178 178 */ 179 179 setBulk : function(){ 180 180 var te = '', type = this.type, c = true; 181 var checkedPosts = $( 'tbody th.check-column input[type="checkbox"]:checked' ); 182 var categories = {}; 181 183 this.revert(); 182 184 183 185 $( '#bulk-edit td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length ); … … window.wp = window.wp || {}; 217 219 // Populate the list of items to bulk edit. 218 220 $( '#bulk-titles' ).html( '<ul id="bulk-titles-list" role="list">' + te + '</ul>' ); 219 221 222 // Gather up some statistics on which of these checked posts are in which categories. 223 checkedPosts.each( function() { 224 var id = $( this ).val(); 225 var checked = $( '#category_' + id ).text().split( ',' ); 226 227 checked.map( function( cid ) { 228 categories[ cid ] || ( categories[ cid ] = 0 ); 229 // Just record that this category is checked. 230 categories[ cid ]++; 231 } ); 232 } ); 233 234 // Compute initial states. 235 $( '.inline-edit-categories input[name="post_category[]"]' ).each( function() { 236 if ( categories[ $( this ).val() ] == checkedPosts.length ) { 237 // If the number of checked categories matches the number of selected posts, then all posts are in this category. 238 $( this ).prop( 'checked', true ); 239 } else if ( categories[ $( this ).val() ] > 0 ) { 240 // If the number is less than the number of selected posts, then it's indeterminate. 241 $( this ).prop( 'indeterminate', true ); 242 if ( ! $( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).length ) { 243 // Set indeterminate states for the backend. 244 $( this ).attr( 'label', wp.i18n.__( 'Some selected posts have this category' ) ).after( '<input type="hidden" name="indeterminate_post_category[]" value="' + $( this ).val() + '">' ); 245 } 246 } 247 } ); 248 249 $( '.inline-edit-categories input[name="post_category[]"]' ).on( 'change', function() { 250 // Remove the indeterminate flags as there was a specific state change. 251 $( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).remove(); 252 } ); 253 254 $( '.inline-edit-save button' ).on( 'click', function() { 255 $( '.inline-edit-categories input[name="post_category[]"]' ).prop( 'indeterminate', false ); 256 } ); 257 220 258 /** 221 259 * Binds on click events to handle the list of items to bulk edit. 222 260 * -
src/wp-admin/css/list-tables.css
diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index 07cbc6229d..ad3c5522e6 100644
a b ul.cat-checklist { 1147 1147 overflow-y: scroll; 1148 1148 } 1149 1149 1150 ul.cat-checklist input[name="post_category[]"]:indeterminate::before { 1151 content: ''; 1152 border-top: 2px solid grey; 1153 width: 65%; 1154 height: 2px; 1155 position: absolute; 1156 top: calc( 50% + 1px ); 1157 left: 50%; 1158 transform: translate( -50%, -50% ); 1159 } 1160 1150 1161 #bulk-titles .ntdelbutton, 1151 1162 #bulk-titles .ntdeltitle, 1152 1163 .inline-edit-row fieldset ul.cat-checklist label { -
src/wp-admin/includes/post.php
diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index c93ac71bec..2e33e1fdb4 100644
a b function bulk_edit_posts( $post_data = null ) { 649 649 } 650 650 651 651 if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) { 652 $cats = (array) wp_get_post_categories( $post_id ); 653 $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) ); 652 $cats = (array) wp_get_post_categories( $post_id ); 653 654 if ( 655 isset( $post_data['indeterminate_post_category'] ) 656 && is_array( $post_data['indeterminate_post_category'] ) 657 ) { 658 $indeterminate_post_category = $post_data['indeterminate_post_category']; 659 } else { 660 $indeterminate_post_category = array(); 661 } 662 663 $indeterminate_cats = array_intersect( $cats, $indeterminate_post_category ); 664 $determinate_cats = array_diff( $new_cats, $indeterminate_post_category ); 665 $post_data['post_category'] = array_unique( array_merge( $indeterminate_cats, $determinate_cats ) ); 666 654 667 unset( $post_data['tax_input']['category'] ); 655 668 } 656 669