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 theWP_List_Table
class: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.
Try this:
http://wordpress.org/extend/plugins/db-toolkit/
I’ve not yet used it to it’s full potential but it allows CRUD management of data in your database. Its completely managable in the WordPress backend. Although there is a bit of a learning curve to it the interface is nice and should do exactly what you need.