Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created March 27, 2014 12:54
Show Gist options
  • Save thomasgriffin/9806920 to your computer and use it in GitHub Desktop.
Save thomasgriffin/9806920 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($){
$(document).on('click', '.manual-optin-trigger', function(e){
e.preventDefault();
var $this = $(this);
// Ensure that the OptinMonster function exists.
if ( typeof window['OptinMonster'] === 'function' ) {
// Load a different optin based on ID.
if ( 'your-id-here' == $this.attr('id') ) {
// Append our holder to the DOM if it does not already exist.
if ( 0 === $('#om-' + om_manual_object.optin).length )
$('<div id="om-' + om_manual_object.optin + '" />').appendTo('body');
// Load OptinMonster.
var custom_optin_monster = new OptinMonster();
custom_optin_monster.manualInit({
optin: om_manual_object.optin,
ajax: om_manual_object.ajaxurl
});
} else {
// Append our holder to the DOM if it does not already exist.
if ( 0 === $('#om-' + om_manual_object.optin2).length )
$('<div id="om-' + om_manual_object.optin2 + '" />').appendTo('body');
// Load OptinMonster.
var custom_optin_monster = new OptinMonster();
custom_optin_monster.manualInit({
optin: om_manual_object.optin2,
ajax: om_manual_object.ajaxurl
});
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment