Kevinleary.net, LLC.

Blog

Sensible approaches to build and maintain custom WordPress websites.

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. Raw HTML This will get the content without any of the built-in WordPress filters that format the output. This…

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.

The Evolution of JavaScript Module Patterns

The evolution of JavaScript module patterns has been a huge headache for web developers. Attempting to work with plugins and libraries that all use different module patterns overly difficult, but once you understand each pattern and how to work with it you can begin to translate and make sense of each. This article should provide…

Export & Import All Databases on a MySQL Server

When I upgrade MySQL I like to start with a backup of all my MySQL databases. I have 50+ databases in my localhost server, so it’s best to bulk export them all to a single .sql file with one command. I need this export to be easy to import back into my MySQL server as…

Using Moment in Angular/TypeScript

Using Moment in a TypeScript Angular app is easier than you think. Here are the steps you’ll need to take to get it setup. Basic Moment Usage Run the following commands inside your Angular CLI project to install Moment and it’s corresponding interfaces. npm i -S moment; npm i -D @types/moment; Once this is done…

Currency Formatting in JavaScript & TypeScript

There’s a simple, native way to format numbers and floats as currency strings in JavaScript. I’ve seen all kinds of approaches to this common scenario. The toLocaleString method is built-in to JavaScript, 100% supported in majority browsers, and requires no external libraries or dependencies. I’d recommend it as the best approach to take if you…

Display HTML in Angular Components

Displaying HTML in an Angular component that’s stored in a template variable isn’t as straightforward as you’d expect. In order to properly store and display an HTML string in a component without issues, you’ll need to take one of two approaches depending on the tags and attributes in the HTML. If you’ve tried displaying HTML…

Quick Fix for WordPress ob_end_flush() Error

From time-to-time I see the following error on your WordPress website, usually at the very bottom of your pages below the footer. ob_end_flush(): failed to send buffer of zlib output compression (1) This happens when your WordPress theme or plugins use output buffering but don’t flush the output properly or, in some cases, when there…

Ionicons in Angular: Web Component Fix

Ionicons 4.x provides a web component that you can use to add an icon with <ion-icon name=”…”></ion-icon>. Using this web component in an Angular app doesn’t work though, and many developers have reported that Ionicons 4 is broken when used with Angular. If you’ve tried to include Ionicons 4 in your Angular CLI project you’ll…

Mac Dock & Multiple Monitors

Unfortunately the native Mac OS X dock can’t be used on multiple displays. You can get it setup so that it’s available on both, but what most people are after (myself included) is a seamless dock that spans two external display monitors reliably. I’ve tried all of the suggested approaches mentioned on the Apple stackexchange…

Loading additional posts…