Kevinleary.net, LLC.

Blog

Sensible approaches to build and maintain custom WordPress websites.

Custom Events in Google Tag Manager

Tracking custom analytics events provide a business with the ability to track specific customer actions online that are most valuable, rather than what an analytics platform prescribes as the most valuable. Implementing custom events in various systems can quickly become complex, so it’s a good idea to use a system like Google Tag Manager to…

Repairing Crashed Database Tables in WordPress

3 ways to fix a common WordPress database error: “Table is marked as crashed and should be repaired”. The choices involve using SQL, PHPMyAdmin, or PHP code.

Social Security Number Validation Rules (Regex)

If you’re building a web application or custom WordPress plugin that needs to validate a US Social Security Number (SSN) then the following approach will provide a way to validate user input without the use of any third-party verification API.

SVG Support & Broken Images

If your WordPress website has broken or missing SVG images and you have the SVG Support plugin installed your issue can be quickly solve with the following quick fix.

A Better Email Address Regular Expression

Over the years I’ve found that this regular expression provides just the right balance of loose and strict pattern recognition to safely be used as a method for validation an email address.

Google Fonts in Gutenberg Editor Styles

If you’re having trouble replacing the font-family for the block editor in WordPress, this undocumented alternative approach should provide a frustration free alternative. The standard approach that uses the add_editor_style function won’t support the loading of external assets in CSS with the @import rule.

JS Fix for “SyntaxError: Cannot use import statement outside a module”

“SyntaxError: Cannot use import statement outside a module” is a common Node.js error when working with `import` to include modules or packages.

Tracking Changes in WordPress

Track, log and notify team members when changes are made to a WordPress website’s file system, database and DNS.

Select Placeholder Color CSS

The select HTML tag doesn’t support a placeholder attribute like an input tag, and when it comes to the CSS color attribute it doesn’t leave many options for style. There are a few ways to provide a select dropdown with a placeholder that can have it’s color CSS styled similar to a ::placeholder pseudo element.

Update an ACF Repeater Field Programmatically

To update a repeater field created with Advanced Custom Fields programmatically you’ll need to use the update_field() function. Populating Untouched/Unsaved Repeater Fields The following approach will pre-populate an ACF field using the $rows array. The field ID provided in this example is repeat-field-id, replace this with your field ID when you programmatically update the field.…

Get WordPress Post Content by Post ID

If you’re wondering how to get WordPress post content by post ID then look no further. The following simple approaches will explain the best approaches to use, and when to choose between unfiltered or filtered content.

Create WordPress Admin User with PHP

How to login to WordPress website with only FTP access by creating a new administrator user with programmatically with PHP.

List Every Action & Filter Hook in WordPress

Adding custom functionality to WordPress for business themes and plugins always involves working with action and filter hooks. This is WordPress’ event architecture, and it’s a core reason why it’s so extensible. The action hooks and filters changes from install to install, because most plugins provide a set of custom filters and hooks for developers…

Fixing WordPress cURL Errors

WordPress uses a single class for all remote HTTP requests, WP_Http. This class uses cURL to handle these requests, and quite often I see developers encountering issues with localhost requests and self-signed certificates, especially if you’re using your own local certificate authority to sign your local development certificates. I use mkcert to do this myself,…

jQuery Select Dropdowns: Common Patterns

jQuery snippets for working with dropdown options: selecting an option by its text label, getting the label for a currently selected option, selecting an option programmatically and more.