Using WordPress as an Admin for non-WordPress data

Okay, this one kind of surprised me. Apparently, the vast majority of developers never realised just how easy it is to use the WordPress admin to administer data that is held in non-WordPress tables. For example, I store all of my Xbox friends and games in a bunch of tables that live next to the default WordPress ones (such as wp_posts etc). Within the WordPress admin I then have additional menu tabs to add, edit and delete all of these. And by using WordPress you get a lot of stuff for free.

Creating additional admin areas for content is fairly simple. This deals with data that does not follow the usual WordPress-paradigm, i.e. for an Xbox plugin games are stored in xbox_games, and not wp_posts with a post_type of “game”. In time I’ll release a skeleton plugin showing how I commonly lay out my admin sections.

Perhaps the biggest advantage is the lack of design work you have to do, especially if a website is already powered by WordPress and your client is familiar with the admin. Tables, list, buttons, forms, all have been styled up for you already meaning you have a very nice admin out of the box (practically).

After that comes the more programmer-orientated features, some of which include;

  • Access to the $wpdb global database object. This gives you nice queries, full escaping (or preparing, as you should be!), and even methods to convert result sets to arrays of objects as necessary.
  • Security built in. Not only do you get the default WordPress protection, you can use nonce’s and full AJAX authentication on requests.
  • An extensive permissions system. Seriously, this point cannot be stated enough. You can create permissions such as edit_xbox_game and then assign them to specific groups or users. Brilliant for when you have multiple users who need access to only certain areas. And testing for this in your plugin? Just use current_user_can(‘edit_xbox_game’)!
  • Modularity. If you make your plugin correctly, it’s already packaged up and ready to be shared with others.

I’ve made several websites using PHP (or any other language) frameworks, only to use WordPress solely for the admin. Short of porting Django’s admin over to PHP, there’s nothing that currently comes close. After removing all of the unnecessary cruft from WordPress dependant on project, you’re left with a nice and simple admin.