|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Module Name: Tiled Galleries |
|
5
|
|
|
* Module Description: Display image galleries in a variety of elegant arrangements. |
|
6
|
|
|
* Jumpstart Description: Display image galleries in a variety of elegant arrangements. |
|
7
|
|
|
* First Introduced: 2.1 |
|
8
|
|
|
* Requires Connection: No |
|
9
|
|
|
* Auto Activate: No |
|
10
|
|
|
* Module Tags: Photos and Videos |
|
11
|
|
|
* Feature: Appearance, Jumpstart |
|
12
|
|
|
* Sort Order: 24 |
|
13
|
|
|
* Additional Search Queries: gallery, tiles, tiled, grid, mosaic, images |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
function jetpack_load_tiled_gallery() { |
|
17
|
|
|
include dirname( __FILE__ ) . "/tiled-gallery/tiled-gallery.php"; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
add_action( 'jetpack_modules_loaded', 'jetpack_tiled_gallery_loaded' ); |
|
21
|
|
|
|
|
22
|
|
|
function jetpack_tiled_gallery_loaded() { |
|
23
|
|
|
Jetpack::enable_module_configurable( __FILE__ ); |
|
24
|
|
|
Jetpack::module_configuration_load( __FILE__, 'jetpack_tiled_gallery_configuration_load' ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function jetpack_tiled_gallery_configuration_load() { |
|
28
|
|
|
wp_safe_redirect( admin_url( 'options-media.php' ) ); |
|
29
|
|
|
exit; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
jetpack_load_tiled_gallery(); |
|
33
|
|
|
|
|
34
|
|
|
// Tile-gallery block definition can be found in wp-calypso repo |
|
35
|
|
|
jetpack_register_block( 'tiled-gallery', array( |
|
36
|
|
|
'render_callback' => 'jetpack_tiled_gallery_load_assets' // This is needed to enqueue front end assets as we request them instead of always |
|
37
|
|
|
) ); |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Renders the tiled gallery dynamically to the user |
|
41
|
|
|
* Currently we use the render_callback to include only load the front end assets when they are required. |
|
42
|
|
|
* |
|
43
|
|
|
* @param $attr array - array of attributes |
|
44
|
|
|
* @param $content string - content block |
|
45
|
|
|
* |
|
46
|
|
|
* @return string |
|
47
|
|
|
*/ |
|
48
|
|
|
function jetpack_tiled_gallery_load_assets( $attr, $content ) { |
|
49
|
|
|
Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery' ); |
|
50
|
|
|
return $content; |
|
51
|
|
|
} |
|
52
|
|
|
|