WP_LIST_TABLE bulk action

I created a class extend WP_List_Table and created method for bulk actions like this :

 function get_bulk_actions()
    {
        $actions = array(
            'synchronize' = 'Synchronize',
            'delete' = 'Delete from Shareino',
        );
        return $actions;
    }

and another method for processing their :

  function process_bulk_action()
    {

        //Detect when a bulk action is being triggered...
        if ('delete' === $this-current_action()) {
            wp_die('Items deleted (or they would be if we had items to delete)!');
        }

    }

This action's display in a dropbox but when i select items and one of action and press on apply it doesn't do any thing,so process_bulk_action not working;

Topic bulk wp-list-table actions Wordpress

Category Web


When call $synchronizationList->display() every thing about table created, pagination,sort and bulk action but when its create bulk action its just create 2 input one is dropbox that contains all of bulk action and a submit button for apply button so it doesn't create from tag and when a submit button doesn't be in a form its do nothing. So i created a form and every thing works fine.

  add_action('admin_menu', array("Shareino", 'ShareinoAdminMenu'));
    /**
     * This method adds shareino items to admin menu
     */
    public static function ShareinoAdminMenu()
    {
        add_menu_page(__('Shareino', 'access'), __('Shareino', 'access'), 'manage_options', __('shareino', 'vibe'),
            array("Shareino", "shareinoSetting"), WP_PLUGIN_URL . "/shareino/assets/images/logo.gif", 80);
        add_submenu_page(
            'shareino',
            __('Synchronize', 'access'),
            __('Synchronize'),
            'manage_options',
            __('Synchronize'),
            array("Shareino", "shareinoSynchronize"));

    }


    public function shareinoSynchronize()
    {
        $synchronizationList = new SynchronizationList();
        $synchronizationList->prepare_items();
        ?>
        <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
        <form id="movies-filter" method="get">
            <!-- For plugins, we also need to ensure that the form posts back to our current page -->
            <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>"/>
            <!-- Now we can render the completed list table -->
            <?php $synchronizationList->display() ?>
        </form>
        <?php
    }

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.