I have a site that uses custom database tables to manage info that is inserted by a process completely independent from WordPress. The data from the table is used in the WordPress site but it is not manageable through the Admin interface.
I want to make it manageable via the admin backend. What is the basic process for this? In my mind I need to create a link in the Admin sidebar to “Manage Custom Data” and that link opens up a page that permits basic CRUD management of the various rows in the table.
This would be effortlessly simply in vanilla code but I am not familiar with such custom aspects of modifying WordPress so I am just looking for pointing in the right direction. Give me the big picture, in other words.
Some notes before: This is only how I’d approach it – I’m not going to step more into detail, because basically it’s a list of plugins you’ll have to code.
Build a Back-End page
Use the function add_menu_page
to add a page. Then build your management tables extending the WP_List_Table
class:
class WPSE_48824_List_Table extends WP_List_Table
{
// do stuff
}
// Use it:
$list_table = new WPSE_48824_List_Table();
$list_table->display();
Handling the DB
Basically you’re going to have a lot of DB requests. Use the $wpdb
object/Class.
Don’t forget to $wpdb->prepare()
your data before inserting it.
Also make use of $wpdb->prefix
instead of hardcoding it.
Bulk actions
Will run via Ajax. More can be read on Ajax for Plugins in Code or here on WPSE in the tag archive ajax.