Category: Blog

  • Charging for themes? Do the right thing!

    Of all the WordPress functions, I think wp_register_script, wp_register_style, wp_enqueue_script, and, wp_enqueue_style are the most elegant. It’s possible to get away with using only the wp_enqueue_* functions, but I prefer to use both for a little bit more control.

    For the uninitiated, these functions allow you to add JavaScript and CSS files to the header (or footer, in later versions of WP) without running of the risk of another plugin adding the same file, that is, you avoid the following:

    <script type="text/javascript" source="http://.../a-plugin/jQuery.js"></script>
    <script type="text/javascript" source="http://.../a-plugin/plugin.js"></script>
    <script type="text/javascript" source="http://.../my-theme/jQuery.js"></script>
    <script type="text/javascript" source="http://.../my-theme/theme.js"></script>

    If you develop themes or plugins for WordPress and are unaware of these functions, you should refer to the codex to get the low down on at least wp_enqueue_script, and wp_enqueue_style – these register and queue the files, the wp_register_* functions register the file ready to be queued for output.

    The Rant

    Despite the value these functions can add to themes and plugins, they are under-utilised in development. The functions have wider adoption in plug-in development, but it’s still well below 100%. In theme development adoption is virtually non-existent (at least in the themes I’ve used).

    This failure to code properly is evenly spread across both free and paid themes. I?m happy to look the other way for free themes. After all, the motivation behind the theme may have been to learn WordPress development.

    In commercial themes, particularly those above the US$30-$35 price point, it’s downright frustrating that these products haven’t been developed properly.

    When someone purchases a theme, they shouldn’t have to debug the product to find out why a JavaScript framework is being included twice. The reason for the purchase is that they either don’t want to, or know how to, develop.

    Avoiding costly mistakes

    Evaluating a commercial theme on behalf of a client triggered this rant. At $195, it’s quite expensive in the world of WordPress. As I was viewing the source code of the online demo, I discovered the faux pas. We’ll advise against using that theme as a starting point. In fact, within short time we’d found a theme $195 cheaper that would do the job.

    Looking at the source code of a demo site is usually enough to tell you how the theme is inserting its scripts:

    • Both <link> and <script> tags will use single quotes around attributes (‘), rather than double quotes (“),
    • CSS <link> tags will have an ID attribute ending in -css, eg: id=’shadowbox-css-css’, and,
    • JavaScript and CSS files include the version number as a query string eg jQuery.js?ver=1.3.2 (although a hook can be used to remove this)

    Making sure that the wp_register_script, wp_register_style, wp_enqueue_script, and, wp_enqueue_style are included properly will save time, bandwidth and also avoid some detrimental conflicts.

  • Partying like it’s 1999

    A little under twelve months ago I wrote a post on a JavaScript base file I’d set up:

    I could have used an existing frame work, such as the increasingly popular jQuery; I decided to use my own, which contains only the very basics, rather than have a larger file containing rarely used functions

    source (emphasis added for this post)

    Within a couple of months of writing that, I was a convert to jQuery. There was no single reason for my conversion, from memory some of the reasons where:

    • the selector engine,
    • plugin availability,
    • documentation — both official and unofficial tutorials, and,
    • lazyness

    It’s the last one that probably had the biggest influence, I’m too lazy to reinvent the wheel, and without using a framework that’s what I was going to be doing. Frequently. Examples in blogs I read, weather it be group blogs, such as A List Apart, or one person shows, such as CSS-Tricks were all beginning to use jQuery. If I were to stick to my guns and not use a framework, I’d be doing a lot of rewriting.

    As for the functions that are rarely used? It’s really only the Ajax group of functions that I’ve never used, for the simple reason that I don’t like Ajax. In many of the situations it’s used, it is often fanciness without necessary function. Then again, ask me about Ajax in a couple of months’ time.

  • How to get 4.3 stars for customer service!

    Coincidently, a few days after deciding to write this post, I was listening to NPR’s On the Media reporting on the problem with online reviews:

    When it comes to rating products online, it turns out we’re way too nice. The average out of 5 stars for things like dog food, printer paper or boots is 4.3 and … all that kindness is actually kind of a problem.
    Source

    Which presents a problem: I’m about to give a positive review to Soupgiant’s host, QuadraHosting, due to their customer service, despite some major technical problems in recent months. This leads to one question: Am I being too nice?

    In July, all sites on our hosting account — fortunately none of them belonging to clients — experienced an outage due to a data centre power failure.

    Since then, it appears both Quadrahosting and Equinix have been working to ensure such a problem doesn’t happen again.

    Another outage on Sunday Oct 12, 2009, between 8:20am and mid-afternoon, and my thoughts were that a change of webhosts was not only necessary, but probably urgent. As the outage was long enough to trigger an SLA credit, I wrote to QuadraHosting and requested a 10% credit to our account, which they subsequently denied:

    Section 4a states that we do not cover loss of external power due to ‘[an] inability to obtain raw materials, supplies, or power used in or equipment’

    If this was related to our internal power set up, then we could credit you, though it was the main power source that was [affected].

    We apologise for this.

    I responded that I disagreed with their assessment ‘as it was an upgrade by the data centre’ but that I accepted their decision. Rather than leave it at that, I detailed my real concerns which was rather more than the $2.99 I was hoping to get back. My concerns are:

    …that since the external / power company outage a couple of months ago, I’ve found that my server is going down more frequently. I don’t know if the timing is a coincidence, but the result is I no longer am able to recommend you to my clients.

    (Pro tip: at no point did I call them thieves, or worse, reality TV contestants)

    Rather than leave respond with a cursory, ‘thank you for your comments,’ Brendan, who was handling my case, responded:

    We appreciate you taking the time to provide us with some feedback. The upgrade was related to the power of the Data Centre. Please note that we do purchase power from them and this is considered as a third party source.

    The upgrades to the systems in recent weeks were planned and announced to all our customers.

    With this in mind, we have decided to give you credit to cover one week of your hosting plan.

    Hopefully you will see major improvements in our systems once this power issue has been completed.

    I believe there will be a similar incident in two weeks which we be very similar to the power outage we have recently experienced.

    It seems there are major power upgrades at the data centre related to expansion. We will announce this to our customers when we have more information.

    The end result, after some fine customer service, an explanation of how they obtain their power, and a little bribery, is that I’ve decided to stick with QuadraHosting while they and their data centre fix the power issues. If the problems continue after the upgrades, then I’ll reconsider my options.

    Having dealt with a number of hosts and the kind of customer service that involves a student reading a script, I do think good customer service at a host is worth sticking around for. While their servers at the moment are a little up and down, the customer service outweighs that disadvantage.

    All in all, I give QuadraHosting a 4.3 star rating for their customer service.

  • Including WordPress’s comment-reply.js (the right way)

    Since threaded comments were enabled in WordPress 2.7, most themes include the following line in header.php

    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>

    This code checks if the visitor is browsing either a page or a post and adds the JavaScript required for threaded comments if they are.

    I prefer a slight variation

    <?php
    if ( is_singular() && comments_open() && get_option('thread_comments') )
      wp_enqueue_script( 'comment-reply' );
    ?>

    My variation checks if the visitor is browsing either a page or a post, if comments are open for the entry, and finally, if threaded comments are enabled. If all of these conditions are met, the JavaScript required for threaded comments is added.

    If you run your wp_enqueue_script calls in functions.php, as I do, this is the code to use:

    <?php
    function theme_queue_js(){
    if ( (!is_admin()) && is_singular() && comments_open() && get_option('thread_comments') )
      wp_enqueue_script( 'comment-reply' );
    }
    add_action('wp_print_scripts', 'theme_queue_js');
    ?>

    The call is added to the wp_print_scripts action as is_singular and comments_open are unknown during the init action.

     

    Note: I’ve written a plugin to make the comment-reply JavaScript unobtrusive, it’s call Rapid Comment Reply.

  • Career Stats: Shane Warne the Musical (.com.au)

    Very generously, the producers of Shane Warne the Musical have given me access to their website stats for the purposes of this post.

    All statistics below relate to the period from opening night – December 10, ’08 – until mid March ’09; during this period there were 25,377 visitors leaving 96,867 page impressions.

    Of the site statistics I have access to; SWTM provides an example of a site with a cross-section of visitors, from multiple age groups and backgrounds. This is all conjecture on my behalf; Google Analytics is yet to report sex, age group, and economic circumstances (but they’re probably working on it).

    (more…)

  • Caching on the Google AJAX Libraries API

    Using the Google AJAX Libraries API, there are several options for specifying the version numbers of the library you wish to use, for example the following URLs all point to the latest version – at the time of writing – of jQuery.

    1. http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js,
    2. http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js, and,
    3. http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js

    The first uses the latest release in the version 1 tree, the second the latest in the version 1.3 tree, and the third the release 1.3.0 exactly. What I found interesting – and discovered accidently – is the browser caching times for each of these urls; the first two are cached for an hour, the third for twelve months.

    The vastly different caching times make perfect sense, in the first two cases, the developer is expecting an upgrade to the latest version, and doesn’t want to wait up to twelve months for it; in the third case the developer doesn’t expect an upgrade so an extended caching period has no effect.

    To take full advantage of the Google servers, as described in a recent article by Dave Ward, the caching times suggest it’s best to specify the full version of the library you wish to use.

    google.load Method – Update Jan 24, 2009

    (more…)

  • Why I will not be dropping support for IE6

    Increasingly I’m reading of web developers deciding to drop IE6 from their list of supported browsers, usually, because of its creative interpretation of CSS standards, besides IE7 is over a year old, and, IE8 about to be released.

    I’ve decided to continue support for IE6 as it’s still in wide use – especially in corporate environments – and, I don’t think it needs to take a lot of work to develop for. I’ll say that again, I don’t think IE6 is as bad it’s sometimes made out to be.

    (more…)

  • JavaScript Equal Height Columns

    The desire for equal height columns in a CSS layout is nothing new; there are many solutions available, some use JavaScript, others use CSS with negative margins, and then, there’s the faux columns method using background images. All of these methods have their place as perfectly valid solutions, and, depending on the situation, may be the best solution available. (more…)

  • Base JavaScript File

    Upcoming posts on JavaScript will include references to functions in my base JavaScript file; rather than explain these functions each time, they’ll be detailed in this post for future reference.

    There are many pre-written JavaScript examples and functions available, so it’s important to note that all of these functions have been written by others, some include slight changes; all moved to the namespace PWCC, as you’ll see in the source code.

    (more…)

  • Review – Everything you know about CSS is wrong!

    During the week I read Rachel Andrew and Kevin Yank’s Everything You Know About CSS Is Wrong! At a little over 100 pages it’s a concise explanation of CSS tables and how they will – and an argument why they should – change the way in which web developers work.

    EYKACIW! begins by explaining how today’s web developer has hacked CSS to do things it was never designed to do, in much the same way that we hacked HTML tables in the heady days of the 1990s; floats, faux columns, negative margins, positioning, and, several more tricks now used as a second nature all get dishonourable mentions.

    (more…)