Reputation: 646
I am writing a custom plugin for a client and I was able to create custom admin tables based on custom database tables using the "Custom List Table Example" plugin as a guide.
However, I cannot seem to find any information on how to create inline "edit"/"view more" expanded views for a column. For instance, when you go to the "Posts" admin page there is an option to "Quick Edit" a post under the "Title" column and then an expanded view appears with fields to edit the post.
I was able to create the following action links by using the following code:
function column_order_ID($item){
//Build row actions
$actions = array(
'view_more' => sprintf('<a href="?page=%s&action=%s&order_ID=%s">View More</a>',$_REQUEST['page'],'edit',$item['order_ID']),
'delete' => sprintf('<a href="?page=%s&action=%s&order=%s">Delete</a>',$_REQUEST['page'],'delete',$item['ID']),
);
//Return the title contents
return sprintf('%1$s <span style="color:silver"></span>%3$s',
/*$1%s*/ $item['order_ID'],
/*$2%s*/ $item['ID'],
/*$3%s*/ $this->row_actions($actions)
);
}
As of right now I am unsure how the "View More" action can be linked to the code that creates the expanded view within the table.
What are best practices with this or is there a tutorial anyone can point me to that I may have missed? Any help will be greatly appreciated!
Upvotes: 2
Views: 5776
Reputation: 646
Found the issue, it is because WP_List_Table can only be used to view data and not to edit it, any actions that are attached to data in the rows has to be linked to another page where the actions are processed. In order to accomplish what I mentioned I needed to go with Custom Post Types instead, create custom metaboxes, and create a custom table using:
add_filter("manage_edit-club_types_columns", "clubs_edit_columns"); (http://codex.wordpress.org/Plugin_API/Filter_Reference/manage_edit-post_type_columns)
add_action("manage_posts_custom_column", "clubs_custom_columns"); (http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column)
Using the documentation on the WordPress codex I was able to figure out to customize the tables for the custom post tables and the "Edit", "Quick Edit", and "Trash" features were built into functionality.
Upvotes: 3