“De badge is goed”

Op vraag van de gemeenten waar erg veel werklozen wonen, heeft de regering een draaiboek opgesteld. […] Een onderdeel dat daarbij buitengewone aandacht krijgt, is de badge die alle werklozen zullen krijgen en die ze geacht worden altijd bij zich te hebben. Die identificatieplicht associëren met de verplichting de Jodenster te dragen, is kwalijk. […] De badge maakt de bezitters ervan niet tot paria’s, dat waren ze al van de dag dat ze hun werk verloren. Integendeel, het document houdt een eerste vorm van erkenning in en bekleedt hen met rechten die ze voorheen niet bezaten.

Uit “De badge is goed” op Radio Plasky, geïnspireerd door “Leve de badge” op De Standaard.

Autoptimize to allow optimizing whitelisted resources only (and more)

Although work is still ongoing on what will become Autoptimize 2.0, I thought I’d share an (API-only) feature that allows developers/ web agencies to only aggregate & minify a fixed set of known-good resources only. This whitelist-based optimization will allow for a more stable situation upon delivery of your project to customers, as the CSS/ JS of plugins that are installed by your customer will not be autoptimized, so the site is less likely to break by accident.
The following example-code shows how to tell Autoptimize to only aggregate & minify jquery.js and jquery-migrate.min.js;

add_filter('autoptimize_filter_js_whitelist','example_js_whitelist');
function example_js_whitelist() {
return "jquery.js,jquery-migrate.min.js";
}

Using autoptimize_filter_css_whitelist allows you to accomplish the exact same things for CSS. The guys over at gigaom.com are already using autoptimize_filter_js_whitelist, so we must at least be doing something right there.
Some other new filters that might prove helpful;

  • autoptimize_filter_css_removables and autoptimize_filter_js_removables will allow you to specify which CSS or JS should actually be removed alltogether (Google Fonts, Emoji’s, … all in case you don’t like dequeuing off course)
  • autoptimize_filter_css_inlinesize allows you to specify up until how many characters of optimized CSS should be inlined instead of linked (can be useful for print CSS). Default value is 128, but I might bump that to 256 actually.
  • passing “true” to autoptimize_filter_css_fonts_cdn will tell AO to try to switch the font URL’s to your CDN
  • autoptimize_filter_cssjs_multidomain takes an array which can be used to tell AO that are also to be considered local domains and resources from those can be optimize (warning; as AO aggregates from the filesystem, this only works if the resources are actually local)
  • autoptimize_filter_cachecheck_do, autoptimize_filter_cachecheck_frequency and autoptimize_filter_cachecheck_maxsize can be used to control the wp-cronned cachechecker that will get triggered daily

Non-API improvements include performance optimizations, out-of-the box support for WPML subdomain-based language-variations and a whole heap of smaller improvements and bugfixes (e.g. the fact that if you have multiple title-tags, the optimized CSS would be injected in front of every one of those).
So yeah, I’d say we almost have ourselves a release. Only major thing still to go in; swapping the “look only in head” for an “include inline code” option. And testing of course, but that’s one area where I am looking at YOU, dear reader! Download the in-development version from GitHub and test away!

WP YouTube Lyte: new player UI and API tips

WP YouTube Lyte 1.6.4 was released a couple of hours ago and features the new YouTube player look and feel:

Vieux Farka Touré & Julia Easterlin - Little Things (Music Video)

Here are some tips on how you can tweak that to match your own preferences;
As you can see in the vid above (Vieux Farka Touré & Julia Easterlin – Little Things), I wanted WP YouTube Lyte to show the bottom control (which as on YouTube is now invisible by default) add can be accomplished with just a little CSS:
.ctrl{display:block !important;}</code>

If you’d like Lyte to use the exact same font as YouTube does, you can add CSS to import that font and it will be applied to title-field in Lyte:

@import url(https://fonts.googleapis.com/css?family=Roboto&subset=latin,latin-ext);

You can even use Lyte’s API do alter the CSS like this;

add_filter('lyte_css','lyte_change_css',10,1);
function lyte_change_css($lyte_css) {
        // source the font
        $lyte_css="@import url(https://fonts.googleapis.com/css?family=Roboto&subset=latin,latin-ext);".$lyte_css;
        // show bottom control
        $lyte_css.=" .ctrl{display:block !important;}";
        return $lyte_css;
}

Talking about the API, you can now also force Lyte to be active on mobile as well (which is not the default as it would force your visitors to click “play” twice, once to load the YouTube iFrame and once to play as mobile YouTube doesn’t support autoplay), you can use this code;

add_filter('lyte_do_mobile','lyte_on_mobile',10,0);
function lyte_on_mobile(){
        return true;
}

Solve WP Super Cache + Autoptimize Internal Server Errors

Yesterday I noticed my autoptimized JS-files were returning an internal server error (CSS worked as that is inlined). My Apache error-log had this entry:

[Tue Oct 13 17:23:42 2015] [alert] [client 178.xx.xx.xx] /var/public_html/blog.futtta.be/wp-content/cache/.htaccess: Option Indexes not allowed here

/var/public_html/blog.futtta.be/wp-content/cache/.htaccess is created by WP Super Cache, which got updated recently, a.o. to disable indexes being created of directories, and the .htaccess indeed read;

# BEGIN INDEX
Options -Indexes
# END INDEX

The solution? I could have edited WPSC’s .htaccess, but my changes could get overwritten there whenever Donncha would feel like it, so in the end I edited my site’s config in Apache;

<directory /var/public_html/blog.futtta.be>
AllowOverride All
</directory>

And all is well now.

3 interesting WordPress plugins

I came across some interesting WordPress plugins and thought I’d document these quickly;

  1. Warm Cache; have your site crawled based on your sitemap.xml to re-generate your cache (applicable to both your page cache and Autoptimize’s cache)
  2. Duplicator: export your entire WordPress installation to an archive and install elsewhere. Haven’t tried this yet, but might come in very handy at some point.
  3. Code Snippets: don’t burden your theme’s functions.php with your own code (risking losing the changes with a theme update), but use Code Snippets instead. Handy if you want to e.g. tell Autoptimize not to be active on specific pages or if you want WP YouTube Lyte to also act on youtube-links in text widgets for example.