WordPress.org

Ready to get started?Download WordPress

Forums

Suggestion for class-wp-list-table (2 posts)

  1. alexidoia
    Member
    Posted 1 year ago #

    Hello,

    The short version :
    Class-wp-list-table::bulk_action responsible for displaying the Apply button for bulk action does not set the name attribute for the button. That prevents developpers to create an event handler based on this button being clicked or not. Method can be overrided but doing so for setting only that name attribute is not very optimised.
    Suggestion : setting a name attribute in the core.

    The longer version :
    Say we do an extended class of class-wp-list-table for our needs and in the extended class we handle the event a user has clicked on the Apply button for a bulk action but has forgotten to select the posts by checking their row checkbox.
    A user-friendly response would be 'You have forgotten to select posts'.

    Now say the user clicks on the Empty Trash button, but right before, by mistake, selects a bulk action. Then our previous event handler would display the user-frienldy message as well as executing the empty trash action. That is because the only way to trigger the event the user clicked on apply without selected posts, is to check that $this->current_action is set and that $_REQUEST['posts'] is empty (the not-checked posts).
    Then the developper would need to better conditionned its event handler in trying to catch if the Apply button has been used, and if not, ignore the fact that a bulk action has been selected and that no posts have been checked, because the user did not use the Apply button.
    That would work but unfortunatly, the bulk_action method display the Apply button without setting its name attribute which then prevent the developper to check if the user has clicked on it or not since no var in _REQUEST is set.

    Sure this bulk_action method is public and can be overrided but that would be simpler if a name attribute was set right from the core, that should not interfer with anything else and would avoid overiding the function only for this.

    Minor improvment I guess but would better apprehend any future release that modify the core class.

  2. Steven Jones
    Member
    Posted 1 year ago #

    Hi - you can contribute to WordPress by using the 'Get Involved' menu at the top there. Pick which category your improvement fits into and go from there.

Topic Closed

This topic has been closed to new replies.

About this Topic