The owner of Casual Creations asked us to develop a name and tag line, a visual identity, marketing materials, and a website. See More
Group Buying Site makes it easy for you to get your very own online group buying business up and running in just a few hours. Leveraging the power of WordPress as a content management system, GBS allows owners to easily create and manage their daily deals through a user-friendly interface.
Sprout Venture called us in to lead a team of developers rearchitecting GBS to create version 3.0 of the software. The new architecture breaks the application into modular components, making ongoing development faster and more flexible than ever. In addition to the rewritten code base, new features introduced in version 3.0 include shopping carts, support for taxes and shipping, and customizable notifications.
a project See More
I’ve a great deal of experience with two open source content management systems: WordPress and Drupal. They both have their strengths and weaknesses, which I won’t get into here. If I had to pick the key difference between the two, though, it’s in how they answer one question:
What is a URL?
In WordPress, a URL indicates which posts to display. Your request is mapped to query variables (if you don’t have permalinks turned on, you’ll see these variables directly in your query string), and those variables are used to manipulate the database query in
$wp_query->query(). It’s a very nice, consistent system: a URL equals one or more posts (or a 404 error). (NB. the admin section is a different beast entirely.)
With Drupal, a URL is an entry in the menu system. When Drupal sees the URL, it looks up the corresponding entry, and calls the function specified in that entry. That function is responsible for creating the contents of the page, be it a list of nodes, a form, flying monkeys, or what have you. You can use a module like Views to achieve results similar to WordPress, but you have a lot more power and flexibility to do something different with a given page.
Sometimes you want that power and flexibility in WordPress. You just want to say, “When a user visits this URL, call this function and display its output.” That’s not really the “WordPress way” of doing things, and it requires a fair amount of code to accomplish what seems to be a simple instruction.
Abstract the Details Away
So I went and wrote another WordPress plugin. WP Router abstracts away all the messy details of declaring a callback function for a URL in WordPress. One method call is all it takes to set up your path, your rewrite rules, your query variables, your access rules, your title, your template overrides. It reduces a few dozen action/filter callbacks to a small list of easy-to-understand arguments.
If you’ve every worked with Drupal’s menu system, you’ll find many of the arguments familiar, adapted, of course, for the WordPress framework. Read all about them in the usage notes, and check out the sample code included in the plugin.
Right now, this is at version 0.2, which is synonymous with “has all the features I thought to add initially, plus one more”. But I’m just one developer. What would make this plugin more useful to you? What doesn’t work like you expect it to? What part of the API is confusing? Please leave a comment or create an issue in Github.
And if you’re interested in contributing, feel free to fork the project and send me updates. It’s hosted at Github, with released copied over to WordPress’s plugin repository. As usual with code I write, it’s licensed under the MIT License (i.e., do whatever you want with it, just mention where it came from).
Following common practice in WordPress plugin development, you create a class for you plugin, instantiate that class with a
$my_plugin = new My_Plugin();
in your main plugin file, and declare all your actions/filters in your class’s
__construct() function, using something like:
add_filter('init', array($this, 'my_init_function'));
I’m declaring that to be “wrong”, and I’m not going to do it anymore. Why? Because it’s not good objects-oriented design, and it seems to me that if you’re going to use objects, you should follow good object-oriented design patterns. Read More