Skip to content

Instantly share code, notes, and snippets.

😎
Awesome Motive-ing

Justin Sternberg jtsternberg

😎
Awesome Motive-ing
Block or report user

Report or block jtsternberg

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
@jtsternberg
jtsternberg / wpforms-to-optin-monster.php
Last active Dec 5, 2019
Automatically trigger an OptinMonster form to show, filled out, when an WP Form is submitted.
View wpforms-to-optin-monster.php
<?php
/*
* Plugin Name: WP Forms to OptinMonster
* Plugin URI: http://optinmonster.com
* Description: Automatically trigger an OptinMonster form to show, filled out, when an WP Form is submitted.
* Version: 0.1.0
* Author: Justin Sternberg
* Author URI: http://optinmonster.com
*/
@jtsternberg
jtsternberg / om-image-data-attribute.html
Created Dec 2, 2019
Add pinterest no-pin data attribute to OptinMonster-loaded images
View om-image-data-attribute.html
<script type="text/javascript">
document.addEventListener('om.Campaign.load', function(event) {
var slug = event.detail.Campaign.id;
var images = document.querySelectorAll('#om-' + slug + ' img');
if ( images ) {
images.forEach(function(el) {
el.setAttribute('data-pin-nopin', true);
});
}
});
@jtsternberg
jtsternberg / cmb2-register-reset-field.php
Last active Nov 11, 2019
replace CMB2 register_rest_field handlers with our own
View cmb2-register-reset-field.php
<?php
/**
* Registers a new post type
* @uses $wp_post_types Inserts new post type object into the list
*
* @param string Post type key, must not exceed 20 characters
* @param array|string See optional args description above.
* @return object|WP_Error the registered post type object, or an error object
*/
@jtsternberg
jtsternberg / filter-om-campaigns-by-name.php
Last active Mar 14, 2019
Filter OptinMonster campaigns loaded into WordPress by name
View filter-om-campaigns-by-name.php
<?php
function filter_om_campaigns_by_name( $campaigns, $save ) {
// Make sure this is the refresh request and that we have data.
if ( ! isset( $campaigns->success ) && ! empty( $campaigns ) ) {
// Loop through the campaigns
foreach ( (array) $campaigns as $slug => $campaign ) {
@jtsternberg
jtsternberg / am-ascii.html
Last active Feb 4, 2019
AwesomeMotive ascii
View am-ascii.html
<pre>
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
````````````````````````````````````````````````````````````````````````````````````````````````````
@jtsternberg
jtsternberg / om-webhook-arbitrary-data.html
Created Jan 16, 2019
send arbitrary to the webhook via the debugInfo field
View om-webhook-arbitrary-data.html
<script>
document.addEventListener('om.Form.init', function( evt ) {
var { Campaign } = evt.detail;
var input;
// Only do this for a specific campaign
if ( '<slug>' !== Campaign.id ) {
return;
}
@jtsternberg
jtsternberg / add-x++-language-to-cpt-plugin.php
Created Jan 16, 2019
Add additional languages to code-snippet-cpt plugin
View add-x++-language-to-cpt-plugin.php
<?php
add_action( 'admin_init', function() {
$exists = get_term_by( 'slug', 'xpp', $taxonomy );
if ( empty( $exists ) ) {
$result = wp_insert_term( 'X++', 'languages', array( 'slug' => 'xpp' ) );
wp_die( '<xmp>'. __LINE__ .') $result: '. print_r( $result, true ) .'</xmp>', 'Debug' );
}
wp_die( '<xmp>'. __LINE__ .') $exists: '. print_r( $exists, true ) .'</xmp>', 'Debug' );
} );
@jtsternberg
jtsternberg / meh-rathon-countdown-alarm.js
Last active Apr 1, 2019
meh.com meh-RATHON! countdown alarm
View meh-rathon-countdown-alarm.js
clear();
var cdSettings = {
debug: true,
evt: null,
audio: null,
audioUrl: 'https://jtsternberg.com/file-drop/analog-watch-alarm_daniel-simion.mp3',
secondsLeft: 0,
timeLeft: 0,
log: true,
alarming: false,
@jtsternberg
jtsternberg / om-redirect-with-existing-query-args.js
Created Nov 21, 2018
On OM redirect action, append any existing query args to the redirect url
View om-redirect-with-existing-query-args.js
document.addEventListener('om.Action.redirect', function(evt) {
var action = evt.detail.Action;
// Take existing url and append any query args on current url.
action.options.url += ( action.options.url.indexOf('?') > -1 ? '&' : '?' ) + window.location.search.substr(1);
});
@jtsternberg
jtsternberg / om.Analytics.track-example.js
Last active Nov 15, 2018 — forked from brianaohern/om-Analytics-conversion-example.js
om.Analytics.track Example using Google Tag Manager to track a specific event in our Google Analytics account.
View om.Analytics.track-example.js
document.addEventListener('om.Analytics.track', function(event) {
if ( 'conversion' === event.detail.Analytics.type ) {
dataLayer.push({
'event': 'gaTriggerEvent',
'gaEventCategory': 'form',
'gaEventAction': 'submit',
'gaEventLabel': 'optin-monster'
});
}
} );
You can’t perform that action at this time.