Completed
Push — update/story-block-loading-med... ( e6e62b...d81748 )
by
unknown
28:46 queued 18:45
created

donations.php ➔ 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
 * Donations Block.
4
 *
5
 * @since 8.x
6
 *
7
 * @package Jetpack
8
 */
9
10
namespace Automattic\Jetpack\Extensions\Donations;
11
12
use Jetpack_Gutenberg;
13
14
const FEATURE_NAME = 'donations';
15
const BLOCK_NAME   = 'jetpack/' . FEATURE_NAME;
16
17
/**
18
 * Registers the block for use in Gutenberg
19
 * This is done via an action so that we can disable
20
 * registration if we need to.
21
 */
22
function register_block() {
23
	jetpack_register_block(
24
		BLOCK_NAME,
25
		array(
26
			'render_callback' => __NAMESPACE__ . '\load_assets',
27
			'plan_check'      => true,
28
		)
29
	);
30
}
31
add_action( 'init', __NAMESPACE__ . '\register_block' );
32
33
/**
34
 * Donations block registration/dependency declaration.
35
 *
36
 * @param array  $attr    Array containing the Donations block attributes.
37
 * @param string $content String containing the Donations block content.
38
 *
39
 * @return string
40
 */
41
function load_assets( $attr, $content ) {
42
	Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME );
43
	return $content;
44
}
45