Ticket #47048: 47048-6.diff
File 47048-6.diff, 6.1 KB (added by , 5 years ago) |
---|
-
src/js/_enqueues/lib/nav-menu.js
diff --git src/js/_enqueues/lib/nav-menu.js src/js/_enqueues/lib/nav-menu.js index 3f1f9a7..f6c070c 100644
208 208 // Add the items 209 209 api.addItemToMenu(menuItems, processMethod, function(){ 210 210 // Deselect the items and hide the ajax spinner 211 checkboxes.removeAttr('checked'); 211 checkboxes.prop( 'checked', false ); 212 t.find( '.button-controls .select-all' ).prop( 'checked', false ); 212 213 t.find( '.button-controls .spinner' ).removeClass( 'is-active' ); 213 214 }); 214 215 }); … … 1061 1062 1062 1063 attachTabsPanelListeners : function() { 1063 1064 $('#menu-settings-column').bind('click', function(e) { 1064 var selectAreaMatch, panelId, wrapper, items,1065 var selectAreaMatch, selectAll, panelId, wrapper, items, 1065 1066 target = $(e.target); 1066 1067 1067 1068 if ( target.hasClass('nav-tab-link') ) { … … 1071 1072 wrapper = target.parents('.accordion-section-content').first(); 1072 1073 1073 1074 // upon changing tabs, we want to uncheck all checkboxes 1074 $('input', wrapper). removeAttr('checked');1075 $('input', wrapper).prop( 'checked', false ); 1075 1076 1076 1077 $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); 1077 1078 $('#' + panelId, wrapper).removeClass('tabs-panel-inactive').addClass('tabs-panel-active'); … … 1090 1091 } 1091 1092 1092 1093 e.preventDefault(); 1093 } else if ( target.hasClass('select-all') ) { 1094 selectAreaMatch = /#(.*)$/.exec(e.target.href); 1095 if ( selectAreaMatch && selectAreaMatch[1] ) { 1096 items = $('#' + selectAreaMatch[1] + ' .tabs-panel-active .menu-item-title input'); 1097 if( items.length === items.filter(':checked').length ) 1098 items.removeAttr('checked'); 1099 else 1100 items.prop('checked', true); 1101 return false; 1094 } else if ( target.hasClass( 'select-all' ) ) { 1095 selectAreaMatch = target.closest( '.button-controls' ).data( 'items-type' ); 1096 if ( selectAreaMatch ) { 1097 items = $( '#' + selectAreaMatch + ' .tabs-panel-active .menu-item-title input' ); 1098 1099 if ( items.length === items.filter( ':checked' ).length && ! target.is( ':checked' ) ) { 1100 items.prop( 'checked', false ); 1101 } else if ( target.is(':checked') ) { 1102 items.prop( 'checked', true ); 1103 } 1104 } 1105 } else if ( target.hasClass( 'menu-item-checkbox' ) ) { 1106 selectAreaMatch = target.closest( '.tabs-panel-active' ).parent().attr( 'id' ); 1107 if ( selectAreaMatch ) { 1108 items = $( '#' + selectAreaMatch + ' .tabs-panel-active .menu-item-title input' ); 1109 selectAll = $( '.button-controls[data-items-type="' + selectAreaMatch + '"] .select-all' ); 1110 1111 if ( items.length === items.filter( ':checked' ).length && ! selectAll.is( ':checked' ) ) { 1112 selectAll.prop( 'checked', true ); 1113 } else if ( selectAll.is( ':checked' ) ) { 1114 selectAll.prop( 'checked', false ); 1115 } 1102 1116 } 1103 1117 } else if ( target.hasClass('submit-add-to-menu') ) { 1104 1118 api.registerChange(); … … 1226 1240 pattern = /menu-item[(\[^]\]*/, 1227 1241 $items = $('<div>').html(resp).find('li'), 1228 1242 wrapper = panel.closest( '.accordion-section-content' ), 1243 selectAll = wrapper.find( '.button-controls .select-all' ), 1229 1244 $item; 1230 1245 1231 1246 if( ! $items.length ) { … … 1260 1275 $('.categorychecklist', panel).html( $items ); 1261 1276 $( '.spinner', panel ).removeClass( 'is-active' ); 1262 1277 wrapper.removeClass( 'has-no-menu-item' ); 1278 1279 if ( selectAll.is( ':checked' ) ) { 1280 selectAll.prop( 'checked', false ); 1281 } 1263 1282 }, 1264 1283 1265 1284 /** -
src/wp-admin/includes/nav-menu.php
diff --git src/wp-admin/includes/nav-menu.php src/wp-admin/includes/nav-menu.php index 25fddcf..11e8c7f 100644
function wp_nav_menu_item_post_type_meta_box( $object, $box ) { 593 593 594 594 $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args ); 595 595 596 if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {597 $checkbox_items = preg_replace( '/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items );598 599 }600 601 596 echo $checkbox_items; 602 597 ?> 603 598 </ul> … … function wp_nav_menu_item_post_type_meta_box( $object, $box ) { 608 603 <?php endif; ?> 609 604 </div><!-- /.tabs-panel --> 610 605 611 <p class="button-controls wp-clearfix"> 612 <span class="list-controls"> 613 <a href=" 614 <?php 615 echo esc_url( 616 add_query_arg( 617 array( 618 $post_type_name . '-tab' => 'all', 619 'selectall' => 1, 620 ), 621 remove_query_arg( $removed_args ) 622 ) 623 ); 624 ?> 625 #posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 606 <p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>"> 607 <span class="list-controls hide-if-no-js"> 608 <input type="checkbox" id="<?php echo esc_attr( $post_type_name . '-tab' ); ?>" class="select-all" /> 609 <label for="<?php echo esc_attr( $post_type_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label> 626 610 </span> 627 611 628 612 <span class="add-to-menu"> … … function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { 848 832 </ul> 849 833 </div><!-- /.tabs-panel --> 850 834 851 <p class="button-controls wp-clearfix"> 852 <span class="list-controls"> 853 <a href=" 854 <?php 855 echo esc_url( 856 add_query_arg( 857 array( 858 $taxonomy_name . '-tab' => 'all', 859 'selectall' => 1, 860 ), 861 remove_query_arg( $removed_args ) 862 ) 863 ); 864 ?> 865 #taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a> 835 <p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>"> 836 <span class="list-controls hide-if-no-js"> 837 <input type="checkbox" id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" /> 838 <label for="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label> 866 839 </span> 867 840 868 841 <span class="add-to-menu">