Author Archives: Patrick McGoohan

Updating a fork to the master branch on GitHub

GitHub makes it very simple to fork — or create a personal copy of — a public repository. While I could easily star a repository I found interesting (or watch it), I tend to fork instead, thinking, somewhat optimistically, that I’m going to dig in and immediately start contributing. As the saying goes, “l’enfer est […]

Cloning a repository with submodules

A submodule is a repository dependency. This means that while it’s needed for a given repository, it isn’t part of that repository, having instead a separate repository of its very own. This subtle nuance can present itself in the form of a particularly opaque problem when cloning a project with submodules. Let’s say you’re cloning […]

Associating a username with a repository

When working with a private repository, GitHub will force you to provide a username and password (or personal access token if two-step authentication has been configured) every time you want to do anything that affects the repository (e.g. clone, pull, push, fetch). If you associate a specific username with the repository (from a user authorized […]

How to avoid a 403 Forbidden error when cloning a private repository

Sometimes when I’m trying to clone a private repository to a remote host, I get a 403 Forbidden error, like so: git clone https://github.com/repos_username/repos_name.git Initialized empty Git repository in /home/public_html/.git/ error: The requested URL returned error: 403 Forbidden while accessing https://github.com/repos_username/repos_name.git/info/refs fatal: HTTP request failed No prompt for a username and password, just the door […]

Hardcoding a default theme

To preset a custom theme as the default for a WordPress project, copy it into wp-content/themes/, then add this line to the wp-config.php file, replacing ‘theme-name’ with the name of the new default: define(‘WP_DEFAULT_THEME’, ‘theme-name’);

REM to Pixels calculator

Few are the occasions when I’ve needed to convert pixels to REM, usually only when I’m working with a child theme based on one of the default WordPress themes (like Twenty Sixteen). Even fewer are the occasions when I’ve needed to reverse the sausage crank and convert REM back to pixels. And yet, it was […]

Installing and using Composer

Composer is a dependency-management tool for PHP. It installs and keeps current all library dependencies for a given project. It does so recursively, so not only does it manage all direct dependencies but any dependencies those dependencies have, and so on, and so forth, ad infinitum, ad nauseum. It’s becoming more popular as an installation […]

Installing WordPress in its own subdirectory

There are occasions when I prefer to house WordPress in its own subdirectory, such as when I’m using it as the core CMS but building auxiliary functionality alongside it with something like CakePHP. Note: If you’re planning on using version control with your project, I’ve outlined a slightly different method for installing WordPress in a […]

Validating empty fields

Validating an optional field is a snap with CakePHP’s allowEmpty. But what if the field is only optional sometimes and under certain circumstances? A custom validation method, right? Well, actually no. See, if a field is optional (or, more accurately, ‘allowEmpty’ => true) then CakePHP will ignore any validation method, custom or otherwise. As it […]

Creating a custom validation method

CakePHP offers a lot of handy built-in validation methods for common field types, such as email addresses, dates, even credit card numbers. If you can’t find what you need among these methods and your needs are pretty straightforward, you can write a custom regular expression. If your needs are a little more complicated, you can […]