Laying out a grid in WordPress

For a recent project, I needed to lay items out in a series of grids, sometimes three columns, sometimes more. The CSS provided by the designer looked something like this:

.columns section {
float: left;
margin-left: 20px;
width: 220px;
}
.columns section.one {
clear: left;
margin-left: 0;
}

I could have used jQuery, or some of the more advanced CSS selectors, to achieve this, but here’s what I created as a custom WordPress template tag. Continue reading “Laying out a grid in WordPress”

Dealing with sold out products and the PayPal BMSetInventory API method

I’ve just built a WordPress custom post type which allows you to sell a few simple products on your site by interacting with the PayPal Button Management API. (It wasn’t easy. PayPal’s documentation is full of duplicated informal, distributed all over the place, and badly maintained.) One thing which isn’t mentioned in the documentation is that you can use the BMSetInventory API method to stop customers buying products when they are sold out… which is kind of critical, when you think of it. Continue reading “Dealing with sold out products and the PayPal BMSetInventory API method”

Handy sendmail debugging commands

Some sendmail commands I’ve just found useful, but couldn’t locate on Google.

Get the current status of a message in the queue: grep  'james@example.com' /var/log/maillog

Get the headers for an email: cat /var/spool/mqueue/qf[message ID]

Get the body of an email: cat /var/spool/mqueue/df[message ID]

(Many thanks to my old friend Mr Matt Westby for his help with this.)

Gravity forms access for editors

Gravity Forms is an excellent WordPress plugin, which allows flexible and easy control and creation of pretty much any kind of form in your website. Behind the scenes it has a very flexible integration with the WordPress system of roles and capabilities, which governs who can do what in your admin area. Continue reading “Gravity forms access for editors”

Some security suggestions for WordPress (and other) sites

Someone on the Manchester WordPress User Group mailing list recently asked about checking their WordPress site for malware, and as I’ve spent some time decontaminating a WordPress site which was fairly riddled with malware recently, I thought I’d write up some quick pointers which might help you (or me in the future). I’ve broken them down into detection and prevention, and noted which are paid and which are free.

Continue reading “Some security suggestions for WordPress (and other) sites”

Trust your gut, also use SMART Utility

For a while now my laptop has been running *extremely* slowly. Recently it got worse and about every other startup would just freeze until I forcibly powered down and tried again.

I ran Apple’s Disk Utility and told it to check the error messages from the drive’s internal SMART systems: “this drive is verified”. I groused and left it for a while, but performance continued to suck and the whole thing was making me nervous. I told Disk Utility to check again: still no SMART errors from the drives, but this time it found some mis-set permissions. Louder alarm bells went off in the chaos of my mind, so I refreshed a SuperDuper! clone of the drive and over the weekend I ran Disk Warrior to attempt to save the drive, using whatever arcane magicks it employs to do these things. Success! The drive was rebuilt! I had Dodged A Bullet™, all was good in the world, and I went back to mildly grumbling about performance.

Then the laptop failed to boot again. Continue reading “Trust your gut, also use SMART Utility”

Excluding one category from the main WordPress feed

Today I needed to exclude a category from the main WordPress posts feed, the one you’ll find at http://mywordpresssite.com/feed/; however I didn’t want to exclude posts in that category from other feeds (especially not from that category’s feed at http://mywordpresssite.com/excluded-category/feed/). Here’s how I set about it… Continue reading “Excluding one category from the main WordPress feed”

WP Super Cache and WP Touch (Pro)

On one client’s site we’re using WP Super Cache and WP Touch Pro, and it bothered me that while WP Touch Pro ensures that mobile users get a lovely optimised theme, it wasn’t serving cached pages for those queries. Until recently we were hacking both WP Super Cache and WP Touch (pre-Pro) to achieve this, but recent changes in both plugins mean we can avoid the egregious charge of tampering with other people’s plugin code.

Three fairly simple steps: Continue reading “WP Super Cache and WP Touch (Pro)”

Scaling WordPress & Co-ordinating Code at WordUp Whitehall

Thanks to Simon Dickson for inviting me to speak at WordUp Whitehall, a specialist and informal one day WordPress conference for people working in UK Government. I don’t do enough speaking, something I need to address, and this was a great opportunity to share some of the knowledge gained from working on relaunching the recent Defra project.

My presentation covered two quite separate topics: scaling WordPress for large amounts of traffic, and how version control can be useful for client in-house teams.

Here’s a PDF version of the talk, and certainly let me know if there’s any speaking opportunities coming up… I’m available! Scaling WordPress & Co-ordinating code

There’s a lot of images used in the presentation, and thanks to the following for providing their photos under a Creative Commons license:

© @hwayoungjung – http://www.flickr.com/photos/hwayoungjung/3742229597/
© Andrew Becraft – http://www.flickr.com/photos/dunechaser/2816064611/
© Christian Payne –http://www.flickr.com/photos/christianpayne/3524859632/in/photostream/
© Don Solo – http://www.flickr.com/photos/donsolo/2886355241/
© Evan Moss – http://www.flickr.com/photos/mightymoss/4163027317/in/photostream/
© Federico Casares – http://www.flickr.com/photos/solofotones/1839531915/
© Garrett & Kitty Wilkin –http://www.flickr.com/photos/gareandkitty/338059022/in/photostream/
© Garrett Coakley – http://www.flickr.com/photos/garrettc/2172850095/
© Gopal Vijayaraghavan –http://www.flickr.com/photos/t3rmin4t0r/3947963283/in/photostream/
© H.Powers – http://www.flickr.com/photos/melisande-origami/108813447/sizes/l/
© H.Powers – http://www.flickr.com/photos/melisande-origami/108813447/sizes/l/
© Hobvias Sudoneighm – http://www.flickr.com/photos/striatic/3834431/
© Jimmie –http://www.flickr.com/photos/jimmiehomeschoolmom/2810673350/in/photostream/
© Joseph Robertson – http://www.flickr.com/photos/josephrobertson/59407804/
© Mike McCune – http://www.flickr.com/photos/mccun934/3261249676/
© Mo Riza – http://www.flickr.com/photos/moriza/96724309/in/photostream/
© Mo Riza – http://www.flickr.com/photos/moriza/96724309/in/photostream/
© Pyno Moscato – http://www.flickr.com/photos/pinomoscato/3992211669/
© Rob Shenk – http://www.flickr.com/photos/rcsj/400758302/sizes/l/in/photostream/
© Sean Dreilinger –http://www.flickr.com/photos/seandreilinger/2326448445/in/photostream/
© Sean Dreilinger –http://www.flickr.com/photos/seandreilinger/2326448445/in/photostream/
© Steve Harwood – http://www.flickr.com/photos/captkodak/272746539/in/photostream/
© Thomas Hawk – http://www.flickr.com/photos/thomashawk/2442371176/
© Troy Holden – http://www.flickr.com/photos/troyholden/4114564467/in/photostream/

Mine ears have attended dConstruct 2010

I remember seeing the speaker list for dConstruct 2010 go up and thinking “that is so so awesome, I am definitely going to that”: Merlin Mann, Tom Coates (particularly), John Gruber. Amazing. Then this summer it was decided that we should have a family holiday, with my in-laws, between the 21 August and the 4 September. Because I am a Big Man (emotionally) I sucked it up, didn’t create a scene, and had a lovely time… with my mother-in-law… missing dConstruct. (Actually my mother-in-law is lovely, it’s just hard to avoid the temptation to play to the stereotype.)

Luckily dConstruct are also great in that they record the audio from their conferences then get it online really quickly, so this week walking to and from my office has been accompanied by lots of lovely ideas banging on my ear drums. My highlights were, in no particular order: John Gruber, for a lucid and illuminating treatise on why the captain of your ship should have really good taste; Hannah Donovan, for starting her talk on design jam sessions with some musical improvisation; Tom Coates, on how the tendrils of the web are beginning to reach into the objects of our lives; James Bridle, on knowledge structures and the history of knowledge artifacts; and Merlin Mann, rambling on about how we’re all nerds, how that’s (mostly) great, and some nerdery coping strategies, along with anything else which happened across his brain. In a fit of quite staggering arrogance I’ve assembled these highlights into a shortened Simon’s dConstruct 2010 edit but if you have the time, I recommend the whole gosh-be-darned shooting match here so you don’t miss the rest of the talks. Enjoy!