Puddinq.com sharing knowledge

Format bytes

Format bytes

Regex cheatsheet

Links testing (link) negative lookbehind Find space not precede bij \ Dynamically replace countries with code

Using isset() empty() and is_null()

Validating the input is very important, but you want te write lean code. So if you are in doubt about using !empty only, or !empty && isset here’s the difference: Value of variable ($var) isset($var) empty($var) is_null($var) “” (an empty string) bool(true) bool(true) bool(false) ” ” (space) bool(true) bool(false) bool(false) FALSE bool(true) bool(true) bool(false) TRUE […]

How can you allow editors to clear (manage) the WP Rocket cache

First of, you should look at the official documentation customize-access WP Rocket. This article uses the same technique but adds a trick. When you use the init hook, the function runs every time the hook fires. To reduce this, we have added an option and before we run the full function we check if that […]

WooCommerce add attribute to multiple products (programmatically)

This snippets was used in winkel-centrum.nl, I needed to adjust an import and add colors found in the title as attributes. I had imported the products and wanted to extract a word from the title to add as attribute in the product. I used a shortcode because I wanted to visualize the products I was […]

Insert extra link in yoast breadcrumb

There are a few filters in WordPress to give you the oppertunity to change an aspect, but the variable is an array the has a cetrain order. Yoast breadcrums is a filter like that. If you want to add an extra link to the main blog at the second position it is not as simple […]

PHP use a function in HereDoc

Heredocs are amazing ( under the right circumstances ), using ling strings with variables without endless echo’s or quotes and line endings. But using functions is a bit less convenient. I found the following made it work for me. (example uses the wordpress translation function)

Php 7.3.11 and MySql 8.0.18 on WAMP

Following an earlier post how to update your wamp stack to Php 7.2, we update the tip and point out Php 7.3.11 and MySql 8.0.18 are available on Wamp. get your updates Awaiting Php 7.4 coming november 2019 we are excited.. If Php 7.4 is available it will be with at the same page get your […]

load_plugin_textdomain is not working, how to debug

Loading the textdomain for a custom plugin can feel like a nightmare. It either works, or you are endlessly trying to alter it untill it workd. wp_debug is no help and there you feel you do not have any way to debug it. Untill now: load_plugin_textdomain does return true or false and if it is […]