Completed
Branch Gutenberg/espresso-cpt-editor (d57906)
by
unknown
78:21 queued 69:49
created
core/services/editor/BlockAssetRegister.php 2 patches
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -22,198 +22,198 @@
 block discarded – undo
22 22
 abstract class BlockAssetRegister implements AssetRegisterInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var DomainInterface $domain
27
-     */
28
-    private $domain;
29
-
30
-    /**
31
-     * @var Registry $registry
32
-     */
33
-    private $registry;
34
-
35
-    /**
36
-     * @var string $script_handle
37
-     */
38
-    private $script_handle;
39
-
40
-    /**
41
-     * @var array $script_dependencies
42
-     */
43
-    private $script_dependencies;
44
-
45
-    /**
46
-     * @var string $style_handle
47
-     */
48
-    private $style_handle;
49
-
50
-    /**
51
-     * @var array $style_dependencies
52
-     */
53
-    private $style_dependencies;
54
-
55
-
56
-    /**
57
-     * BlockAssetRegister constructor.
58
-     *
59
-     * @param string          $script_handle
60
-     * @param array           $script_dependencies
61
-     * @param string          $style_handle
62
-     * @param array           $style_dependencies
63
-     * @param DomainInterface $domain
64
-     * @param Registry        $registry
65
-     * @throws InvalidDataTypeException
66
-     */
67
-    public function __construct(
68
-        $script_handle,
69
-        array $script_dependencies,
70
-        $style_handle,
71
-        array $style_dependencies,
72
-        DomainInterface $domain,
73
-        Registry $registry
74
-    ) {
75
-        $this->setScriptHandle($script_handle);
76
-        $this->setScriptDependencies($script_dependencies);
77
-        $this->setStyleHandle($style_handle);
78
-        $this->setStyleDependencies($style_dependencies);
79
-        $this->domain              = $domain;
80
-        $this->registry            = $registry;
81
-    }
82
-
83
-
84
-    /**
85
-     * @return string
86
-     */
87
-    public function scriptHandle()
88
-    {
89
-        return $this->script_handle;
90
-    }
91
-
92
-
93
-    /**
94
-     * @param string $script_handle
95
-     * @throws InvalidDataTypeException
96
-     */
97
-    private function setScriptHandle($script_handle)
98
-    {
99
-        if (! is_string($script_handle)) {
100
-            throw new InvalidDataTypeException('$script_handle', $script_handle, 'string');
101
-        }
102
-        $this->script_handle = $script_handle;
103
-    }
104
-
105
-
106
-    /**
107
-     * @return string
108
-     */
109
-    public function styleHandle()
110
-    {
111
-        return $this->style_handle;
112
-    }
113
-
114
-
115
-    /**
116
-     * @param string $style_handle
117
-     * @throws InvalidDataTypeException
118
-     */
119
-    private function setStyleHandle($style_handle)
120
-    {
121
-        if (! is_string($style_handle)) {
122
-            throw new InvalidDataTypeException('$style_handle', $style_handle, 'string');
123
-        }
124
-        $this->style_handle = $style_handle;
125
-    }
126
-
127
-
128
-    /**
129
-     * @return array
130
-     */
131
-    private function scriptDependencies()
132
-    {
133
-        return $this->script_dependencies;
134
-    }
135
-
136
-
137
-    /**
138
-     * @param array $script_dependencies
139
-     */
140
-    private function setScriptDependencies(array $script_dependencies)
141
-    {
142
-        $this->script_dependencies = $script_dependencies + array(
143
-                'eejs-core',
144
-                'wp-blocks',    // Provides useful functions and components for extending the editor
145
-                'wp-i18n',      // Provides localization functions
146
-                'wp-element',   // Provides React.Component
147
-                'wp-components' // Provides many prebuilt components and controls
148
-            );
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    private function styleDependencies()
156
-    {
157
-        return $this->style_dependencies;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param array $style_dependencies
163
-     */
164
-    private function setStyleDependencies(array $style_dependencies)
165
-    {
166
-        $this->style_dependencies = $style_dependencies;
167
-    }
168
-
169
-
170
-    /**
171
-     * @return void
172
-     * @throws \EventEspresso\core\exceptions\InvalidFilePathException
173
-     * @throws \InvalidArgumentException
174
-     */
175
-    public function registerManifestFile()
176
-    {
177
-        if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) {
178
-            $this->registry->registerManifestFile(
179
-                $this->domain->assetNamespace(),
180
-                $this->domain->distributionAssetsUrl(),
181
-                $this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST
182
-            );
183
-        }
184
-    }
185
-
186
-
187
-    /**
188
-     * @return  void
189
-     */
190
-    public function registerScripts()
191
-    {
192
-        wp_register_script(
193
-            $this->scriptHandle(),
194
-            $this->registry->getJsUrl(
195
-                $this->domain->assetNamespace(),
196
-                $this->scriptHandle()
197
-            ),
198
-            $this->scriptDependencies(),
199
-            null,
200
-            true
201
-        );
202
-    }
203
-
204
-
205
-    /**
206
-     * @return void
207
-     */
208
-    public function registerStyles()
209
-    {
210
-        wp_register_style(
211
-            $this->styleHandle(),
212
-            $this->registry->getCssUrl(
213
-                $this->domain->assetNamespace(),
214
-                $this->styleHandle()
215
-            ),
216
-            $this->styleDependencies()
217
-        );
218
-    }
25
+	/**
26
+	 * @var DomainInterface $domain
27
+	 */
28
+	private $domain;
29
+
30
+	/**
31
+	 * @var Registry $registry
32
+	 */
33
+	private $registry;
34
+
35
+	/**
36
+	 * @var string $script_handle
37
+	 */
38
+	private $script_handle;
39
+
40
+	/**
41
+	 * @var array $script_dependencies
42
+	 */
43
+	private $script_dependencies;
44
+
45
+	/**
46
+	 * @var string $style_handle
47
+	 */
48
+	private $style_handle;
49
+
50
+	/**
51
+	 * @var array $style_dependencies
52
+	 */
53
+	private $style_dependencies;
54
+
55
+
56
+	/**
57
+	 * BlockAssetRegister constructor.
58
+	 *
59
+	 * @param string          $script_handle
60
+	 * @param array           $script_dependencies
61
+	 * @param string          $style_handle
62
+	 * @param array           $style_dependencies
63
+	 * @param DomainInterface $domain
64
+	 * @param Registry        $registry
65
+	 * @throws InvalidDataTypeException
66
+	 */
67
+	public function __construct(
68
+		$script_handle,
69
+		array $script_dependencies,
70
+		$style_handle,
71
+		array $style_dependencies,
72
+		DomainInterface $domain,
73
+		Registry $registry
74
+	) {
75
+		$this->setScriptHandle($script_handle);
76
+		$this->setScriptDependencies($script_dependencies);
77
+		$this->setStyleHandle($style_handle);
78
+		$this->setStyleDependencies($style_dependencies);
79
+		$this->domain              = $domain;
80
+		$this->registry            = $registry;
81
+	}
82
+
83
+
84
+	/**
85
+	 * @return string
86
+	 */
87
+	public function scriptHandle()
88
+	{
89
+		return $this->script_handle;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param string $script_handle
95
+	 * @throws InvalidDataTypeException
96
+	 */
97
+	private function setScriptHandle($script_handle)
98
+	{
99
+		if (! is_string($script_handle)) {
100
+			throw new InvalidDataTypeException('$script_handle', $script_handle, 'string');
101
+		}
102
+		$this->script_handle = $script_handle;
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return string
108
+	 */
109
+	public function styleHandle()
110
+	{
111
+		return $this->style_handle;
112
+	}
113
+
114
+
115
+	/**
116
+	 * @param string $style_handle
117
+	 * @throws InvalidDataTypeException
118
+	 */
119
+	private function setStyleHandle($style_handle)
120
+	{
121
+		if (! is_string($style_handle)) {
122
+			throw new InvalidDataTypeException('$style_handle', $style_handle, 'string');
123
+		}
124
+		$this->style_handle = $style_handle;
125
+	}
126
+
127
+
128
+	/**
129
+	 * @return array
130
+	 */
131
+	private function scriptDependencies()
132
+	{
133
+		return $this->script_dependencies;
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param array $script_dependencies
139
+	 */
140
+	private function setScriptDependencies(array $script_dependencies)
141
+	{
142
+		$this->script_dependencies = $script_dependencies + array(
143
+				'eejs-core',
144
+				'wp-blocks',    // Provides useful functions and components for extending the editor
145
+				'wp-i18n',      // Provides localization functions
146
+				'wp-element',   // Provides React.Component
147
+				'wp-components' // Provides many prebuilt components and controls
148
+			);
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	private function styleDependencies()
156
+	{
157
+		return $this->style_dependencies;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param array $style_dependencies
163
+	 */
164
+	private function setStyleDependencies(array $style_dependencies)
165
+	{
166
+		$this->style_dependencies = $style_dependencies;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return void
172
+	 * @throws \EventEspresso\core\exceptions\InvalidFilePathException
173
+	 * @throws \InvalidArgumentException
174
+	 */
175
+	public function registerManifestFile()
176
+	{
177
+		if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) {
178
+			$this->registry->registerManifestFile(
179
+				$this->domain->assetNamespace(),
180
+				$this->domain->distributionAssetsUrl(),
181
+				$this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST
182
+			);
183
+		}
184
+	}
185
+
186
+
187
+	/**
188
+	 * @return  void
189
+	 */
190
+	public function registerScripts()
191
+	{
192
+		wp_register_script(
193
+			$this->scriptHandle(),
194
+			$this->registry->getJsUrl(
195
+				$this->domain->assetNamespace(),
196
+				$this->scriptHandle()
197
+			),
198
+			$this->scriptDependencies(),
199
+			null,
200
+			true
201
+		);
202
+	}
203
+
204
+
205
+	/**
206
+	 * @return void
207
+	 */
208
+	public function registerStyles()
209
+	{
210
+		wp_register_style(
211
+			$this->styleHandle(),
212
+			$this->registry->getCssUrl(
213
+				$this->domain->assetNamespace(),
214
+				$this->styleHandle()
215
+			),
216
+			$this->styleDependencies()
217
+		);
218
+	}
219 219
 }
220 220
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     private function setScriptHandle($script_handle)
98 98
     {
99
-        if (! is_string($script_handle)) {
99
+        if ( ! is_string($script_handle)) {
100 100
             throw new InvalidDataTypeException('$script_handle', $script_handle, 'string');
101 101
         }
102 102
         $this->script_handle = $script_handle;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     private function setStyleHandle($style_handle)
120 120
     {
121
-        if (! is_string($style_handle)) {
121
+        if ( ! is_string($style_handle)) {
122 122
             throw new InvalidDataTypeException('$style_handle', $style_handle, 'string');
123 123
         }
124 124
         $this->style_handle = $style_handle;
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $this->script_dependencies = $script_dependencies + array(
143 143
                 'eejs-core',
144
-                'wp-blocks',    // Provides useful functions and components for extending the editor
145
-                'wp-i18n',      // Provides localization functions
146
-                'wp-element',   // Provides React.Component
144
+                'wp-blocks', // Provides useful functions and components for extending the editor
145
+                'wp-i18n', // Provides localization functions
146
+                'wp-element', // Provides React.Component
147 147
                 'wp-components' // Provides many prebuilt components and controls
148 148
             );
149 149
     }
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function registerManifestFile()
176 176
     {
177
-        if($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) {
177
+        if ($this->domain->assetNamespace() !== Registry::ASSET_NAMESPACE_CORE) {
178 178
             $this->registry->registerManifestFile(
179 179
                 $this->domain->assetNamespace(),
180 180
                 $this->domain->distributionAssetsUrl(),
181
-                $this->domain->distributionAssetsPath() . Registry::FILE_NAME_BUILD_MANIFEST
181
+                $this->domain->distributionAssetsPath().Registry::FILE_NAME_BUILD_MANIFEST
182 182
             );
183 183
         }
184 184
     }
Please login to merge, or discard this patch.
core/services/assets/AssetRegisterInterface.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,28 +16,28 @@
 block discarded – undo
16 16
  */
17 17
 interface AssetRegisterInterface
18 18
 {
19
-    /**
20
-     * @return  void
21
-     */
22
-    public function registerManifestFile();
23
-
24
-    /**
25
-     * @return  void
26
-     */
27
-    public function registerScripts();
28
-
29
-    /**
30
-     * @return void
31
-     */
32
-    public function registerStyles();
33
-
34
-    /**
35
-     * @return string
36
-     */
37
-    public function scriptHandle();
38
-
39
-    /**
40
-     * @return string
41
-     */
42
-    public function styleHandle();
19
+	/**
20
+	 * @return  void
21
+	 */
22
+	public function registerManifestFile();
23
+
24
+	/**
25
+	 * @return  void
26
+	 */
27
+	public function registerScripts();
28
+
29
+	/**
30
+	 * @return void
31
+	 */
32
+	public function registerStyles();
33
+
34
+	/**
35
+	 * @return string
36
+	 */
37
+	public function scriptHandle();
38
+
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function styleHandle();
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
core/domain/entities/editor/Block.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -24,219 +24,219 @@
 block discarded – undo
24 24
 abstract class Block implements BlockInterface
25 25
 {
26 26
 
27
-    const NS = 'event-espresso/';
28
-
29
-    /**
30
-     * AssetRegister that this editor block uses for asset registration
31
-     *
32
-     * @var AssetRegisterInterface $asset_register_fqcn
33
-     */
34
-    protected $asset_register;
35
-
36
-    /**
37
-     * @var array $attributes
38
-     */
39
-    private $attributes;
40
-
41
-    /**
42
-     * If set to true, then the block will render its content client side
43
-     * If false, then the block will render its content server side using the renderBlock() method
44
-     *
45
-     * @var bool $dynamic
46
-     */
47
-    private $dynamic = false;
48
-
49
-    /**
50
-     * @var string $editor_block_type
51
-     */
52
-    private $editor_block_type;
53
-
54
-    /**
55
-     * @var array $supported_post_types
56
-     */
57
-    private $supported_post_types;
58
-
59
-    /**
60
-     * @var WP_Block_Type $wp_block_type
61
-     */
62
-    private $wp_block_type;
63
-
64
-
65
-    /**
66
-     * BlockLoader constructor.
67
-     *
68
-     * @param AssetRegisterInterface $asset_register
69
-     */
70
-    public function __construct(AssetRegisterInterface $asset_register) {
71
-        $this->asset_register = $asset_register;
72
-    }
73
-
74
-
75
-    /**
76
-     * @return string
77
-     */
78
-    public function blockType()
79
-    {
80
-        return $this->editor_block_type;
81
-    }
82
-
83
-
84
-    /**
85
-     * @return string
86
-     */
87
-    public function namespacedBlockType()
88
-    {
89
-        return Block::NS . $this->editor_block_type;
90
-    }
91
-
92
-
93
-    /**
94
-     * @param string $editor_block_type
95
-     */
96
-    protected function setBlockType($editor_block_type)
97
-    {
98
-        $this->editor_block_type = $editor_block_type;
99
-    }
100
-
101
-
102
-    /**
103
-     * AssetRegister that this editor block uses for asset registration
104
-     *
105
-     * @return AssetRegisterInterface
106
-     */
107
-    public function assetRegister()
108
-    {
109
-        return $this->asset_register;
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * @param WP_Block_Type $wp_block_type
116
-     */
117
-    protected function setWpBlockType($wp_block_type)
118
-    {
119
-        $this->wp_block_type = $wp_block_type;
120
-    }
121
-
122
-
123
-    /**
124
-     * @param array $supported_post_types
125
-     */
126
-    protected function setSupportedPostTypes(array $supported_post_types)
127
-    {
128
-        $this->supported_post_types = $supported_post_types;
129
-    }
130
-
131
-
132
-    /**
133
-     * @return array
134
-     */
135
-    public function attributes()
136
-    {
137
-        return $this->attributes;
138
-    }
139
-
140
-
141
-    /**
142
-     * @param array $attributes
143
-     */
144
-    public function setAttributes(array $attributes)
145
-    {
146
-        $this->attributes = $attributes;
147
-    }
148
-
149
-
150
-    /**
151
-     * @return bool
152
-     */
153
-    public function isDynamic()
154
-    {
155
-        return $this->dynamic;
156
-    }
157
-
158
-
159
-    /**
160
-     * @param bool $dynamic
161
-     */
162
-    public function setDynamic($dynamic = true)
163
-    {
164
-        $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN);
165
-    }
166
-
167
-
168
-    /**
169
-     * Registers the Editor Block with WP core;
170
-     * Returns the registered block type on success, or false on failure.
171
-     *
172
-     * @return WP_Block_Type|false
173
-     */
174
-    public function registerBlock()
175
-    {
176
-        $args          = array(
177
-            'attributes'      => $this->attributes(),
178
-            'editor_script'   => $this->asset_register->scriptHandle(),
179
-            'editor_style'    => $this->asset_register->styleHandle(),
180
-            'script'          => $this->asset_register->scriptHandle(),
181
-            'style'           => $this->asset_register->styleHandle(),
182
-        );
183
-        if(! $this->isDynamic()) {
184
-            $args['render_callback'] = $this->renderBlock();
185
-        }
186
-        $wp_block_type = register_block_type(
187
-            new WP_Block_Type(
188
-                $this->namespacedBlockType(),
189
-                $args
190
-            )
191
-        );
192
-        $this->setWpBlockType($wp_block_type);
193
-        return $wp_block_type;
194
-    }
195
-
196
-
197
-    /**
198
-     * @return WP_Block_Type|false The registered block type on success, or false on failure.
199
-     */
200
-    public function unRegisterBlock()
201
-    {
202
-        return unregister_block_type($this->namespacedBlockType());
203
-    }
204
-
205
-
206
-    /**
207
-     * returns true if the block type applies for the supplied post type
208
-     * and should be added to that post type's editor
209
-     *
210
-     * @param string $post_type
211
-     * @return boolean
212
-     */
213
-    public function appliesToPostType($post_type)
214
-    {
215
-        return in_array($post_type, $this->supported_post_types, true);
216
-    }
217
-
218
-
219
-    /**
220
-     * @return array
221
-     */
222
-    public function getEditorContainer()
223
-    {
224
-        return array(
225
-            $this->namespacedBlockType(),
226
-            array()
227
-        );
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * returns the rendered HTML for the block
234
-     *
235
-     * @param array $attributes
236
-     * @return string
237
-     */
238
-    public function renderBlock(array $attributes = array())
239
-    {
240
-        return '';
241
-    }
27
+	const NS = 'event-espresso/';
28
+
29
+	/**
30
+	 * AssetRegister that this editor block uses for asset registration
31
+	 *
32
+	 * @var AssetRegisterInterface $asset_register_fqcn
33
+	 */
34
+	protected $asset_register;
35
+
36
+	/**
37
+	 * @var array $attributes
38
+	 */
39
+	private $attributes;
40
+
41
+	/**
42
+	 * If set to true, then the block will render its content client side
43
+	 * If false, then the block will render its content server side using the renderBlock() method
44
+	 *
45
+	 * @var bool $dynamic
46
+	 */
47
+	private $dynamic = false;
48
+
49
+	/**
50
+	 * @var string $editor_block_type
51
+	 */
52
+	private $editor_block_type;
53
+
54
+	/**
55
+	 * @var array $supported_post_types
56
+	 */
57
+	private $supported_post_types;
58
+
59
+	/**
60
+	 * @var WP_Block_Type $wp_block_type
61
+	 */
62
+	private $wp_block_type;
63
+
64
+
65
+	/**
66
+	 * BlockLoader constructor.
67
+	 *
68
+	 * @param AssetRegisterInterface $asset_register
69
+	 */
70
+	public function __construct(AssetRegisterInterface $asset_register) {
71
+		$this->asset_register = $asset_register;
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return string
77
+	 */
78
+	public function blockType()
79
+	{
80
+		return $this->editor_block_type;
81
+	}
82
+
83
+
84
+	/**
85
+	 * @return string
86
+	 */
87
+	public function namespacedBlockType()
88
+	{
89
+		return Block::NS . $this->editor_block_type;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param string $editor_block_type
95
+	 */
96
+	protected function setBlockType($editor_block_type)
97
+	{
98
+		$this->editor_block_type = $editor_block_type;
99
+	}
100
+
101
+
102
+	/**
103
+	 * AssetRegister that this editor block uses for asset registration
104
+	 *
105
+	 * @return AssetRegisterInterface
106
+	 */
107
+	public function assetRegister()
108
+	{
109
+		return $this->asset_register;
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * @param WP_Block_Type $wp_block_type
116
+	 */
117
+	protected function setWpBlockType($wp_block_type)
118
+	{
119
+		$this->wp_block_type = $wp_block_type;
120
+	}
121
+
122
+
123
+	/**
124
+	 * @param array $supported_post_types
125
+	 */
126
+	protected function setSupportedPostTypes(array $supported_post_types)
127
+	{
128
+		$this->supported_post_types = $supported_post_types;
129
+	}
130
+
131
+
132
+	/**
133
+	 * @return array
134
+	 */
135
+	public function attributes()
136
+	{
137
+		return $this->attributes;
138
+	}
139
+
140
+
141
+	/**
142
+	 * @param array $attributes
143
+	 */
144
+	public function setAttributes(array $attributes)
145
+	{
146
+		$this->attributes = $attributes;
147
+	}
148
+
149
+
150
+	/**
151
+	 * @return bool
152
+	 */
153
+	public function isDynamic()
154
+	{
155
+		return $this->dynamic;
156
+	}
157
+
158
+
159
+	/**
160
+	 * @param bool $dynamic
161
+	 */
162
+	public function setDynamic($dynamic = true)
163
+	{
164
+		$this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN);
165
+	}
166
+
167
+
168
+	/**
169
+	 * Registers the Editor Block with WP core;
170
+	 * Returns the registered block type on success, or false on failure.
171
+	 *
172
+	 * @return WP_Block_Type|false
173
+	 */
174
+	public function registerBlock()
175
+	{
176
+		$args          = array(
177
+			'attributes'      => $this->attributes(),
178
+			'editor_script'   => $this->asset_register->scriptHandle(),
179
+			'editor_style'    => $this->asset_register->styleHandle(),
180
+			'script'          => $this->asset_register->scriptHandle(),
181
+			'style'           => $this->asset_register->styleHandle(),
182
+		);
183
+		if(! $this->isDynamic()) {
184
+			$args['render_callback'] = $this->renderBlock();
185
+		}
186
+		$wp_block_type = register_block_type(
187
+			new WP_Block_Type(
188
+				$this->namespacedBlockType(),
189
+				$args
190
+			)
191
+		);
192
+		$this->setWpBlockType($wp_block_type);
193
+		return $wp_block_type;
194
+	}
195
+
196
+
197
+	/**
198
+	 * @return WP_Block_Type|false The registered block type on success, or false on failure.
199
+	 */
200
+	public function unRegisterBlock()
201
+	{
202
+		return unregister_block_type($this->namespacedBlockType());
203
+	}
204
+
205
+
206
+	/**
207
+	 * returns true if the block type applies for the supplied post type
208
+	 * and should be added to that post type's editor
209
+	 *
210
+	 * @param string $post_type
211
+	 * @return boolean
212
+	 */
213
+	public function appliesToPostType($post_type)
214
+	{
215
+		return in_array($post_type, $this->supported_post_types, true);
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return array
221
+	 */
222
+	public function getEditorContainer()
223
+	{
224
+		return array(
225
+			$this->namespacedBlockType(),
226
+			array()
227
+		);
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * returns the rendered HTML for the block
234
+	 *
235
+	 * @param array $attributes
236
+	 * @return string
237
+	 */
238
+	public function renderBlock(array $attributes = array())
239
+	{
240
+		return '';
241
+	}
242 242
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function namespacedBlockType()
88 88
     {
89
-        return Block::NS . $this->editor_block_type;
89
+        return Block::NS.$this->editor_block_type;
90 90
     }
91 91
 
92 92
 
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function registerBlock()
175 175
     {
176
-        $args          = array(
176
+        $args = array(
177 177
             'attributes'      => $this->attributes(),
178 178
             'editor_script'   => $this->asset_register->scriptHandle(),
179 179
             'editor_style'    => $this->asset_register->styleHandle(),
180 180
             'script'          => $this->asset_register->scriptHandle(),
181 181
             'style'           => $this->asset_register->styleHandle(),
182 182
         );
183
-        if(! $this->isDynamic()) {
183
+        if ( ! $this->isDynamic()) {
184 184
             $args['render_callback'] = $this->renderBlock();
185 185
         }
186 186
         $wp_block_type = register_block_type(
Please login to merge, or discard this patch.