Category: Development

  • Filtering Blocks When allowed_block_types_all is a boolean

    If you’re trying to filter which blocks are allowed in the WordPress block editor using allowed_block_types_all but the value is true/false it’s difficult to know what to do. I’ll cover every use case here: If It’s false This means no blocks are allowed. Note that I’ve used empty here so that it also catches empty…

  • Gutenberg Comments

    You might have noticed my comment section looks a little.. blocky.. After my WordCamp Europe talk in Berlin about the block list module, I decided to polish up my examples some more and deploy to production. And so I present, block comments, a prototype of block editor powered comments. https://github.com/tomjn/block-comments FAQ How Does it Work?…

  • Using HTTP2 Push With WordPress

    Taking advantage of HTTP/2 push can bring big improvements to front end performance. This pushes resources to the browser preemptively, avoiding extra requests and waiting time. I’m going to cover how to do this in WordPress. This has made big improvements to page load times, removing connections and waiting times for resources, as well as…

  • How Frontenberg Works

    How does Frontenberg work? I’m going to walk through what I did to build a frontend Gutenberg site, the problems encountered, and the fixes

  • VIP-VVV

    Mourning the loss of VIP Quickstart? A fan of VVV? Then I have something for you. Presenting, an unofficial Tom and Lorelei venture: VIP VVV! Available now on GitHub at https://github.com/tomjn/VIP-VVV To setup, simply add this to your VVV’s vvv-custom.yml file under the sites section: Then run this command: This will create a subdomain multisite configured for WordPress.com…

  • What’s New in VVV 2.0

    Varying Vagrant Vagrants ( VVV ) has undergone a small transformation for the better. This post will cover what’s changed and how to make sure your local developer environment isn’t left behind. The New Main Provisioner The fabulous Lorelei Aurora has rewritten the provisioning system for VVV, enabling a slew of new features and improved…

  • The Correct Way to Build Plugins – The Bitter Truth

    What is the correct way to build a WordPress plugin, the official, recommended way that was always intended? The idealised standard? The Problem Plugins are not discrete modules in the WordPress world. Their isolation exists only on the filesystem, but once that code is loaded into memory it shares the same space as Core itself.…

  • Vagrant Provision Timeouts

    Have you ever encountered this error? Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured (“config.vm.boot_timeout” value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the…

  • WordPress and Composer TLDR

    There’s a few questions I’m commonly asked about using composer + WordPress. Here they are in a super short form FAQ: To install a composer project, run: To update a composer project, run: Install WordPress in a folder or in your composer.json add: Note: This is a subdirectory install, you really don’t want to nest composer packages.…

  • Root Composition in WordPress Plugins

    When I build a WordPress plugin, I use several methods to structure things that help me greatly, all of which stem from root composition. I’m going to expand on what that is and how I use it. Every plugin has a root file that contains the plugin header comment, and gets loaded by WordPress. This…

  • ___ without a plugin

    How do I do ___ without a plugin? The answer is to remove the comment at the top of the plugin, and it’s no longer a plugin.

  • Theme Composition vs Frameworks

    For a long time, theme frameworks have been the primary alternative to building things from scratch in WordPress, and to a lesser extent, starter themes. There is a better way. Starter Themes & Frameworks Starter themes work on the paradigm of adding and replacing. You’re given a theme that represents the ‘halfway’ mark and add…

  • WordPress Bash Magic

    I’ve been doing a lot of bash scripting with WordPress, especially with WP CLI. Here are some snippets I found useful. All my scripts assume a standard wp-config.php with DEFINE() statements and no unusual logic structures. A rogue constant with the name DB_NAME may throw things off without some modification. Getting the Database table prefix If you…

  • Calling Constructors

    Take a look at this code, found inside the Jetpack Post Views plugin: Here an object is calling its own constructor. But what’s wrong with it? The General rule for calling __construct: The only occasion it is okay to call a constructor method directly, is in a child class that needs to call its parent…

  • Use of mysql_connect in WordPress

    Take a look at this code, found inside a PHP example: This looks familiar, it’s a basic MySQL query example, found on a University of Minnesota Morris server. But what’s wrong with it? The General WordPress rule for mysql_connect: When making an SQL query in a WordPress environment, use the WPDB class, do not use  mysql_connect…

  • &$this

    Take a look at this code, found inside a PHP class or object: This looks familiar, and can be found in many themes and plugins. But what’s wrong with it? It’s PHP4 code in a PHP5 world. General PHP rule for add_action: When creating a callable, never use &$this, use $this instead There is almost never…

  • ComposerPress

    Curious about Composer but already have a WordPress site? Not to worry, I have you covered. Presenting Composerpress: Composerpress is a plugin that analyses your WordPress install, and generates a composer.json file you can then use retro-actively. This file acts as an inventory of dependencies, plugins, etc that are needed to set up a site, and…

  • Creating Objects on Hooks/Actions

    Lets say we had a class that set up some important things. These things needed to be added on the admin_init hook, and they were done in our classes constructor. How would we create our object so they get set up on the admin_init hook? Some people may try to do one of these: But…

  • Alternative Post Loops

    We all know the standard post loop in every template, but what if we did something slightly different? Lets begin with the standard main loop we all know: There’s a lot of boilerplate there, what if we could reduce it down? Lets try using a feature of PHP 5 called Iterators: Put the class in…