Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
Created September 10, 2015 19:35
Show Gist options
  • Save ericakfranz/ed0c0b3ff05247ab7be8 to your computer and use it in GitHub Desktop.
Save ericakfranz/ed0c0b3ff05247ab7be8 to your computer and use it in GitHub Desktop.
Remove all OptinMonster optins on mobile.
<?php
/**
* Plugin Name: OptinMonster - Remove Optins on Mobile Devices
* Plugin URI: http://optinmonster.com/
* Description: Remove all OptinMonster optins from mobile devices using wp_is_mobile();
* Version: 1.0.0
* Author: Erica Franz
* Author URI: https://fatpony.me/
* License: GPL2
*/
defined( 'ABSPATH' ) or die( 'No jellyfish!' );
//* Filter wp_footer
add_action( 'wp_footer', 'ekf_om_remove_optins_mobile' );
//* Remove all optins on mobile
function ekf_om_remove_optins_mobile() {
if( wp_is_mobile() ) {
echo "<script type='text/javascript'>
jQuery(document).ready(function($){
jQuery(document).on('OptinMonsterBeforeShow', function(event, props, object){
jQuery('#om-' + props.optin).remove();
});
});
</script>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment