Skip to content

Instantly share code, notes, and snippets.

View fjarrett's full-sized avatar

Frankie Jarrett fjarrett

View GitHub Profile
@fjarrett
fjarrett / wp-bulk-update-themes.sh
Last active September 12, 2015 18:51
Update all themes on every virtual host running WordPress
#!/bin/bash
for DIR in /var/www/*/public_html; do
cd $DIR
if [ -f "wp-config.php" ]; then
echo "cd $DIR"
@fjarrett
fjarrett / wp-bulk-update-core.sh
Last active September 12, 2015 18:51
Update core on every virtual host running WordPress
#!/bin/bash
for DIR in /var/www/*/public_html; do
cd $DIR
if [ -f "wp-config.php" ]; then
echo "cd $DIR"
@fjarrett
fjarrett / site-create.sh
Last active April 24, 2017 22:33
Create a new virtual host in Apache
#!/bin/bash
echo "Enter the domain of the site you want to create:"
read DOMAIN
if [ -d /var/www/$DOMAIN ]; then
echo -e "\x1b[1;31mError:\e[0m $DOMAIN already exists!"
@fjarrett
fjarrett / site-remove.sh
Last active June 7, 2021 09:55
Remove a virtual host from Apache
#!/bin/bash
echo "Enter the domain of the site you want to remove:"
read DOMAIN
if [ ! -d /var/www/$DOMAIN ]; then
echo -e "\x1b[1;31mError:\e[0m $DOMAIN does not exist!"
@fjarrett
fjarrett / pre-commit
Last active November 7, 2015 19:34
Git pre-commit hook for Codeception on VVV
#!/bin/bash
CODECEPTION_CHECK=1
SELF_DIR=$( pwd )
echo "Checking staged changes..."
# Run Codeception tests
if [ "$CODECEPTION_CHECK" == 1 ]; then
if [ -f "$SELF_DIR/codeception.yml" ]; then
@fjarrett
fjarrett / safe_array_replace_recursive.php
Last active April 20, 2017 15:44
Recursively replace elements from passed arrays into the first array (safe for PHP 5.2)
<?php
/**
* Recursively replace elements from passed arrays into the first array (safe for PHP 5.2).
*
* @author Frankie Jarrett <fjarrett@gmail.com>
* @link http://php.net/manual/en/function.array-replace-recursive.php
*
* @param array $array1
* @param array $array2
@fjarrett
fjarrett / load-test-url.sh
Created January 23, 2016 23:22
Basic load testing script
#!/bin/bash
echo -n "Enter a URL to load test: "
read URL
# Ensure the URL has a trailing slash
[[ ${URL:${#URL}-1:1} != "/" ]] && URL="$URL/"; :
echo -n "Number of requests: "
read REQUESTS
@fjarrett
fjarrett / locale.php
Last active February 19, 2016 17:57
Always use English in the WP Admin
<?php
add_action( 'plugins_loaded', function() {
add_filter( 'locale', function( $locale ) {
return is_admin() ? 'en_US' : $locale;
} );
@fjarrett
fjarrett / sample.html
Last active June 13, 2016 16:16
HTML Sample Page Content
<div id="top"></div>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
@fjarrett
fjarrett / unautop-func.php
Last active April 6, 2022 16:57
Inverse behavior to the wpautop() function found in WordPress
<?php
/**
* Replaces paragraph elements with double line-breaks.
*
* This is the inverse behavior of the wpautop() function
* found in WordPress which converts double line-breaks to
* paragraphs. Handy when you want to undo whatever it did.
*
* @see wpautop()