Passing Multi-Dimensional Arrays from WordPress to JavaScript

On its own wp_localize_script() can’t handle multi-dimensional arrays, but you can get around that by encoding the child arrays in JSON. That doesn’t handle HTML content very well, though, so another way to do it is to use the l10n_print_after parameter. That’s kind of ugly, but it seems like the best way available right now. It […]

Continue reading...

Tweaking Apache Settings for VPSs

Apache’s default settings assume it’s running under a dedicated box with at least 2GB of RAM, so they don’t perform very well in a VPS that may only have 500MB. I recently made some tweaks to several VPS’s that reduced memory usage by 300-400MB without degrading performance. Apache Performance Tuning is a good article that […]

Continue reading...

Creating an OpenVZ Template From an Existing VPS

I recently setup a VPS on a new OpenVZ node and wanted to use it as a template for future VPS’s created on that node.  The instructions in the wiki are actually overkill for this situation; here’s all I had to do: vzctl stop [vps id] Create /tmp/vz-template-exclude.txt and add these lines to it: .bash_history […]

Continue reading...

Conditionally Loading JavaScript and CSS in WordPress Plugins

Update 1/2/2013: As of WordPress 3.3, it’s now possible to call wp_enqueue_script() directly inside a shortcode callback, and the JavaScript file will be called within the document’s footer. That’s technically possible for CSS files as well, but should be considered a bad practice because outputting CSS outside the <head> tag violates W3C specs, can case FOUC, and may […]

Continue reading...

The Necessity of Contracts

Mike Monteiro and Gabe Levine gave a great presentation for Creative Mornings on the necessity of contracts when doing client work. I never really liked using them because 95% of projects go smoothly and it seems kind of impersonal, but after a recent experience and talking to other developers, I’m beginning to see the need for them, and […]

Continue reading...