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

YIKES_Easy_Forms_Blocks   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
editor_scripts() 0 1 ?
A register_blocks() 0 8 1
render_block() 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