Forked from n7studios/envira-gallery-load-lightbox-from-link.php
Created
January 6, 2016 07:25
-
-
Save zeshanshani/c207f36ab157db4484cc to your computer and use it in GitHub Desktop.
Envira Gallery - Load Lightbox from Link
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
<?php | |
/** | |
* Plugin Name: Envira Gallery - Load Lightbox from Link | |
* Plugin URI: http://enviragallery.com | |
* Version: 1.0 | |
* Author: Tim Carr | |
* Author URI: http://www.n7studios.co.uk | |
* Description: Launch a gallery's lightbox from a link. Requires that the gallery be embedded into the Page. | |
*/ | |
function envira_gallery_launch_lightbox( $data ) { | |
?> | |
<script> | |
jQuery(document).ready(function($) { | |
$('.envirabox').on('click', function(e) { | |
e.preventDefault(); | |
$('.envira-gallery-'+$(this).data('envira-gallery-id')).envirabox().click(); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_filter( 'wp_footer', 'envira_gallery_launch_lightbox' ); |
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
<!-- | |
1. Change data-envira-gallery-id to the Gallery ID you want to display | |
2. Ensure that Gallery is on the same page as the below link | |
3. Ensure the PHP file above is located in wp-content/plugins and activated via WordPress Admin > Plugins | |
--> | |
<a href="#" class="envirabox" data-envira-gallery-id="1234">Load Gallery in Lightbox</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment