Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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 .

share|improve this answer
    
I don't recommend that you sink a lot of time into extending WP_List_Table - it's marked private, and I've been told by core devs that in the future, extending classes may just break. I have some fancy classes that help with manually displaying content in a WPish way: wordpress.org/extend/plugins/boones-sortable-columns wordpress.org/extend/plugins/boones-pagination Other than that minor point, +1 to what kaiser says. –  Boone Gorges Apr 13 '12 at 0:32
    
Core devs do say a lot of stuff on long days. We got functions or func args that are deprecated since years and still functional. WP_List_Table won't break in the future for one reason: Too many plugins & Themes are relying on it and it's pretty well documented (Only god knows who's the one who took a day of to write this. Just praise him!). But thanks for linking your plugins. –  kaiser Apr 13 '12 at 1:24
1  
Incidentally, the WP_List_Table documentation now explicitly says "This class may be used by developers through extending the class and overriding its methods", so this is definitely a supported solution these days. –  Matt Gibson Apr 24 '13 at 19:00
    
@MattGibson Thanks for coming back to an old question/answer. Updated and extended with an example. –  kaiser Apr 24 '13 at 20:54

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.