Skip to content

Instantly share code, notes, and snippets.

Matt Radford mattradford

Block or report user

Report or block mattradford

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
mattradford / yoast_social_accounts.php
Last active Jun 20, 2019
Output Yoast Social links
View yoast_social_accounts.php
* Return a nav element populated with Yoast social accounts
function yoast_social_accounts()
if ($social_accounts = get_option('wpseo_social')) {
$fb_url = $social_accounts['facebook_site'];
$twitter_account = $social_accounts['twitter_site'];
$youtube_url = $social_accounts['youtube_url'];
mattradford /
Last active Oct 23, 2018 — forked from hanigamal/
WordPress Commandline Local Install
# WP Commandline Local Install, by Brian Richards (@rzen)
# Creates a new directory, downloads WordPress, creates a database, sets up wp-config,
# optionally empties wp-content, and deletes other misc files. This compliments my local
# dev setup, outlined here:
# Credit:
# Based on WPBuildr ( Props to Aaron Holbrook
mattradford / restrict_acf_menu.php
Created Jun 11, 2018
Restrict ACF menu visibility based on the user's email domain
View restrict_acf_menu.php
* Restrict ACF Custom Fields menu to domains only
function td_acf_hide_admin() {
$current_user = wp_get_current_user();
$domain = substr(
mattradford / yoast-primary-category-menu-item.php
Created Jun 4, 2018
Highlight menu item based on Yoast Primary Category
View yoast-primary-category-menu-item.php
* Highlight menu item based on Yoast Primary Category
function td_yoast_primary_category_nav_class( $classes, $item ) {
if ( is_single() ) {
global $post;
if ( $primary_category = get_post_meta($post->ID,'_yoast_wpseo_primary_category',true) ) {
$primary_category_term = get_term_by( 'id', $primary_category, 'category' );
$menu_locations = get_nav_menu_locations();
if ( has_term($menu_locations['primary_navigation'], 'nav_menu', $item) ) {
mattradford /
Created Apr 27, 2018
Pull a WP Engine install via SSH. File and DB.
    # Pull an install's files and DB from WP Engine
    # Variables
    #User input
    read -p 'Repo to clone (blank if none): ' repo
    read -p 'Install to pull: ' install
    read -r -p 'Include uploads? (y/N) ' response
    read -p 'Local MySQL port: ' port
mattradford /
Last active Apr 24, 2018
Programatically flush a WP Engine object cache
# Programatically flush a WPE cache
# Requires
# Set private key in $private_key
# @params install
# @params private_key
# @returns HTTP status code
# Variables
mattradford / FacetWP set n selected
Last active Apr 21, 2018
Set the number of choices selected at which "{n} selected" will display. is_tax conditional left as an example.
View FacetWP set n selected
* Set {n} selected text to show after 1 selection, on all facets
function td_facetwp_selected() {
if ( is_tax() ) {
(function($) {
$(function() {
if ('undefined' !== typeof FWP) {
mattradford / fSelect-numDisplayed
Created Mar 15, 2018
Change FacetWP fSelect number of choices at which text changes to "{n} selected"
View fSelect-numDisplayed
add_filter( 'facetwp_render_output', function( $output ) {
$output['settings']['location']['numDisplayed'] = 1;
return $output;
View exodus-list
# List of trackers for DNS blocking
# Taken from and a4.tl2
mattradford / ajax-handler-wp.php
Last active Oct 31, 2017 — forked from pixeline/ajax-handler-wp.php
Custom ajax handler for Wordpress. Using admin-ajax.php does not allow the use of plugin shortcodes. Using a custom ajax handler like this bypasses that.
View ajax-handler-wp.php
WORDPRESS SPECIFIC AJAX HANDLER (because admin-ajax.php does not render plugin shortcodes).
credits: Raz Ohad
//mimic the actual admin-ajax
define('DOING_AJAX', true);
if (!isset( $_REQUEST['action']))
You can’t perform that action at this time.