Debug WP-Cron with Trigger Scheduled Events

I’ve added a new plugin to the directory called Trigger Scheduled Events, which does pretty much what it says on the tin. With it, you can view a list of all events scheduled by WP-Cron and run any of them instantly instead of waiting until the next time the event is scheduled to be fired.

WP-Cron is useful because it allows you to schedule events to happen later using the wp_schedule_event() function, but during development this can lead to a lot of waiting around to see if your code works. Trigger Scheduled Events gets around this problem by allowing you to run your events on demand.

Get it!

You can download the plugin through the Add New menu from your WordPress admin or you can download it from the plugin directory. If you’d like to make suggestions for improvements, you can do that over at the plugin’s GitHub page.

Shopify Image Variant Swap on iOS

A while back I was building a Shopify store for a client and I had used the Variant Images app to assign photos to individual product options. This app is pretty cool, but it has a couple of drawbacks. The dealbreaker for me was that its javascript doesn’t work at all on iOS currently.

In order to get image swapping working on iOS, I ended up writing my own simple script to detect when an option is changed, look for an image to match, and swap it into place. Implementation is pretty simple.

  1. Create your product options.
  2. Upload your images and set the ALT text to match the value of the option. If you’re selling t-shirts and you have an option called Color with variants Red, Green, and Blue, you would upload an image for each and set the ALT text on the images to “Red”, “Green”, and “Blue” in order to match them up.
  3. Insert the following code into the bottom of templates/product.liquid:
{% comment %}
Custom Image Swap - Image name must match option value…nt-swap-on-ios/
{% endcomment %}
        // create an associative array of images, using alt text as key
        var product_images = new Array();
        {% for image in product.images %}
            product_images['{{ image.alt | escape }}'] = '{{ image | product_img_url: 'original' }}';
        {% endfor %}

        // change the featured image source
        jQuery('.product-options select').change(function(){
            if ( jQuery.inArray( jQuery(this).val(), product_images ) ) {
                jQuery('.image.featured img').attr('src', product_images[jQuery(this).val()] );

Now your images should be swapping when you select a new option. As an added bonus, this script works with Shopify’s image zoom function. And since it’s pretty straightforward jQuery, if you need it to function slightly differently it’s pretty easy to modify. If you’d like to see it in action, check out the demo store.

Batch Convert Domain Names to IP Addresses

Last week I needed to check a large number of sites to see how many of them were still hosted by my employer’s legacy system. After clicking through about 80 of them I realized it would have been much smarter to just ping them and see what IP address they were living at. I looked for a tool that would do that for me, but didn’t find one that would accept a list of domains and look them all up at once. So I made one. may be a new favorite among my tiny web apps. It accepts a list of host names and looks up the IP address of the server each is pointing to. That’s it. Please enjoy this potentially useful app that does exactly one thing.