Skip to content

Instantly share code, notes, and snippets.

Frankie Jarrett fjarrett

Block or report user

Report or block fjarrett

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
fjarrett / lock-down.php
Last active Oct 28, 2019
Simple must-use plugin to lock down WordPress and keep it up-to-date. Useful for canary sites.
View lock-down.php
* Place this file in `wp-content/mu-plugins/lock-down.php` and it will be automatically loaded by WordPress.
// Auto-update all the things.
add_filter( 'auto_update_core', '__return_true' );
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );
fjarrett / wait-for-php-server-start.php
Created Aug 30, 2019
Use the Requests lib to wait for the built-in PHP server to start up
View wait-for-php-server-start.php
$process = new Process( sprintf( 'php -S localhost:8080 -t %s', __DIR__ ) );
$start = time();
// Wait for the server to start up (5 seconds max).
do {
try {
fjarrett / .profile
Created Aug 10, 2017
Docker <--> Valet
View .profile
# Toggle localhost between Docker and Valet
quitapp () {
command osascript -e 'quit app "'$*'"' &
alias usevalet="quitapp Kitematic && quitapp Docker && valet restart && mysqld &>/dev/null &"
alias usedocker="open -a Docker && valet stop && mysql.server stop && open -a Kitematic"
fjarrett / cdn-baseurl.php
Created Jul 20, 2017
Filter the media uploads baseurl to point to a CDN
View cdn-baseurl.php
// Turn ON: $ wp option update cdn_baseurl
// Turn OFF: $ wp option delete cdn_baseurl
$cdn_baseurl = get_option( 'cdn_baseurl' );
if ( ! $cdn_baseurl ) {
fjarrett /
Last active Jul 14, 2017
Match values of PHP constant definitions by type

The Regex


Purpose: To reference constant values from a PHP file (wp-config.php) that should not be included.
Author: Frankie Jarrett

fjarrett / gist:4ef5890043a80904c542339b1fd1ffb2
Created Jun 6, 2017
List of cache groups used in WordPress core
View gist:4ef5890043a80904c542339b1fd1ffb2
fjarrett /
Created Jun 5, 2017
Bash alias to allow root to run WP-CLI commands as another user
# force `wp` commands to run as the `www-data` user
wp() {
if [ $1 == "cli" ]; then
command wp $* --allow-root
elif [ $(whoami) != "www-data" ]; then
su www-data -c "wp $*"
command wp $*
fjarrett / foo-plugin.php
Last active Apr 28, 2017
Foo Plugin Boilerplate
View foo-plugin.php
* Plugin Name: Foo Plugin
* Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit!
* Version: 1.0.0
* Author: Your Name
* Author URI:
* Text Domain: foo-plugin
* Domain Path: /languages
* License: GPL-2.0
fjarrett /
Last active Jun 12, 2019
How to use a Ceph (or S3) bucket for WordPress uploads

How to use a Ceph (or S3) bucket for WordPress uploads

Listed below are the steps I took to use Ceph object store for WordPress media without a plugin. It works by mounting Ceph (or an AWS S3) bucket as a network device on the file system via s3fs and using wp-content/uploads/ as the mount path.

Since s3fs is POSIX compatible, it means you can still access (and manage) the media within wp-content/uploads/ over SFTP/SSH as if they are natively there.

WP-CLI commands such as wp media import and wp media regenerate also still work.

Although your media is being stored and fetched from a network storage bucket, your web server can still resolve all the requests to wp-content/uploads/ on the local filesystem like normal.

This means that image URLs do not have to be rewritten and will use the core format you're used to over HTTP and any absolute filesystem paths in PHP that may exist `/path/to/wp-content

fjarrett /
Last active Mar 15, 2017
Collection of simple PS1s for bash profiles
# HH:MM:SS [cwd] $
export PS1="\t [\W] \\$ "
# HH:MM:SS [cwd] $ (colorized)
export PS1="\[\e[37m\]\t\[\e[m\] \[\e[36m\][\[\e[m\]\[\e[36m\]\W\[\e[m\]\[\e[36m\]]\[\e[m\] \[\e[32m\]\\$\[\e[m\] "
# user@host [/path/to/cwd] $
export PS1="\u@\h [\w] \\$ "
# user@host [/path/to/cwd] $ (colorized)
You can’t perform that action at this time.