In display_rows()
you are using the following code to print the ‘name’ column:
echo '<td '.$attributes.'><strong><a href="'.$editlink.'" title="Edit">'.stripslashes($rec->name).'</a></strong></td>';
Nowhere do you call column_name()
, which is the function you’ve defined to display the item’s and row actions:
function column_name($item){
$actions = array(
'edit' => sprintf('<a href="https://wordpress.stackexchange.com/questions/76517/?page=%s&action=%s&testimonial=%s">Edit</a>',$_REQUEST['page'],'edit',$item['ID']),
'delete' => sprintf('<a href="https://wordpress.stackexchange.com/questions/76517/?page=%s&action=%s&testimonial=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']),
);
//Return the title contents
return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s',
/*$1%s*/ $item['name'],
/*$2%s*/ $item['ID'],
/*$3%s*/ $this->row_actions($actions)
);
}
See, for example, how the underlying WP_List_Table
does it.
In fact, if you avoid over-riding the underlying class’s display_rows()
method then it will automatically use your column_{$column_id}()
method (where it exists), to define the content of the column. This makes it much easier to maintain than your current switch statement.