WordPress.org

Make WordPress Core

Ticket #29789: bulk_edit.patch

File bulk_edit.patch, 1.0 KB (added by psoluch, 5 years ago)

patch to hide bulk edit selectbox when user can't edit or trash anything on post list

  • wp-admin/js/common.js

     
    222222                }
    223223
    224224                $( document ).trigger( 'wp-collapse-menu', { state: state } );
     225
     226                // check if bulk edit selectbox should be displayed
     227                checkbox_capabilities_checker();
    225228        });
    226229
    227230        if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
     
    742745})();
    743746
    744747}( jQuery, window ));
     748
     749function checkbox_capabilities_checker() {
     750
     751        // get the number of entries (posts, pages etc) that have checkboxes (user can trash or edit them)
     752        var countOfCheckboxes = jQuery('.wp-list-table tbody input[type=checkbox]').size();
     753
     754        // if there are no entries with checkboxes (the user can't edit or trash entries)
     755        if ( ! countOfCheckboxes ) {
     756
     757                // hide the select-all-checkboxes and bulk actions select boxes
     758                jQuery('.bulkactions, .check-column').hide();
     759        }
     760}
     761 No newline at end of file