Archive | March, 2011

Header-Rotator

A few late night tweaks to the header image logic: I’ve created as simple a plugin as possible that lets me have three of my own images randomly appear in the heading. Based on the TwentyTen Header Rotator plugin, I ripped out all the code other than the logic to hook into the WordPress framework and the last line to pick an image at random. For my first pass, I hard-coded threefour images (a full moon on a snowy evening, a frosty window and a full batch of cherries, all taken at home) to load up the array. Got it working. That’s the first sanity check. It will be followed with admin pages, setting pages, the ability to upload and resize your own images, etc.

I tried to keep it as close to “the simplest thing that would work” for a first pass, but I left a little complexity in there: the list of images is an array of one-element arrays because the main theme uses something similar where you can store more information about each image, such as a thumbnail location. I figured I’d eventually need to add that back in there, so I left the structure in place. Here’s the core code that gets it to work:


if(!is_admin()) add_filter('theme_mod_header_image','trhr_rotate');
 
function trhr_rotate(){
$imagelist = array(
0 => array('url' => home_url('/wp-content/uploads/2011/03/cropped-DSCN1285.jpg')),
1 => array('url' => home_url('/wp-content/uploads/2011/03/cropped-DSCN1288.jpg')),
2 => array('url' => home_url('/wp-content/uploads/2011/02/cropped-SnowMoon.jpg')),
3 => array('url' => home_url('/wp-content/uploads/2010/07/cherries.jpg')),
);
return $imagelist[rand(0,count($imagelist)-1)]['url'];
}

Thanks to the Seacoast WordPress Developers group for the inspiration, and also some cool ideas from Smashing Magazine’s “Ten Things Every WordPress Plugin Developer Should Know

TwentyTenFive theme

Readers shouldn’t notice too much of a change as I switched from the TwentyTen default theme for WordPress 3.x to the TwentyTenFive theme by Richard Shepard. It was originally developed as this article for Smashing Magazine, and then took on a life of its own. The theme is available for download and modification from GitHub.com. I was pleased to be able to contribute a minor fix (a really tiny fix, consisting of two dots and a slash, but in the right place). Hope to contribute more as I learn more about WordPress internals.

TwentyTen Header Rotator Follow-up

Ah, the power of the web. I posted the problem I was having both here and on the WordPress.org web site, and within a week, another developer pointed out the simple one word addition to the plugin code to make it work in WordPress 3.1. Problem solved!

Now that I’ve spent some time poking at the code, and inspired by the “How to Build a Plugin” presentation at last Seacoast WordPress Developer’s meeting, I’m thinking of a fancier plugin that will let you load up as many images as you want and shuffle them. Inspiration is one thing, perspiration is another; I’ve got enough on my plate right now that this is a pretty low-priority issue. And there’s the challenge of feature creep: it would be nice if I could link each header to page that described the significance of the picture, had its licenses, etc. And that you could load up multiple pictures and enable/disable them individually for seasonal themes or special events. And… oh, dear.

Seacoast WordPress Developers meeting, 2-March-2011

Five people attended the March meeting of the Seacoast WordPress Developer‘s meetup, held at the New Hampshire innovation Commercialization Center near Pease in Portsmouth. We did a round of introductions and welcomed two new members and discussed what the group could focus on. We discussed the boundaries of CMS and Blogging and Wikis and how they overlap (A professional in education provided us with some great insights on how we think about some of these items), the challenge in finding consultants and clients, and how we can build up a network. We talked about potential agenda items: what should we schedule, what should we have in free-form.
I think an FAQ we ought to be prepared to answer is “What is it that WordPress is?” It’s less than obvious. “A blog” is the wrong answer, as that is a form of document, and not an application. “A CMS” is such a vaguely defined answer that it’s not much more useful than “an application.”

Other questions we started to explore, and possible future topics:

  • What is it that others are looking for on the web?
  • Good resources for learning WordPress: Codex, FAQ, books, etc.
  • WordPress SEO
  • WordPress Security
  • Loop/structure of databases tables, templates
  • Popular plugins
  • WordPress Backup tips: data and files
  • WordPress Community

Finally, Amanda presented her talk on building a plugin. She’d done some excellent research and used clear examples and explained them well. Here are the notes and slides posted to the new Seacoast WordPress Developer’s website, running WordPress, of course, and BuddyPress.

So, it was a great second meeting of the Seacoast WordPress Developer’s group. Stay tuned for more news. Thanks to Amanda for organizing the event, and to the New Hampshire Innovation Commercialization Center for providing the great facilities!

Powered by WordPress. Designed by Woo Themes

This work by Ted Roche is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.