Author: Matt Watson

  • Array Chunk

    Using array chunk (array_chunk) we can easily split an array into a multidimensional array (an array of arrays). The array chunk function could be used to break an array into smaller parts, perhaps to make it easier to process. Basic Example Assuming we setup an array as per the below code example ($array on line…

  • A question can be a very powerful thing! Take this one for instance: “Anyone in #barnsley got a building going free for an #umbraco mashup day?” Matt Watson What is so special about that question? Well, that was a very innocent tweet I sent in November 2011 that set off a chain of events that…

  • Sometimes when writing a block of text using the WordPress editor, you need it to look a certain way, we usually do this by adding styles to pieces of text, but we don’t always want our clients to have to open up the text editor and do this manually. In this example we will create…

  • If you are developing a WordPress theme or plugin then it is important to make it as secure and robust as possible. One way to do this is to properly escape values that you use in your project so that XSS (Cross-Site-Scripting) is prevented. An example of a XSS attack may be that you have…

  • I had an interesting job land on my desk today. A customer wanted to change a text string within a third party plugin, however there was no settings or filters to alter the string. The string however was translatable via WordPresses own internationalisation (i18n) api, and was written in the following format. esc_html_e( ‘String to…

  • We have taken a look at custom block sidebars, third party block sidebars via InspectorControls, and how to add controls to the post sidebar. In this guide we are going to look at putting our controls in their very own custom sidebar. Our Custom Sidebar The screenshot above shows what we are going to build.…

  • So far we have taken a look at the block sidebar by adding InspectorControls to our custom blocks and adding controls to core and third party block sidebar with filters and Higher Order Components. In this guide we are going to look at adding controls to the post sidebar. Display Settings in the Post Sidebar…

  • Are you writing a lot of WordPress block editor (Gutenberg) blocks for just one client? Wouldnt it be good to just group them all together? Simple, just create a custom block category. In the PHP of your plugin just add the following: This will register a custom block category in your block inserter. Adjust the…

  • Have you ever noticed how some plugins have one or more custom links on the WordPress Plugin screen? To be honest if I cannot find the settings for the plugin this is the first place I look: Settings Link on Plugin Settings Page Panel If you want to add your own custom link to the…

  • Did you know that you can create Customizer Sections and Panels in JavaScript? Did you know that you can also register Customizer Settings and Controls in JavaScript too? You can do all that and more, with code similar to the following: Note that in our text control we have used the setting wholesomecode_wholesome_plugin_example_text, unfortunately we…