Completed
Pull Request — master (#808)
by
unknown
07:45 queued 05:21
created

blocks.php ➔ yikes_maybe_activate_blocks()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
cc 6
nc 6
nop 0
dl 0
loc 19
ccs 0
cts 13
cp 0
crap 42
rs 9.0111
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A YIKES_Easy_Forms_Blocks::__construct() 0 4 1
YIKES_Easy_Forms_Blocks::editor_scripts() 0 1 ?
1
<?php
2
/**
3
 * Class YIKES_Easy_Forms_Blocks.
4
 */
5
abstract class YIKES_Easy_Forms_Blocks {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
7
	const BLOCK_NAMESPACE = 'yikes-inc-easy-forms/';
8
9
	/**
10
	 * Register our hooks.
11
	 */
12
	public function __construct() {
13
		add_action( 'enqueue_block_editor_assets', array( $this, 'editor_scripts' ) );
14
		add_action( 'init', array( $this, 'register_blocks' ), 11 );
15
	}
16
17
	/**
18
	 * Enqueue our scripts.
19
	 */
20
	abstract public function editor_scripts();
21
22
	/**
23
	 * Register our Easy Forms block callback.
24
	 */
25
	public function register_blocks() {
26
		register_block_type(
27
			static::BLOCK_NAMESPACE . static::BLOCK,
28
			array(
29
				'render_callback' => array( $this, 'render_block' ),
30
			)
31
		);
32
	}
33
34
	/**
35
	 * Take the shortcode parameters from the Gutenberg block and render our shortcode.
36
	 *
37
	 * @param array  $attributes Block attributes.
38
	 * @param string $content    Block content.
39
	 * @return string Block output.
40
	 */
41
	abstract public function render_block( $attributes, $content );
42
}
43