All posts in WordPress

Cross Site Scripting Vulnerability in Subscribe2 Plugin

News of the XSS bug in Subscribe2 didn’t show up in any of my RSS feeds or mailing lists, even though it’s a fairly popular plugin,  so I wanted to make a note of it in case anyone else missed it. Version 8.2 has a fix for it .

Creating Admin Notices From a WordPress Plugin

I just threw a couple small PHP classes up on GitHub that I use in almost every WordPress plugin I write. The first is  IDAdminNotices , which is a clean and easy way for plugins and themes to send messages/errors to the user within the Administration Panels. The second is IDDescribeVar , which will outputs the type, length and contents… [more]

Preventing Callback Functions From Executing Multiple Times

Many actions in WordPress will fire multiple times, which can lead to performance drags and undesired/intuitiveness results. Pippin Williamson points out that you can check how many times an action has already run , and modify your code to respond accordingly.

Using Constants for a Text Domain in WordPress

Normally any kind of global values that don’t change within a program’s execution should be defined as constants, but text domains within internationalized WordPress plugins are an exception to that rule. Mark Jaquith explains why it’s important to use a string instead .

WordPress Developer’s Meetup Presentation on Child Themes

I’ll be giving a presentation on building Child Themes at the Seattle WordPress Developer’s Meetup tomorrow . You can follow along with the presentation if you plan on attending.

BackPress PHP Library

BackPress is a useful project that packages the re-usable code from WordPress into an independent library you can use in non-WordPress projects.

Including External View Files in WordPress Widgets

I ran into a problem today while cleaning up and modifying some widgets. I moved all of the markup inside widget() to an external view file, and then included it via require_once(), which worked fine. I then tried to do the same thing inside form(), but didn’t get any output. It turns out that you can’t use include_once() or require_once() inside form() ,… [more]

Comparing WordPress, Drupal and Joomla in 2011

Ok, so it’s already 2012, but I just came across an article comparing the three from last year and it was a good read. Like a lot of articles, though, the real value is in the comments more than the article itself. Going into it I had the impression that Joomla was a stagnant mess, but it sounds… [more]

WordPress Backup Options

Nathan Ingram put together a thorough post on backing up WordPress and a chart comparing various plugins and services .

Placing Snippets in a Functionality Plugin Instead of Theme

Dave Clements has a great suggestion for adding snippets to a WordPress site in a way that will preserve them between theme changes: create a simple functionality plugin .

Scaling WordPress Installations

TJ Stein gave a really good presentation at WordCamp Chicago 2011 about scaling and performance issues with WordPress installations. He focuses a lot on using ngnix instead of Apache, but also covers PHP object caching, Varnish, CDNs, benchmarking, etc. It’s a good overview of current practices, but there’s also a lot of specific tips throughout.

Different Approaches to Building a Theme-based Site

Mark Root-Wiley wrote a great article on the pros and cons of using premium themes, writing child themes and writing themes from scratch . It’s discussed in the context of WordPress themes, but most of it is applicable to other CMSs as well. I think it’s a good introduction to give clients when discussing which method is best for their project.

Differences between query_posts(), get_posts() and WP_Query

This WordPress Answers page explains the differences between the query_post() and get_posts() functions, and their relation to the WP_Query class. They both use WP_Query internally, but should be used in different contexts. Using them in the wrong context could lead to bugs that are hard to track down.

Re-Abolish Slavery Ribbon

I just released a new WordPress plugin into the repository that raises awareness about modern-day slavery by adding a “Re-Abolish Slavery” ribbon to WordPress sites. It’s running on this site, so  you can see a live example by looking in the upper-right hand corner. The ribbon links to the Not For Sale campaign , which is one of the leading organizations involved in fighting human… [more]

Unit Testing WordPress Plugins

Nikolay Bachiyski gave a good talk at this year’s WordCamp San Francisco about unit testing WordPress plugins . His method uses PHPUnit , which is an additional PEAR package you have to install on the server. You can then use MockPress to simulate WordPress in the tests. Another option is the SimpleTest for WordPress plugin , which uses SimpleTest instead of PHPUnit, doesn’t require installing a PEAR… [more]

Performance Improvements for Dedicated WordPress Servers

Mark Maunder benchmarked several performance tuning measures with a WordPress installation on a VPS server to show which are most effective. The biggest improvements were from installing PHP-APC , setting up Nginx to proxy concurrent connections for Apache, and using MySQL’s query cache.

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 looks like WordPress 3.3 might have a wp_add_js_data() function , which would be much… [more]

Conditionally Loading JavaScript and CSS in WordPress Plugins

When writing a WordPress plugin it’s considered a best practice to only include JavaScript/CSS/etc files on the specific pages that need them, rather than on every page load. This speeds up page load by reducing the number of HTTP transactions and also minimizes the risk of unnecessary conflicts between other files. There are two popular… [more]

Basic Google Maps Placemarks Plugin

I wrote a new WordPress plugin for a side project and just released it into the repository . It creates a custom post type for markers and then inserts them into an embedded Google Map, using the post’s featured image as the map icon. Note: all support requests should be posted to the support forums .

 
re-abolish slavery