Author: simonwheatley
-
Escaping lists of strings for SQL in WordPress
Today I found myself wanting to use a query similar to SELECT DISTINCT post_id FROM $wpdb->posts WHERE meta_key IN ( ‘string_x’, ‘string_y’, ‘string_z’ ), but where I needed to construct the values for the list of strings from an array of untrusted values (because we never trust inputs, we always look suspiciously on them if…
-
Dragging, dropping and sorting, with jQuery UI
I spy a nice opportunity to document some jQuery UI functionality I’ve been playing with this afternoon, for a soon-to-be-revealed client project. The project needs photo galleries, and as these need to be tied into the other custom post types and taxonomies, I’m quickly rolling my own so I can completely control the experience for…
-
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: 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…
-
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…
-
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…
-
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…
-
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…
-
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,…