Quick List: Things WordPress Plugins Developers Can Do to Help Their Plugins Scale

1) For heavy backend operations like generating reports, don’t generate the screen on the init hook. Schedule a cron job and generate it periodically … if the administrator needs it right away, give them a refresh button.

2) Don’t autoload options unless they are really needed on every page load. And if you do autoload the option then make sure it isn’t too big 10KB should be plenty. Keep in mind if you create your option for the first time using the update_option(); [codex] function it will be autoloaded by default. So you should instead intiate the option using add_option('myoption','myvalue', false);

3) Don’t use wp_postmeta fields for numeric calculations. WordPress strongly encourages developers to work within their custom post type API, which is good, but that doesn’t mean the Metadata API is equally good for all data types. For instance a post_type, “order”, in which the record will have fields like ‘subtotal’,’tax’,’discount’,’grand_total’, which will likely be summed and counted and multiplied etc, go ahead and use a custom table with a foreign key on post_id.

Obfuscate Your Code at Your Own Risk

Looks like ZippyKid no longer supports WishList Member. I think it raises a good point about obfuscating code. Hiding your code behind some sort of encryption like Base64 may prevent your code from being ripped off, but it also prevents it from being improved and supported. If WLM made it’s code transparent it could share the burden of support and innovation with other services and developers. ZippyKid/WP Engine/WPMU/WP.com and on and on. But the obfuscation instead guarantees this vast community of resources can be of no benefit to WLM at all. I hope it’s worth it.

Thesis Cache(r) Beta – 2012-07-31

Through my work at WPEngine I’ve found that using the Thesis Theme can occasionally lead to some performance issues on higher-traffic sites. Nothing spectacular, there are a ton of themes out there that have some issues scaling. Thesis is not special.

But what occurred to me about Thesis, is that it really should be one of the more performant themes out there.  The logic of the theme is organized hierarchically. Thesis passes all html output through thesis_html_framework() which means it is very easy to grab it and cache it, thus adding an additional layer of caching using the WordPress Object Cache.

[download link=”/downloads/thesis-cacher.zip”]

Why would you need this if you are already using W3TC or using a hosting company like WPEngine. Both give you various tools for page caching … why use another?

Well, first this plugin is not about replacing your existing caching, but instead making sure that you have adequate caching at the theme level. Even with system level caching there are going to be times where the cache is not served … either because a user is logged in, or because you are getting a lot of traffic and the cache is just missing, or because the cache was purposefully cleared.

ThesisCache(r) just gives you another layer to prevent consuming MySQL/PHP memory if you don’t have too. It gives you page-by-page,post-by-post control over whether to cache a post (or any post type). You can choose to NOT cache a page … or you can even choose to NOT cache the sidebars even though you want to cache the rest.

If you are not currently using ANY object caching no worries, ThesisCache(r) will set up a file-based object cache for you. If you are using an object cache, it will simply leverage what already use.

ThesisCache(r) isn’t in the Plugin Repo yet so here’s the download link. Please report any issues you have in the comments below. I’ll try to deal with them when I can.

[download link=”/downloads/thesis-cacher.zip”]

Plugin Shoutout : Advanced Custom Fields

Like most developers, I have a tendency to want to code everything from scratch. I suppose like any craftsman, there’s a resistance to relying on a machine to do work you enjoy doing with your hands. But sometimes the challenges of a particular project force your hand and you need to save time on meta boxes and custom fields and spend more time on other aspects of the project. Lately I’ve been relying on Advanced Custom Fields for managing custom fields and I’ve been very impressed.

The interface is smooth and as far as I can tell so far, there’s no front end performance hit. Though, I must admit I do not use the front-end functions provided by ACF and instead prefer to rely on the standard <code>get_post_meta()</code> approach.

But there are two things specifically I enjoy about this plugin. First, it gives you the option to have your “field group” either inside an expandable meta box. This is the standard way custom fields are presented. But it also gives you the ability to add the fields right into the form with no meta box wrapping element. This gives your form some variety. (see screen shots)

The second thing I really enjoy about this plugin is the API for adding custom field types. Developers always love finding an organized API when they need one. For this specific project I need a field where the user could select a NextGen Gallery from a dropdown. All I had to do was create a class extending the acfField. Then add the following to my functions.php:

add_action('acf_register_field','ngg_register_acf_field');
function ngg_register_acf_field() {
add_filter('acf_register_field','ngg_field',0,1);
}

function ngg_field($custom) {
global $acf;
$ngg = array('class'=>'acf_NGG_Gallery','url'=>PATHTODIR.'/acf_ngg.php');
$custom['ngg'] = $ngg;
return $custom;
   }

Popup Domination Plugin Breaks WordPress 3.3

I’m not the first to be frustrated by the Popup Domination Plugin busting the WordPress admin after upgrading to 3.3. The reason for the break is pretty simple. The plugin uses a WordPress function that itself relies on a function that has yet to be bootstrapped at the point at which the plugin is loaded. The solution is easy thanks to this post. Once you apply the fix you’ll see that Popup Domination has an update. Just auto-upgrade to the new version and you’ll be fine.

Manage BuddyPress Inactive Users

So I quickly threw together this plugin today for a project I’m working on in which I need the ability to resend individual “welcome” emails via the standard WordPress admin. It very simply adds a screen in the user admin that queries inactive users and then adds a button to each row to send the email. This plugin was designed to work with BuddyPress installations and is not a stand alone. I’ll be adding mass edit and manual activation shortly.

Download Plugin

WordPress jQuery PopUp Plugin (BETA)

Status: Due to my being overworked at the moment, I am only “sort of” supporting this plugin. If you need full time support I recommend Popup Domination

Nothing is more exciting than when a clients needs collides with a developers interests. I’ve been wanting to write this plugin for a while but never had the time to make it a priority … at least not until this week when a client requested. Synergy! I started writing it this morning and couldn’t stop until I had something releasable.

WordPress jQuery PopUp Plugin

So here is is. Just upload and activate.

[download link=”https://wordpress.org/extend/plugins/jquery-popup-plugin/”]