Skip to content

Instantly share code, notes, and snippets.

View thomasgriffin's full-sized avatar
👋

Thomas Griffin thomasgriffin

👋
View GitHub Profile
@thomasgriffin
thomasgriffin / gist:971e2ebc33118ea49bdc
Last active March 21, 2016 04:14
Remove lightbox image sizes generated by OptinMonster.
<?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 ] );
}
@thomasgriffin
thomasgriffin / gist:5368d5d28da58dd19f73
Last active May 30, 2018 10:57
Prevent Gravity Forms from storing entries on a specific form.
<?php
add_action( 'gform_after_submission_5', 'tgm_io_remove_form_entry' );
/**
* Prevents Gravity Form entries from being stored in the database
* for a specific form. In this case, the form ID is 5. Change 5 in
* the hook to target your specific form ID.
*
* @global object $wpdb The WP database object.
* @param array $entry Array of entry data.
*/
@thomasgriffin
thomasgriffin / gist:891c405de8b6475a6772
Created November 21, 2014 20:16
Redirect any non-business email addresses to a custom page.
add_action( 'wp_footer', 'tgm_om_force_specific_email_address', 999 );
function tgm_om_force_specific_email_address() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$(document).on('OptinMonsterBeforeOptin', function(e, data){
// Grab the email address submitted by the user.
var email = $('#om-' + data.optin).find('input[type="email"]').val();
@thomasgriffin
thomasgriffin / gist:fadfec5c1d13a0f6c531
Created October 29, 2014 19:01
Prevent email addresses from being added to Pardot if they end with certain domain names.
<?php
add_filter( 'optin_monster_pre_optin_pardot', 'tgm_om_block_specific_email_domains' );
function tgm_om_block_specific_domains( $data ) {
// If no email passed, return.
if ( empty( $data['email'] ) ) {
return $data;
}
// Check for specific email domains. If there is a match, set email to false to prevent from sending to Pardot.
@thomasgriffin
thomasgriffin / gist:62689c45fa4bf7b6cb31
Created October 29, 2014 18:47
Custom action hook for custom conversion tracking in Canvas in OptinMonster.
<?php
add_action( 'optin_monster_ajax_action', 'tgm_om_custom_tracker', 10, 2 );
function tgm_om_custom_tracker( $action, $data ) {
// If not our action, do nothing.
if ( 'track_optinmonster_custom' !== $action ) {
return;
}
// If our ID is not passed, do nothing.
@thomasgriffin
thomasgriffin / gist:3065685c64c023c748f1
Created October 29, 2014 18:46
Do custom conversion tracking for canvas in OptinMonster.
jQuery(document).ready(function($){
$(document).on('click', '.optin-monster-overlay .livechat_button a', function(e){
// Prepare variables.
var $this = $(this),
optin = $this.closest('.optin-monster-overlay').attr('id').replace('om-', '').replace('-', '_');
if ( ! window[optin] ) {
return;
}
// Send ajax request to track the optin.
{
id: 'my-template',
seo: {
},
integrations: {
[
],
[
@thomasgriffin
thomasgriffin / gist:3fc79ee983329bd6c528
Last active February 13, 2017 19:05
Prevent Gravity Forms from storing entries in the database.
<?php
add_action( 'gform_after_submission', 'tgm_io_remove_form_entry' );
/**
* Prevents Gravity Form entries from being stored in the database.
*
* @global object $wpdb The WP database object.
* @param array $entry Array of entry data.
*/
function tgm_io_remove_form_entry( $entry ) {
@thomasgriffin
thomasgriffin / gist:9a70130f00d5be84245f
Created October 27, 2014 12:33
Hide the license key from OptinMonster settings area.
<?php
add_action( 'optin_monster_admin_styles', 'tgm_om_hide_license_key_fields' );
function tgm_om_hide_license_key_fields( $view ) {
if ( 'overview' !== $view ) {
return;
}
?>
<style type="text/css">#optin-monster-settings-key-box, #optin-monster-settings-key-type-box { display: none; }</style>
@thomasgriffin
thomasgriffin / gist:2448165e856ff79db829
Created October 25, 2014 19:40
Protected content for OptinMonster. This is an example template (taken from twenty fourteen) that checks to see if the lead passed is stored in the local lead storage before showing content.
<?php
/**
* Template Name: Protected Content
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
get_header(); ?>