Skip to content

Instantly share code, notes, and snippets.

View fjarrett's full-sized avatar

Frankie Jarrett fjarrett

View GitHub Profile
@fjarrett
fjarrett / home.php
Created July 11, 2013 15:58
Homepage posts potential workaround
<?php
get_template_part( 'archive' );
@fjarrett
fjarrett / gist:7358625
Last active December 27, 2015 16:59
Activate font smoothing for MP6
<?php
/**
* Adds font smoothing to MP6 in the Admin Bar and the entire WP Admin area.
*
* @print HTML
* @action admin_head
* @action wp_head
*/
function fjarrett_mp6_font_smoothing() {
if ( ! is_plugin_active( 'mp6/mp6.php' ) )
@fjarrett
fjarrett / gist:8058052
Created December 20, 2013 17:10
Attempt to resolve IP value database error
<?php
/**
* Log handler
* @param string $message sprintf-ready error message string
* @param array $args sprintf (and extra) arguments to use
* @param int $object_id Target object id
* @param string $action Action performed (stream_action)
* @param int $user_id User responsible for the action
* @param array $contexts Contexts of the action
@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 / plugin_version_sync.sh
Last active July 9, 2016 15:00
Keep a plugin version between two sites in sync.
#!/bin/bash
#
# Keep a plugin version between two sites in sync.
# If one host has a newer version, the other will
# be updated to match.
#
# EXAMPLE
# plugin_version_sync.sh <plugin> <host-1> <host-2>
PLUGIN=$1
@fjarrett
fjarrett / search-css.php
Last active July 29, 2016 22:22
Return an array of CSS selectors that have certain properties.
<?php
/**
* Return an array of CSS selectors that have certain properties.
*
* Example: fjarrett_search_css( 'font-family: "Open Sans"' )
* Result: array( 'h1', 'h2', 'h3', 'h4', 'h5', 'p', 'blockquote' );
*
* @param string $path
* @param string $search
@fjarrett
fjarrett / class-returner.php
Last active December 11, 2016 05:24
Return class for magic WordPress filter callback methods.
<?php
/**
* This class is designed to return a basic value by parsing the dynamic
* static method name you call to determine its type and value.
*
* It's useful for filtering values in WordPress quickly without having
* to create a callback function. Think of this as a continuation of the
* callback helpers already in WordPress: __return_true(), et al.
*
@fjarrett
fjarrett / detect-serialized-data.sql
Last active January 18, 2017 07:57
Detect serialized data with regex in MySQL - https://regex101.com/r/mXyzmI/2
/* Select rows that contain serialized data */
SELECT * FROM `wp_options` WHERE `option_value` RLIKE '(a:[0-9]+:{)|(s:[0-9]+:)|(i:[0-9]+;)|(O:[0-9]+:\")';
/* Select rows that don't contain serialized data */
SELECT * FROM `wp_options` WHERE `option_value` NOT RLIKE '(a:[0-9]+:{)|(s:[0-9]+:)|(i:[0-9]+;)|(O:[0-9]+:\")';