Ticket #58479: 58479-2.diff
File 58479-2.diff, 4.5 KB (added by , 10 months ago) |
---|
-
src/js/_enqueues/admin/common.js
diff --git src/js/_enqueues/admin/common.js src/js/_enqueues/admin/common.js index b2d8b56c63..4da979cd8f 100644
$( function() { 1114 1114 }); 1115 1115 } 1116 1116 1117 $document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error ', makeNoticesDismissible );1117 $document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error wp-notice-added', makeNoticesDismissible ); 1118 1118 1119 1119 // Init screen meta. 1120 1120 screenMeta.init(); … … $( function() { 1276 1276 // Marry the secondary "Change role to" controls to the primary controls: 1277 1277 marryControls( $('#new_role'), $('#changeit'), $('#new_role2'), $('#changeit2') ); 1278 1278 1279 var addAdminNotice = function( data ) { 1280 var $notice = $( data.selector ), 1281 $headerEnd = $( '.wp-header-end' ), 1282 $adminNotice; 1283 1284 delete data.selector; 1285 1286 $adminNotice = '<div id="' + data.id + '" class="notice notice-error is-dismissible"><p>' + data.message + '</p></div>'; 1287 1288 // Check if this admin notice already exists. 1289 if ( ! $notice.length ) { 1290 $notice = $( '#' + data.id ); 1291 } 1292 1293 if ( $notice.length ) { 1294 $notice.replaceWith( $adminNotice ); 1295 } else if ( $headerEnd.length ) { 1296 $headerEnd.after( $adminNotice ); 1297 } else { 1298 if ( 'customize' === pagenow ) { 1299 $( '.customize-themes-notifications' ).append( $adminNotice ); 1300 } else { 1301 $( '.wrap' ).find( '> h1' ).after( $adminNotice ); 1302 } 1303 } 1304 1305 $document.trigger( 'wp-notice-added' ); 1306 }; 1307 1308 $( '.bulkactions' ).parents('form').on( 'submit', function(event) { 1309 var form = this; 1310 1311 var submiterName = event.originalEvent && event.originalEvent.submitter ? event.originalEvent.submitter.name : false; 1312 1313 var bulkFieldRelations = { 1314 'bulk_action': 'action', 1315 'changeit': 'new_role' 1316 } 1317 1318 // We need to know which button was clicked and it's bulk_action button. 1319 if( ! Object.keys(bulkFieldRelations).includes( submiterName ) ) { 1320 return; 1321 } 1322 1323 var values = new FormData(form); 1324 var value = values.get(bulkFieldRelations[submiterName]) || '-1'; 1325 1326 // Check that the action is not the default one. 1327 if( value !== '-1') { 1328 // Check that at least one item is selected. 1329 var itemsSelected = form.querySelectorAll('.wp-list-table tbody .check-column input[type="checkbox"]:checked'); 1330 1331 if ( itemsSelected.length > 0 ) { 1332 return; 1333 } 1334 } 1335 1336 event.preventDefault(); 1337 event.stopPropagation(); 1338 1339 $( 'html, body' ).animate( { scrollTop: 0 } ); 1340 1341 var errorMessage = __( 'Please select at least one item to perform this action on.' ); 1342 1343 addAdminNotice( { 1344 id: 'no-items-selected', 1345 className: 'notice-error is-dismissible', 1346 message: errorMessage 1347 } ); 1348 1349 wp.a11y.speak( errorMessage ); 1350 }); 1351 1279 1352 /** 1280 1353 * Shows row actions on focus of its parent container element or any other elements contained within. 1281 1354 * -
src/js/_enqueues/wp/updates.js
diff --git src/js/_enqueues/wp/updates.js src/js/_enqueues/wp/updates.js index 558a40f6de..bcb0df8d58 100644
2830 2830 return; 2831 2831 } 2832 2832 2833 // Bail if there were no items selected.2834 if ( ! itemsSelected.length ) {2835 event.preventDefault();2836 $( 'html, body' ).animate( { scrollTop: 0 } );2837 2838 return wp.updates.addAdminNotice( {2839 id: 'no-items-selected',2840 className: 'notice-error is-dismissible',2841 message: __( 'Please select at least one item to perform this action on.' )2842 } );2843 }2844 2845 2833 // Determine the type of request we're dealing with. 2846 2834 switch ( bulkAction ) { 2847 2835 case 'update-selected': -
src/wp-admin/admin.php
diff --git src/wp-admin/admin.php src/wp-admin/admin.php index 630765f77d..63167b4290 100644
set_screen_options(); 113 113 $date_format = __( 'F j, Y' ); 114 114 $time_format = __( 'g:i a' ); 115 115 116 wp_enqueue_script( 'wp-a11y' ); 116 117 wp_enqueue_script( 'common' ); 117 118 118 119 /** -
src/wp-admin/includes/class-wp-list-table.php
diff --git src/wp-admin/includes/class-wp-list-table.php src/wp-admin/includes/class-wp-list-table.php index 253bcca800..a0d4c33bcb 100644
class WP_List_Table { 625 625 626 626 echo "</select>\n"; 627 627 628 submit_button( __( 'Apply' ), 'action', ' ', false, array( 'id' => "doaction$two" ) );628 submit_button( __( 'Apply' ), 'action', 'bulk_action', false, array( 'id' => "doaction$two" ) ); 629 629 echo "\n"; 630 630 } 631 631