This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.addEventListener('om.Campaign.afterShow', function(event) { | |
var campaign = event.detail.Campaign; | |
if ( '{{id}}' !== campaign.id ) { | |
return; | |
} | |
var validationError = 'A last name is required.'; | |
var $nameField = document.getElementById( '{{ns}}-field-name' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Comma-separated list of WordPress user ids allowed access to the OptinMonster pages. | |
define( 'ALLOWED_OM_USERS', '1,2,5' ); | |
// The new capability defined for viewing OM pages. | |
// function for_om_get_allowed_cap() { | |
// return 'optinmonster_allowed'; | |
// } | |
// add_filter( 'optin_monster_api_menu_cap', 'for_om_get_allowed_cap' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('om.Optin.init.submit', function( evt ) { | |
// Only do this for a specific campaign | |
if ( '<slug>' !== evt.detail.Campaign.id ) { | |
return; | |
} | |
// Some meta you want to send along to your webhook or Zapier... | |
var meta = JSON.parse( JSON.stringify( window.location ) ); | |
meta.pizza = 'pepperoni'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('om.DisplayRules.afterRun', function(event) { | |
var DisplayRules = event.detail.DisplayRules; | |
var Campaign = event.detail.Campaign; | |
if ( 'YOUR-CAMPAIGN-ID' === Campaign.id && DisplayRules.show ) { | |
if ( 'pepperoni' !== window.pizza ) { | |
// Only allow rules to pass if pizza variable exists | |
// and it's value is 'pepperoni'. | |
DisplayRules.show = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('om.Html.scripts', function(event) { | |
console.log(event.detail.Html); | |
console.log(event.detail.Campaign); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
document.addEventListener('om.Dtr.init', function(event) { | |
/** | |
* API method for deleting a custom variable. Must be accessed via the Dtr object. | |
* | |
* @param string $key The custom variable to delete. | |
* @return null | |
*/ | |
event.detail.Dtr.deleteCustomVariable('foo'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
document.addEventListener('om.Dtr.init', function(event) { | |
/** | |
* API method for checking whether there are any custom variables set. | |
* Must be accessed via the Dtr object. | |
* | |
* @return bool True if any custom variable has been registered, false otherwise. | |
*/ | |
event.detail.Dtr.hasCustomVariables(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
document.addEventListener('om.Dtr.init', function(event) { | |
/** | |
* API method for checking if a custom variable has been registered. | |
* Must be accessed via the Dtr object. | |
* | |
* @param string $key The custom variable key to check. | |
* @return bool True if the custom variable exists, false otherwise. | |
*/ | |
event.detail.Dtr.hasCustomVariable('foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
document.addEventListener('om.Dtr.init', function(event) { | |
/** | |
* API method for retrieving all custom variables. Must be accessed via the Dtr object. | |
* | |
* @return object A JavaScript object with key/value pairs for custom variables. | |
*/ | |
event.detail.Dtr.getCustomVariables(); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
document.addEventListener('om.Dtr.init', function(event) { | |
/** | |
* API method for retrieving a custom variable. Must be accessed via the app object. | |
* | |
* @param string $key The custom variable key to retrieve. | |
* @return string|bool The value of the custom variable key or false if not found. | |
*/ | |
event.detail.Dtr.getCustomVariable('foo'); | |
}); |