WordPress Plugin Structure

The power of WordPress lies in its pluggable infrastructure.  Unlike other content management applications which require you to edit the core code of the system to make changes, WordPress supports plugins.  These smaller applications tie in to a rich API provided by WordPress that allows you to change just about everything about the application and customize it as needed.

The official plugin repository on WordPress.org is currently home to over 20,000 distinct plugins.  Each one adds some new functionality to WordPress, giving you the ability to tweak content, change colors, adjust layouts, or integrate with external systems.  This doesn’t even begin to cover the hundreds of premium plugins you can find online that provide even richer functionality.

Most WordPress developers will, at some point, be asked to create some kind of plugin for a client site. These client plugins can range from a shortcode manager to some kind of advertisement rotation engine to an API integration with a third-party customer management system. Instead of focusing on the what for your plugins, this tutorial will focus on the how. Namely, the three different ways you can structure a WordPress Plugin. [Read more…]

Theme-ready Shortcodes in WordPress

A few months back, I taught you how to make your widgets theme-ready by extracting the actual markup into an overridable template.  Now, we’re going to do the same for shortcodes.

And for those of you wanting to see this in practice, stay tuned for the release of version 2.5 of WP Publication Archive in a few weeks.  I’m using this technique to make markup easy to change. [Read more…]

Doing it Wrong the Right Way

Telling someone there’s a right way to include a plugin in a theme is like telling someone there’s a right way to cheer for the Beavers during the Oregon Civil War.

There is no right way.

However, there are still ways to do it if you absolutely need to.

Let’s admit it. As developers, we’re lazy.  We don’t like installing multiple tools when they could be bundled into one package.  We don’t like teaching our clients the difference between functionality and presentation.  We don’t like documenting the multiple items we installed on a client site so the next guy can not break things when he works on it.

We’re lazy. As a result, we try to take shortcuts whenever possible – one of those shortcuts is bundling plugins with themes to extend WordPress’ functionality.  But if you must take such a shortcut, here are the “right” ways to invoke _doing_it_wrong(). [Read more…]

Theme-ready Widgets in WordPress

If you use WordPress, you’ve probably used a handful of widgets in your sidebar.

Some display statistics.  Others print out recent comments.  Others display posts related to the content in the main window.

But all of them do this in the exact same way.  They take some data, wrap it into a hard-coded HTML template, and dump the content of that template to the front page of your site.

For most sites, this is fine.  Each tag has enough information to be easily styled, moved, re-sized, or even re-positioned using CSS.  In some cases, it’s not enough.

I’m a bit of a control freak, and I like to know exactly what is being output on my site, why, and how to change it.  As a result, I build my custom widgets to use customizable templates.

I set the default look – you can change it to whatever you want. [Read more…]

Show off Your Codex Props!

Show off Codex work in your own sidebar.

Some time ago, I released a plugin that allows you to highlight contributions to the core WordPress project on your very own site.

Today sees the release of version 1.2 of the WP Core Contributions Widget plugin.  This new version adds a Codex contributions widget as well.

So now you can show off both your Trac reputation and your work on the Codex.  Those who write documentation for the core project are just as important as the devs who write the code; they deserve recognition, too!

Version 1.2 also extends internationalization by passing all output strings through WordPress’ internal translation functions.  Updated .po files are included for translators.

This latest update also features work from the talented Mike Bijon, bringing the total number of individual code contributors to 4.  This is definitely becoming a community project!

Read the full details of version 1.2 here.  You can download the plugin from the WordPress.org repository or fork the code yourself .