Skip to content

Instantly share code, notes, and snippets.

@oliwa
Created November 17, 2016 12:19
Show Gist options
  • Save oliwa/36b4c8720b541a6f09516b49e60c2a2d to your computer and use it in GitHub Desktop.
Save oliwa/36b4c8720b541a6f09516b49e60c2a2d to your computer and use it in GitHub Desktop.
Magnific Popupwith delayed opening, Cookie to switch off
<div id="advertisement" class="mfp-hide">
<div class="wrap group text-center">
<img src="http://placehold.it/800x600"/>
<p><a href="javascript:;" id="closeAd" class="button"><i class="fa fa-close"></i> Nicht mehr anzeigen</a></p>
</div>
</div>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.cookie.js"></script>
<script>
$(document).ready(function () {
if ($.cookie('doNotShowAd'))
//alert('Cookie gesetzt, kein Popup');
console.log('Cookie gesetzt, kein Popup');
else {
setTimeout(function() {
if ($('#advertisement').length) {
$.magnificPopup.open({
items: {
src: '#advertisement'
},
type: 'inline',
closeBtnInside: false,
});
}
}, 5000);
}
$("#closeAd").click(function() {
$.magnificPopup.close();
$.cookie('doNotShowAd', true);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment