Completed
Push — add/optin-beta-blocks ( ba091d...7fbc6b )
by
unknown
82:39 queued 75:19
created

tiled-gallery.php ➔ jetpack_tiled_gallery_load_assets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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