Magnific Popup

Examples using this library to implement and use custom-coded popups (a library that comes within the theme and is lazy loaded)

// Document ready.
jQuery(function ($) {
// Load magnific popup library.
$.loadMagnificPopup().then(() => {
// Initialise and open popup.
$.magnificPopup.open({
items: {
src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
},
type: 'iframe'
})
})
})
view raw main.js hosted with ❤ by GitHub
// Document ready.
jQuery(function ($) {
// Initialise and open popup if clicked on element with class open-popup.
$('.open-popup').lazyMagnificPopup({
items: {
src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
},
type: 'iframe'
})
})
view raw main.js hosted with ❤ by GitHub

Ensure that dependencies are correct when enqueuing a script array( 'jquery', 'flatsome-js' ) with wp_enqueue_script or wp_register_script

<?php
add_action( 'wp_enqueue_scripts', function () {
wp_register_script(
'child-main-js',
get_stylesheet_directory_uri() . '/main.js',
array( 'jquery', 'flatsome-js' ),
'0.0.1',
true
);
wp_enqueue_script( 'child-main-js' );
} );
view raw functions.php hosted with ❤ by GitHub