Skip to content

Instantly share code, notes, and snippets.

Thomas Griffin thomasgriffin

Block or report user

Report or block thomasgriffin

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
View gist:3504420
<?php
add_filter( 'gform_ajax_spinner_url', 'tgm_io_custom_gforms_spinner' );
/**
* Changes the default Gravity Forms AJAX spinner.
*
* @since 1.0.0
*
* @param string $src The default spinner URL.
* @return string $src The new spinner URL.
*/
View gist:4253190
<?php
add_filter( 'wp_nav_menu_objects', 'tgm_filter_menu_class' );
/**
* Filters the first and last nav menu objects in your menus
* to add custom classes.
*
* @since 1.0.0
*
* @param object $objects An array of nav menu objects.
* @return object $objects Amended array of nav menu objects with new class.
@thomasgriffin
thomasgriffin / api-helper.php
Last active Mar 13, 2019
API Helper to be used during API requests. Should be used as a must-use plugin in WordPress.
View api-helper.php
<?php
/**
* Plugin Name: TGM API Helper
* Plugin URI: https://thomasgriffin.io
* Description: Whitelists the plugins to be loaded during API requests to reduce overhead.
* Author: Thomas Griffin
* Author URI: https://thomasgriffin.io
* Version: 1.0.0
*/
@thomasgriffin
thomasgriffin / gist:4159035
Last active Feb 8, 2019
Add custom post types to search results in WordPress.
View gist:4159035
<?php
add_filter( 'pre_get_posts', 'tgm_io_cpt_search' );
/**
* This function modifies the main WordPress query to include an array of
* post types instead of the default 'post' post type.
*
* @param object $query The original query.
* @return object $query The amended query.
*/
function tgm_io_cpt_search( $query ) {
@thomasgriffin
thomasgriffin / gist:4733283
Created Feb 7, 2013
Map subdomains to URLs in nginx with WordPress.
View gist:4733283
server {
listen 80;
listen 443 ssl;
server_name ~^(?<user>[a-zA-Z0-9-]+)\.example\.com$;
location / {
resolver 8.8.8.8;
rewrite ^([^.]*[^/])$ $1/ permanent;
proxy_pass_header Set-Cookie;
proxy_pass $scheme://example.com/user/$user$request_uri;
View gist:42f4b2acce8a5eb56a3c94c68f2c23dc
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '532160876956612',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.2'
});
};
View gist:4262025
<?php
add_filter( 'jpeg_quality', 'tgm_image_full_quality' );
add_filter( 'wp_editor_set_quality', 'tgm_image_full_quality' );
/**
* Filters the image quality for thumbnails to be at the highest ratio possible.
*
* Supports the new 'wp_editor_set_quality' filter added in WP 3.5.
*
* @since 1.0.0
*
View gist:3789164
<?php
// If plugins_api isn't available, load the file that holds the function.
if ( ! function_exists( 'plugins_api' ) ) {
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
}
// Prepare our query.
$api = plugins_api( 'query_plugins',
array(
'user' => 'griffinjt'
@thomasgriffin
thomasgriffin / variablefunctioncallback.js
Last active Aug 28, 2018
OptinMonster Dynamic Replacement API - variable function callback example.
View variablefunctioncallback.js
<script type="text/javascript">
var OptinMonsterCustomVariables = function(app) {
app.setCustomVariable('name', 'Thomas');
};
</script>
@thomasgriffin
thomasgriffin / customvariablefunction.js
Created Dec 9, 2015
OptinMonster Dynamic Replacement API - function callback example.
View customvariablefunction.js
<script type="text/javascript">
function OptinMonsterCustomVariables(app) {
app.setCustomVariable('name', 'Thomas');
}
</script>
You can’t perform that action at this time.