Custom WP_List_Table: How to generate row actions
I have written my own class extending WP_List_Table.
Now I want to customize row actions and implement the "yellow unapproved rows". I know I could do it the hard makeshift way adding the necessary attributes by hand, but I would like to use native Wordpress functions as far as possible to stay compatible with future updates.
How can something like
function column_when($item) {
$actions = array(
'approve' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Approve') . '</a>', $_REQUEST['page'], 'approve', $item->X_ID),
'unapprove' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Cancel') . '</a>', $_REQUEST['page'], 'cancel', $item->X_ID),
'edit' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Edit') . '</a>', $_REQUEST['page'], 'edit', $item->X_ID),
'delete' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Delete') . '</a>', $_REQUEST['page'], 'delete', $item->X_ID),
);
return sprintf('<span>%1$s</span> %2$s',
$item['ID'],
$this->row_actions($actions)
);
}
where I would like to:
either show 'approve'(green/red) or 'disapprove' (orange/red)
get yellow background for unapproved rows
using as much WP as possible.
I have written my own class extending WP_List_Table.
Now I want to customize row actions and implement the "yellow unapproved rows". I know I could do it the hard makeshift way adding the necessary attributes by hand, but I would like to use native Wordpress functions as far as possible to stay compatible with future updates.
How can something like
function column_when($item) {
$actions = array(
'approve' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Approve') . '</a>', $_REQUEST['page'], 'approve', $item->X_ID),
'unapprove' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Cancel') . '</a>', $_REQUEST['page'], 'cancel', $item->X_ID),
'edit' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Edit') . '</a>', $_REQUEST['page'], 'edit', $item->X_ID),
'delete' => sprintf('<a href="?page=%s&action=%s&X_ID=%s">' . __('Delete') . '</a>', $_REQUEST['page'], 'delete', $item->X_ID),
);
return sprintf('<span>%1$s</span> %2$s',
$item['ID'],
$this->row_actions($actions)
);
}
where I would like to:
either show 'approve'(green/red) or 'disapprove' (orange/red)
get yellow background for unapproved rows
using as much WP as possible.
No comments:
Post a Comment