WordPress is a constantly maturing platform. Just over a year ago I wrote a tutorial about creating custom post types for events- but huge improvements around advanced meta data queries made my previous approach seem hackish. This post is a much revised update with code examples.
Several of my websites were hacked this week using the TimThumb exploit. The issue has been known for a couple weeks now.
Although I had updated the majority of sites and had notified former clients, I still hadn’t gotten to some of the smaller sites yet- like my girlfriend’s food blog.
And word to the wise, your girlfriend’s food blog should always be top priority.
Hackers are using a variety of techniques to hijack WordPress sites right now, but this is how I cleaned up the ones on my server.
I recently released a plugin on WordPress.org that registers a portfolio post type, related taxonomies, and adds an image when you’re viewing the items in the dashboard. It clocks in at a neat 202 lines of code, most of that being labels.
I’ve held onto to the plugin for a while in GitHub since it’s an easy thing for any developer to build out- but I’ve recently been thinking that a standard plugin in the repository might be beneficial as it could make more themes more portable. (Especially for users of my Portfolio Press theme)
And since I expect people to modify this a bit as well, I wanted walk through of the code.
Occasionally a plugin or theme will need to display a notice to users in the WordPress dashboard. This is fairly easy to do using the admin_notices hook, which shows a standard message box at the top of the screen.
I’ve been steadily improving the Options Framework plugin these last several weeks and there’s several nice changes in this 0.6 release. The biggest new feature is sanitization filters and better validation, but there’s also a slew of other less noticeable code improvements.
Unfortunately, a couple things that worked in previous versions will break with this release unless theme code is updated. I debated these changes quite a bit but decided it was best to do this while the plugin is still relatively young and would affect the least amount of people.
Checkboxes are one of the more difficult form elements to deal with. For one, checkboxes don’t get sent in $_POST request unless they are checked. Any other element, like a text input or a radio button, will get sent regardless of it’s state. But if someone were to uncheck an option form and send it there would be no indication in the $_POST request that its state had changed. Read more
Sometimes you want to detect new users on your site versus returning visitors and display different sorts of information to them. An easy way to do this is to set a cookie. Read more
For my projects on GitHub I like to have the most recent stable version tagged so that people have an easy download link to it. So when I go from versions 0.4 > 0.5 on project (for instance), I do this:
1) Delete the v0.4 tag locally:
git tag -d v0.4
2) Delete the v0.4 tag on GitHub (which removes its download link):
git push origin :v0.4
3) Add a new tag for the newest stable release:
git tag -a v0.5 -m "Version 0.5 Stable"
4) Push the latest tag to GitHub (two dashes):
git push --tags
For a little challenge I decided to turn his Photoshop file into actual code using CSS3 and a bit of JQuery. You can see a demo here or download the code (feel free to use in your own projects, no attribution necessary).
You can’t assume everyone is running the latest version of WordPress, especially around big point releases.
Simple Version Check
If you want your code to be backwards compatible (keep it within reason), you can do a simple WordPress version check with conditionals by using:
Or just use the global variable $wp_version.
The latest version of this Thematic Options theme has been completely rebuilt to use the Options Framework Plugin. It’s rather basic and has just a couple settings- but if there’s something else you’d like to see in it please file a ticket or send over a pull request on GitHub.
You can download the latest version of the Thematic Options on GitHub.