custom_list_table edit/delete bulk actions

so… this is a brand new chapter for me, i’ve googled for a solution and found loads but nothing working for me unfortunately.

        function column_title($item){

  $actions = array(
            'edit'      => sprintf('<a href="https://wordpress.stackexchange.com/questions/188237/?page=%s&action=%s&ID=%s">Edit</a>',$_REQUEST['page'],'edit',$item['ID']),
            'delete'    => sprintf('<a href="https://wordpress.stackexchange.com/questions/188237/?page=%s&action=%s&ID=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']),
        );

  return sprintf('%1$s %2$s', $item['ID'], $this->row_actions($actions) );
}

above i’ve added a delete and edit action, and i think i’ve used the sprintf the proper way but i’m not sure,
database table contains the following columns ID, usr_id, date, begin, end, pause, egenb, tot, and asum
i want my actions to select the rows by ID so is my code above correct?

 function column_cb($item) {
    return sprintf(
        '<input type="checkbox" name="ID[]" value="%s" />', $item['ID']
    );    
}

above is my check box, normally name=”book[]” can someone explain what the purpose of the [] is?

    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)!');
    }   
}

and last we got process_bulk_action where the delete action and edit action is to take place is there a kind person out there that can explain how i would go about this? i’m not just seeking a quick answer but understanding of it, i’ve tried with loads of things i found thru google but none made the slightest effect nor did it make any sense to me

in advance thanks to anyone taking the time to read thru my post! 🙂

1 Answer
1

above is my check box, normally name=”book[]” can someone explain what
the purpose of the [] is?

This is allowing the checked values to be returned as an array when getting the results, if you have more than one value checked.

Besides that, I can’t tell what you’re trying to do in order to be able to answer the other questions. Especially the last part. It appears like you’re asking someone to write the code for you, for process_bulk_action()? There’s not enough specific question to answer.

Leave a Comment