Completed
Push — subscription-block-use-new-but... ( ba2b7e...c53c9f )
by
unknown
06:59
created

blocks.php ➔ jetpack_gif_block_render()   B

Complexity

Conditions 9
Paths 160

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
nc 160
nop 1
dl 0
loc 36
rs 7.5555
c 0
b 0
f 0
1
<?php
2
/**
3
 * Load code specific to Gutenberg blocks which are not tied to a module.
4
 * This file is unusual, and is not an actual `module` as such.
5
 * It is included in ./module-extras.php
6
 *
7
 */
8
9
jetpack_register_block(
10
	'map',
11
	array(
12
		'render_callback' => 'jetpack_map_block_load_assets',
13
	)
14
);
15
16
jetpack_register_block( 'vr' );
17
18
/**
19
 * Tiled Gallery block. Depends on the Photon module.
20
 *
21
 * @since 6.9.0
22
*/
23
if (
24
	( defined( 'IS_WPCOM' ) && IS_WPCOM ) ||
25
	class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' )
26
) {
27
	jetpack_register_block(
28
		'tiled-gallery',
29
		array(
30
			'render_callback' => 'jetpack_tiled_gallery_load_block_assets',
31
		)
32
	);
33
34
	/**
35
	 * Tiled gallery block registration/dependency declaration.
36
	 *
37
	 * @param array  $attr - Array containing the block attributes.
38
	 * @param string $content - String containing the block content.
39
	 *
40
	 * @return string
41
	 */
42
	function jetpack_tiled_gallery_load_block_assets( $attr, $content ) {
43
		$dependencies = array(
44
			'lodash',
45
			'wp-i18n',
46
			'wp-token-list',
47
		);
48
		Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies );
49
50
		/**
51
		 * Filter the output of the Tiled Galleries content.
52
		 *
53
		 * @module tiled-gallery
54
		 *
55
		 * @since 6.9.0
56
		 *
57
		 * @param string $content Tiled Gallery block content.
58
		 */
59
		return apply_filters( 'jetpack_tiled_galleries_block_content', $content );
60
	}
61
}
62
63
/**
64
 * Map block registration/dependency declaration.
65
 *
66
 * @param array  $attr - Array containing the map block attributes.
67
 * @param string $content - String containing the map block content.
68
 *
69
 * @return string
70
 */
71
function jetpack_map_block_load_assets( $attr, $content ) {
72
	$dependencies = array(
73
		'lodash',
74
		'wp-element',
75
		'wp-i18n',
76
	);
77
78
	$api_key = Jetpack_Options::get_option( 'mapbox_api_key' );
79
80
	Jetpack_Gutenberg::load_assets_as_required( 'map', $dependencies );
81
	return preg_replace( '/<div /', '<div data-api-key="'. esc_attr( $api_key ) .'" ', $content, 1 );
82
}
83