Last active
November 17, 2016 21:38
-
-
Save bytefade/c1a6b686e094df8049841ede329e914e to your computer and use it in GitHub Desktop.
Ativar popup usando wordpress e magnifig popup
This file contains hidden or 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
<!-- Ativar popup --> | |
<script type="text/javascript"> | |
<?php global $wp, $post; | |
$current_url = home_url(add_query_arg(array(),$wp->request)); | |
// $current_url = home_url(); | |
$meta_popup = get_post_meta($post->ID, 'popupsite', true); | |
?> | |
//sim: liga popup nao ou '' desliga popup | |
popup('<?php echo $current_url; ?>', '<?php echo $meta_popup; ?>', '<?php echo is_front_page() ?>'); | |
</script> |
This file contains hidden or 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
// MagnificPopupv1.1.0.js | |
function popup(url, start, front_page_wp){ | |
if (start == 'sim') { | |
(function($) { | |
$.magnificPopup.open({ | |
items: { | |
src: '#modal-promo' | |
}, | |
type: 'inline', | |
preloader: false, | |
modal: true, | |
enableEscapeKey: false | |
}); | |
$(document).on('click', '.popup-modal-dismiss', function (e) { | |
e.preventDefault(); | |
$.magnificPopup.close(); | |
}); | |
$(document).on('click', '.popup-modal-participar', function (e) { | |
e.preventDefault(); | |
$.magnificPopup.close(); | |
$( 'html, body' ).stop().animate({scrollTop: $("#vaga").offset().top}, 2000); | |
}); | |
})(jQuery); | |
} | |
} |
This file contains hidden or 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
<!-- modal/popup html --> | |
<div id="modal-promo" class="white-popup mfp-hide""> | |
<img src="<?php echo get_template_directory_uri(); ?>/images/promo-inscricao-50.png" alt="Promoção 50% de desconto"> | |
<p><a class="btn btn-danger popup-modal-participar" href="#">Quero concorrer aos 50%</a> | |
<a class="btn btn-secondary popup-modal-dismiss" href="#">Não, já participo</a> | |
</p> | |
</div> | |
<!-- modal/popup html --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment