Skip to content
c3c edited this page Jul 19, 2013 · 4 revisions

This plugin tries to reuse code as much as possible. It makes use of custom post types, custom meta boxes and external libraries to minimize code duplication. It tries to maximize the use of internal WordPress API's. Instead of creating our own forms, handling POST actions, creating error handlers, we can hook into the existing WordPress functionality.

Custom Post Types

posttypes.php

WordPress saves Posts and Pages in the database in a structured way. Both posts and pages end up in the same SQL table. There's just an extra field that says what type they are: "post" or "page". We can use this to our advantage: an event is no more than a post with some extra metadata associated to it like the location of the event, the time of the event, etc.

We can add custom post types to WordPress, and WordPress will automatically make our admin interface overview to add and edit these post types. We have currently implemented 3 post types: "Events", "Ideas" and "Apps". (A fourth may be needed for Submission).

You can access the custom post type archives directly from the following URLS:

  • wordpress-site/?post_type=event
  • wordpress-site/?post_type=idea
  • wordpress-site/?post_type=app

Custom Meta Boxes

metaboxes.php

When editing a post, you will see boxes to enable comments, to add authors, to assign the post to a category, etc. These are called meta boxes.

It's possible to add our own metaboxes. We have metaboxes for event information like the location, the time, the sponsors, the awards, etc. The plugin makes use of a submodule called Custom-Meta-Boxes by HumanMade to make the processeasier.

Translations

There's functionality included in the plugin to translate it. How to translate WordPress plugins is explained in the WordPress Codex. Your translation files should be added in the /lang/ directory, and should be prefixed with wpapps_.

Posts-to-posts (relations)

We've used a submodule called posts-to-posts which enables us to make relations between custom post types. For example: it adds a meta box to the event edit page that will allow you to link the event to specific ideas (or the other way around). We can then display information from the linked ideas on an event page.

Clone this wiki locally