Use BraincraftedBootstrapBundle for Twig forms without Assetic compilation

One of my favourite features of Bootstrap is the form styles, which I’ve wanted to incorporate into various Symfony2 Bootstrap applications I’ve been working on. The BraincraftedBootstrapBundle has a really robust set of styles for Symfony forms but also attempts to throw Bootstrap into Assetic. I’m not a fan of this, I use bootstrap’s SCSS repository and I’m happy managing the dependancy through bower.

In order to stop BraincraftedBootstrapBundle from injecting this into assetic, throw this in your config.yml:

        assetic: false
        twig: true
        knp_menu: false
        knp_paginator: false

A modern Composer workflow with WordPress

Updated on 27th August with different methods for getting WordPress packages

This is a guide on how to incorporate a modern Composer workflow into your WordPress builds. This aimed at people who run WordPress websites as a service – typically bespoke theme developers who want to get a bit more out of WordPress as a tool.

This article prerequisites an understanding of Composer; Composer is a great PHP package manager so if you haven’t used it before give it a look. I won’t go into the specifics of how to use it or set it up as there are plenty of great guides on how to do that.

Composer by default installs it’s packages in `/vendor/` and adds the contents to the PHP autoloader. When we want to install WordPress, that’s not so much what we want. This article should be useful for anyone that wants to install PHP packages that don’t necessarily follow the composer format.

Continue reading “A modern Composer workflow with WordPress”

Temporarily add WordPress actions and filters

Quite regularly I need to use a WordPress filter or action for one little snippit of code and return it back to normal. I’ve done this with anonymous functions. It’s a quick and nifty way to get things done without writing things unnecessarily to the global scope.

function theExcerpt($length = 55, $more_text = '…') {
    $change_excerpt_length = function($old_length) use ($length) {
        return $length;
    $change_excerpt_more = function($old_more_text) use ($more_text) {
        return $more_text;
    add_filter('excerpt_length', $change_excerpt_length, 10);
    add_filter('excerpt_more', $change_excerpt_more, 10);
    remove_filter('excerpt_length', $change_excerpt_length);
    remove_filter('excerpt_more', $change_excerpt_more);