Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Griffin thomasgriffin

View GitHub Profile
@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:984c3e2dfa4b7bc24578
Created Feb 18, 2015
Updates all slides in all sliders and sets the status to active in Soliloquy.
View gist:984c3e2dfa4b7bc24578
<?php
add_action( 'wp_loaded', 'tgm_soliloquy_set_slides_to_published' );
function tgm_soliloquy_set_slides_to_published() {
if ( ! class_exists( 'Soliloquy' ) ) {
return;
}
$sliders = Soliloquy::get_instance()->_get_sliders();
foreach ( (array) $sliders as $slider ) {
View gist:065903820d86889cbe85
<?php // Do not include this opening tag.
add_filter( 'optin_monster_data', 'tgm_om_disable_tracking' );
function tgm_om_disable_tracking( $data ) {
$data['tracked'] = true;
return $data;
}
View gist:afafa8eb35df9192ca60
(function() {
tinymce.create('tinymce.plugins.typekit', {
init: function(ed, url) {
ed.onPreInit.add(function(ed) {
// Get the iframe.
var doc = ed.getDoc();
// Create the script to inject into the header asynchronously.
var typekit = 'xxxxxx', // PLACE YOUR TYPEKIT KIT ID HERE!
jscript = "!function(){var t={kitId:\"" + typekit + "\"},e=!1,a=document.createElement(\"script\");a.src=\"//use.typekit.net/\"+t.kitId+\".js\",a.type=\"text/javascript\",a.async=\"true\",a.onload=a.onreadystatechange=function(){var a=this.readyState;if(!(e||a&&\"complete\"!=a&&\"loaded\"!=a)){e=!0;try{Typekit.load(t)}catch(c){}}};var c=document.getElementsByTagName(\"script\")[0];c.parentNode.insertBefore(a,c)}();";
@thomasgriffin
thomasgriffin / typekit-load.php
Created Dec 27, 2014
Loads the TypeKit plugin into TinyMCE.
View typekit-load.php
<?php // Do not include this opening PHP tag.
add_filter( 'mce_external_plugins', 'tgm_io_typekit_plugin' );
/**
* Adds an external TinyMCE plugin to be loaded into the TinyMCE editor.
*
* @since 1.0.0
*
* @param array $plugins Default array of plugins to be loaded by TinyMCE.
* @return array $plugins Amended array of plugins to be loaded by TinyMCE.
*/
@thomasgriffin
thomasgriffin / typekit.js
Created Dec 27, 2014
Load a TypeKit Font Kit inside of the TinyMCE Visual Editor in WordPress.
View typekit.js
(function() {
tinymce.create('tinymce.plugins.typekit', {
init: function(ed, url) {
ed.onPreInit.add(function(ed) {
// Get the iframe.
var doc = ed.getDoc();
// Create the script to inject into the header asynchronously.
var jscript = "(function() {
var config = {
@thomasgriffin
thomasgriffin / gist:e82ac5bb6d66734b6112
Created Dec 15, 2014
Filter data sent to Mailchimp (send IP address).
View gist:e82ac5bb6d66734b6112
<?php
add_filter( 'optin_monster_pre_optin_mailchimp', 'tgm_om_custom_mailchimp_data', 10, 4 );
/**
* Filter the data sent to Mailchimp.
*
* See here for more info on what is passed: https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php
*
* @param array $data Array of data being sent to Mailchimp.
* @param array $lead Array of lead data captured from the optin submission.
* @param string $list_id The unique list ID to subscribe the lead to.
@thomasgriffin
thomasgriffin / gist:d9653e3abf9ee80d52ac
Created Dec 13, 2014
Change the comment link in WordPress
View gist:d9653e3abf9ee80d52ac
<?php
add_filter( 'get_comments_link', 'tgm_io_change_comment_link', 99 );
/**
* Filters the comment link to have the hash match a different
* comment system, such as Disqus.
*
* @since 1.0.0
*
* @global object $post The current post object.
* @param string $link The default comment link.
@thomasgriffin
thomasgriffin / gist:525dc80a20cb69c7e8bf
Created Dec 11, 2014
Turn off tracking in OptinMonster.
View gist:525dc80a20cb69c7e8bf
<?php
add_filter( 'optin_monster_data', 'tgm_om_turn_off_tracking' );
function tgm_om_turn_off_tracking( $data ) {
$data['tracked'] = true;
return $data;
}
@thomasgriffin
thomasgriffin / gist:971e2ebc33118ea49bdc
Last active Mar 21, 2016
Remove lightbox image sizes generated by OptinMonster.
View gist:971e2ebc33118ea49bdc
<?php
add_filter( 'intermediate_image_sizes', 'tgm_om_filter_image_sizes' );
function tgm_om_filter_image_sizes( $sizes ) {
$om_sizes = array( 'optin-monster-lightbox-theme-balance', 'optin-monster-lightbox-theme-bullseye', 'optin-monster-lightbox-theme-case-study', 'optin-monster-lightbox-theme-clean-slate', 'optin-monster-lightbox-theme-transparent' );
foreach ( $sizes as $i => $size ) {
if ( in_array( $size, $om_sizes ) ) {
unset( $sizes[ $i ] );
}
You can’t perform that action at this time.