Completed
Push — dependabot/npm_and_yarn/ini-1.... ( 6a445d...18502d )
by Yaroslav
08:59 queued 10s
created

conversation.php ➔ render_block()   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
 * Conversation Block.
4
 *
5
 * @since 9.3.0
6
 *
7
 * @package Jetpack
8
 */
9
10
namespace Automattic\Jetpack\Extensions\Conversation;
11
12
use Automattic\Jetpack\Blocks;
13
use Jetpack_Gutenberg;
14
15
const FEATURE_NAME = 'conversation';
16
const BLOCK_NAME   = 'jetpack/' . FEATURE_NAME;
17
18
/**
19
 * Registers the block for use in Gutenberg
20
 * This is done via an action so that we can disable
21
 * registration if we need to.
22
 */
23 View Code Duplication
function register_block() {
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
	$deprecated = function_exists( 'gutenberg_get_post_from_context' );
25
	$provides   = $deprecated ? 'providesContext' : 'provides_context';
26
27
	Blocks::jetpack_register_block(
28
		BLOCK_NAME,
29
		array(
30
			'render_callback' => __NAMESPACE__ . '\render_block',
31
			$provides         => array(
32
				'jetpack/conversation-participants'   => 'participants',
33
				'jetpack/conversation-showTimestamps' => 'showTimestamps',
34
			),
35
		)
36
	);
37
}
38
add_action( 'init', __NAMESPACE__ . '\register_block' );
39
40
/**
41
 * Conversation block registration/dependency declaration.
42
 *
43
 * @param array  $attr    Array containing the Conversation block attributes.
44
 * @param string $content String containing the Conversation block content.
45
 *
46
 * @return string
47
 */
48
function render_block( $attr, $content ) {
49
	Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME );
50
	return $content;
51
}
52