• For a plugin I’m working on, I would like to combine several functionalities on a single page, separated by tabs to keep the UI clean and useable.

    Some of the tabs are used to maintain the values of options for the plugin. I use the settings functions to generate the options and fields. There is a button “Save Settings” which can be used to store the changed values in the database.
    This works fine as long as I only use option settings.

    Now for new functionality, I would like to use a WP_List_Table to maintain the list of new options I want to support.
    I have used this approach already several times on a separate page for other plugins.

    The issue arises when I try to put the WP_List_Table in a tab on the same page as used to manage the option settings.

    My analysis so far is that both are using the same hidden field to define the “action” _REQUEST parameter:

    1. For the option settings in file “wp-admin\includes\plugin.php” on line 1877:
      echo ‘<input type=”hidden” name=”action” value=”update” />’;
    2. For the wp_List_Table bulk_actions in file “wp-admin\includes\class-wp-list-table.php” on line 437:
      echo “<select name=’action$two’ id=’bulk-action-selector-” . esc_attr( $which ) . “‘>\n”;

    I would appreciate any suggestions on how to solve this issue.
    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter DeBAAT

    (@debaat)

    Just found a workaround using JS to rename the value of the “name” attribute:

    jQuery(document).ready(function($) {
    	var action_top = document.getElementById("bulk-action-selector-top");
    	action_top.setAttribute("name", "my_action");
    	var action_bottom = document.getElementById("bulk-action-selector-bottom");
    	action_bottom.setAttribute("name", "my_action2");
    });

    If one wants to apply the same workaround, please take care to only apply this translation on the desired page. You wouldn’t want to break the working of other plugins using the same WP_List_Table.

    Although it works, I believe this still is only a workaround. It would be better if the WP_List_Table allowed to define a custom value for the “name” attribute.

Viewing 1 replies (of 1 total)
  • The topic ‘How to combine Save Settings and WP_List_Table bulk actions?’ is closed to new replies.