Skip to content

Instantly share code, notes, and snippets.

@kwcjr
Last active January 29, 2022 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwcjr/a20830ae870d311bc0129e75b2758c61 to your computer and use it in GitHub Desktop.
Save kwcjr/a20830ae870d311bc0129e75b2758c61 to your computer and use it in GitHub Desktop.
Load custom Divi popup scripts.
/**
* Load custom Divi popup scripts.
* @source https://divihacks.com/how-to-create-a-popup-in-divi-without-a-plugin/
*/
function uniqueID_content_after_body_open_tag() {
?>
<script type="text/javascript">jQuery(document).ready(function(t){t('div:not(.et_mobile_menu) .lightbox-content, div:not(.et_mobile_menu) [class*="lightbox-content-"]').addClass("mfp-hide"),t("div:not(.et_mobile_menu) .lightbox-trigger").magnificPopup({items:{src:"div:not(.et_mobile_menu) .lightbox-content",type:"inline"}}),t('div:not(.et_mobile_menu) [class*="lightbox-trigger-"]').each(function(){var i=".lightbox-content-"+Array.prototype.find.call(this.classList,function(t){return t.indexOf("lightbox-trigger-")>-1}).split("lightbox-trigger-")[1];t(this).magnificPopup({items:{src:i,type:"inline"}})}),t(this).click(function(){t(".mfp-wrap").attr("id","et-boc")}),t('[class*="lightbox-content"]').prepend('<div class="lightbox-overlay"></div>')});</script>
<script src="/wp-content/themes/Divi/includes/builder/feature/dynamic-assets/assets/js/magnific-popup.js" async></script>
<link rel="stylesheet" href="wp-content/themes/Divi/includes/builder/styles/magnific_popup.css">
<style>
/****** Lightbox Styling *******/
[class*="lightbox-trigger-"] {cursor:pointer;}
[class*="lightbox-content-"] {position:relative; z-index: unset !important;}
[class*="lightbox-content-"] .mfp-close {color:#999999 !important;}
[class*="lightbox-content-"] .mfp-close:active {top:0px !important;}
</style>
<?php
}
add_action('wp_body_open', 'uniqueID_content_after_body_open_tag');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment