Skip to content

Commit a419cd4

Browse files
authored
gpeb-lightbox.php: Created a rough draft lightbox implementation for Entry Blocks.
1 parent f4a72dd commit a419cd4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

experimental/gpeb-lightbox.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Entry Blocks // Lightbox
4+
* https://gravitywiz.com/documentation/gravity-forms-entry-blocks/
5+
*
6+
* A rough draft lightbox implementation for Entry Blocks!
7+
*
8+
* Instructions:
9+
*
10+
* 1. Install the Multi-file Merge Tag snippet.
11+
* https://gravitywiz.com/customizing-multi-file-merge-tag/
12+
*
13+
* 2. Copy and paste this snippet into your theme's functions.php or wherever you include custom PHP.
14+
*
15+
* 3. That's it. 😉
16+
*/
17+
add_action( 'wp', function() {
18+
if ( is_callable( 'gw_multi_file_merge_tag' ) && has_block( 'gp-entry-blocks/entries' ) ) {
19+
gw_multi_file_merge_tag()->register_settings( array(
20+
'markup' => array(
21+
array(
22+
'file_types' => array( 'jpg', 'jpeg' ),
23+
'markup' => '<div class="gpeb-image"><a href="{url}" class="gpep-image-link"><img src="{url}" width="100%" /></a><span>{filename}</span></div>'
24+
)
25+
)
26+
) );
27+
wp_enqueue_script( 'magnific', 'https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js', array( 'jquery' ), '1.1.0', true );
28+
wp_enqueue_style( 'magnific', 'https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css', array(), '1.1.0' );
29+
add_action( 'wp_footer', function() {
30+
?>
31+
<script>
32+
jQuery( document ).ready( function( $ ) {
33+
$( '.gpep-image-link' ).magnificPopup({
34+
type: 'image',
35+
gallery: {
36+
enabled: true
37+
}
38+
});
39+
});
40+
</script>
41+
<?php
42+
} );
43+
}
44+
} );

0 commit comments

Comments
 (0)