Recently I was talking to another developer about how to detect ‘WP_DEBUG’ being set on a WordPress installation. Here is the code I use.
WordPress Gutenberg import versus Destructuring Global wp
WordPress Gutenberg Functional Component useState
When creating a block for the WordPress block editor (a.k.a. Gutenberg), I find that most of the documentation is for class components. However, with React hooks we can use functional components. When you need to import ‘useState’ from React, you can do it as follows in a WordPress block.
WordPress and SQL Injection
An SQL injection vulnerability occurs when you use a variable in your SQL statement and someone uses the variable to add unexpected code. In this article, we’ll look at how this occurs and how to prevent it.
WordPress REST API call to Update Post Status Fails Silently
Recently, I was trying to update the post status of a post from ‘future’ to ‘publish’ publish` with the WordPress REST API and while the submission appeared to work, the value was not modified.
MySQL Query for Multiple Strings with LIKE
I recently learned that doing a MySQL “LIKE” with multiple strings separated with ‘%’ behaves the same as multiple “LIKE” statements.
Test WordPress REST API Endpoints from the Browser with jQuery
You can make WordPress REST API calls from the browser console. Here is one way I work with WordPress REST API endpoints in the browser using jQuery.
PHP require vs include
The behaviors of “require”, “include”, “require_once”, and “include_once” in PHP are all very similar with some slight differences. Here is the table highlighting the different behaviors of these statements.
Create WordPress Child Theme
You can quickly create a WordPress child theme by creating a new theme directory and adding two files: style.css and functions.php.
What does declare(strict_types=1); do in PHP? PHP is a weakly typed language, which means that when a value is of the wrong type, PHP tries to cast it to the proper type. For example if you try to add an integer and a string, echo 5 + “3”; PHP will try to cast the string […]