WordPress Development in Gent

BDWM is a very small company, or “Bedrijfje” as we like to call it, that (or “Dat“) does something with websites. (Fun fact: Websites translated to Dutch, is also “Websites“.) What does this bedrijfje do with websites, you ask? Well, it makes them. ‘Makes’ translates to “Maakt“, in case you were wondering about that.

BDWM was founded in 2010 by Jules Colle: a nerd who’s specialized in WordPress development. He really sucks at design. But if you already have a design, then he might transform it to a website or web application for you.

This website is mostly a place for random thoughts, here are some recent ones:

  • Gutenberg: how to insert a reusable block in the editor with JavaScript
    Accessing core blocks and custom made blocks, is pretty straight forward. For example, if you want to get the paragraph block, you could do so with: And if you want to insert a paragraph, you can easily do so with: There’s even a convenient way to get ALL registered blocks as an array with However, … Read More
  • Gutenberg: how to force sidebar to be always open on post edit screen
    Add this to your functions.php … Read More
  • Gutenberg: custom validation / how to prevent post from being saved
    This script will disable the Publish/Update button: To make the post publishable again, you can do: Very nice. But how is this useful? Here are a couple of use cases. Force users to enter a post title. Let’s say you want to force your users to at least enter a title before they can save … Read More
  • Gutenberg: Prevent specific block from being removable
    Ideally, we should use template_lock as much as we possibly can. But with the problems it introduces currently, and because there might be special use cases that template locking cannot handle, I wanted to explore a way to prevent a specific block from being deletable. If you’re comming from a jQuery background (which is likely … Read More
  • Gutenberg: Problems with template_lock
    In my previous post, I described a way for developers to create a custom user interface for a specific post type. This approach relies heavily on using template_lock=’all’ in combination with templateLock={false} on some of the child blocks. Problem 1: there’s a warning Each published Book that you try to edit, will show this warning … Read More
  • Gutenberg: creating an advanced custom admin user interface for your post types with the block editor using template lock.
    As a freelance developer, I want my clients to have an easy to use interface when creating posts. Before WP 5.0 (and before Gutenberg) I used Advanced Custom Fields a lot for this purpose. An example interface for a Book post, could look something like this: As you can see, I want to add the … Read More
  • Gutenberg: set category with dispatch
    Set the category with id termId and post ID currentPostId: Both termID and currentPostId need to be integers. use parseInt to enforce this if necessary. Custom taxonomy Same thing, just use your custom taxonomy slug instead of ‘category’: Set multiple categories If you want to set categories with term ID’s 24, 45 and 87: … Read More
  • WordPress core development with Xdebug and VS Code
    I had a bit of a struggle to get Xdebug working with wordpress-develop, but the solution turned out to be very simple. So I’m sharing it here for future reference. … Read More
  • Dynamically populate a Contact Form 7 dropdown list (or any other input field)
    With Contact Form 7 the normal way to create a drop down list, looks like this: That’s all very nice, but what if this information tends to change often? You probably have a data source already, be it a web API, an excel sheet, or a simple text file. Wouldn’t it be nice to write … Read More
  • Gutenberg: custom validation
    This is a work in progress. The plan is to list all possible validation patterns for custom blocks. At the point of writing it seems like Gutenberg does not provide an out-of-the-box validation mechanism. https://bdwm.be/gutenberg-how-to-make-post-categories-required/ … Read More
  • Gutenberg: how to make post categories required?
    This is how: So, what’s happening here? First we get all the currently selected categories with: Then we subscribe to any changes in the data store. If we detect a change in the selected catergories, we check the number of selected categories. If the number is zero, we show an error message with: and we … Read More
  • Use react in your wordpress plugins
    Try this: https://github.com/pwkip/wp-simple-react-starter-plugin … Read More
  • setting up PHPUnit for plugin development on Local by Flywheel
    Get local by flywheel Add a new local site Custom install PHP 7.3 nginx Mysql 5.6 WP user: admin WP password: admin Go to WP admin Install and activate the plugin you would like to test SSH into the site and run these commands: apt-get update apt-get install curl apt-get install subversion wget -O phpunit … Read More
  • Xdebug Remote debugging with PHPStorm and Digital Ocean Droplet
    Set up a remote server with PHP and XDebug installed. Because firewalls will be firewalls, we probably will need an SSH tunnel set up to the server in order for XDebug to work. So, better say goodby to “Remote” debugging, or prepare yourself for some serious hair pulling. To set op the SSH tunnel that … Read More
  • How to hide menu items from wordpress admin for your clients
    Just use the Adminimize plugin! If you don’t wanna, here are some functions function remove_menus(){ if (!current_user_can(‘administrator’)) { remove_menu_page( ‘index.php’ ); remove_menu_page( ‘upload.php’ ); remove_menu_page( ‘vc-welcome’ ); remove_menu_page( ‘tools.php’ ); remove_menu_page( ‘edit.php?post_type=vacancy’ ); remove_menu_page( ‘edit.php?post_type=branch’ ); remove_menu_page( ‘edit.php?post_type=person’ ); remove_menu_page( ‘edit.php?post_type=page’ ); remove_menu_page( ‘peak6-general-settings’ ); } } add_action( ‘admin_menu’, ‘remove_menus’, 20 ); add_action( ‘admin_bar_menu’, ‘remove_wp_logo’, … Read More
  • How to create dynamically populated cascading dropdown-lists for Contact Form 7
    Something I had to deal with quite often lately, is creating dynamic drop-down lists in WordPress, like this: As always, I like to use the WordPress plugin Contact Form 7 as a basis for all my form-driven projects. The reason is that Contact Form 7 has a robust validation mechanism. It is very lightweight, yet powerful … Read More
  • WordPress Filterable Admin Columns for Custom Posts
    After reading the great article on Ractoon.com on how to create sortable admin columns for custom posts, I decided I wanted to take things a step further and add a select box to the top of the posts table to filter by a custom field. Here’s the code. I followed the same naming conventions as … Read More
  • HTML5 alternative for nested anchor tags
    HTML 5 standards do not allow nesting of hyperlinks, although there are some valid use cases to allow this. So we need to rely on a work-around like this one for now: HTML <div class=”block”> <a class=”overlay” href=”#overlay-link”></a> <div class=”inner”> This entire box is a hyperlink. (Kind of)<br><br><br><br> <a href=”#inner-link”>I’m a W3C compliant hyperlink inside … Read More
  • Apache very slow on localhost on Windows 10
    Apache was slow, and then I disabled XDebug in PHP.ini, and then apache was fast again. The end. … Read More