Category: Code

Unit testing WordPress plugin headers

WordPress plugins require a number of headers to be included in the plugin file for them to render correctly in the dashboard. If releasing a plugin on WordPress.org then a number of additional headers are required in the readme file. The problem I have is that I can never remember which header goes where. Each […]

Code

Using real cron for WordPress with WP CLI

For WordPress site owners wishing to use real cron via a crontab job, it’s fairly common to see advice to use curl to request the site’s wp-cron.php file on a regular basis. In the days before the WordPress CLI (WP-CLI), using the wp-cron.php file was the only technique available to site owners wishing to use […]

Code

Allow developers to make mistakes

Occasionally I look at the theme for one of the first WordPress sites I developed. I look at my early PHP, my early CSS, my early JavaScript & my HTML about ten years into my career. The HTML has at least lost its font tags and table based layouts but my overall reaction is to […]

Code

A fitVids vanilla JavaScript do-over

FitVids.js is a jQuery plugin used to create fluid videos. It helps makes video embeds from YouTube, Vimeo and a number of other sources display nicely on responsive sites. FitVids calculates the ratio of a video, wraps it in a div and sets the padding to enforce a ratio. A typical 4:3 YouTube embed starts as: <iframe width=”420″ […]

Code

Five common WordPress patterns I avoid

I write quite opinionated front-end code. It’s one of the advantages of working in the industry for around twenty years, I know what does and doesn’t work. Working in a rapidly developing industry long term has taught me to be open-minded too, to listen to new ideas and to be prepared to adapt them. I’ve […]

Code

Preparing for WordPress 4.4 comment form changes

As detailed on the Make WordPress blog, the order of comment fields will change in WordPress 4.4, scheduled for a December 2015 release. This may affect your theme if the comment form doesn’t use the typical layout of one field above the other. Preparing your theme for the release of WordPress 4.4 will require your CSS […]

Code

Responsive Web Design MVP

This is not another responsive web design equals web design post. That particular debate is largely answered every time an m-dot link is shared on Twitter or Facebook. Ethan Marcotte’s landmark A List Apart article defined responsive web design as having three technical ingredients: fluid grids flexible media media-queries. It’s often argued that modern responsive […]

Code

WordPress 4.2.3 and the benefit of time

WordPress 4.2.3 has reminded me why being conservative with enhancements is a good thing. If a bug is committed, you lose the benefit of time to fix it. WordPress 4.2.3 has broken some sites using shortcodes in HTML tag attributes. As part of a security fix, certain ways of doing this are no longer possible.

Code

Unobtrusive Comment Reply JavaScript for WordPress

I’ve decided to rewrite the JavaScript in the comment-reply.js file used on the front-end of WordPress sites with threaded comments enabled. The version included in WordPress uses inline events, I’m rewriting it to be unobtrusive. I’ll be submitting a patch back to WordPress core once it’s done. It’s available as a plugin if you want to […]

Code

Removing Google Analytics referrer spam

Referrer spam is one of the more frustrating developments on the web in recent years. The premise is simple enough, a site owner sees a new referrer in their analytics and visits the website in question to investigate the source of new traffic. The page in question does not contain any such links and instead advertises anatomical […]

Code