1 | <?php |
||
27 | abstract class Block implements BlockInterface |
||
28 | { |
||
29 | |||
30 | const NS = 'event-espresso/'; |
||
31 | |||
32 | /** |
||
33 | * AssetRegister that this editor block uses for asset registration |
||
34 | * |
||
35 | * @var AssetRegisterInterface $asset_register_fqcn |
||
36 | */ |
||
37 | protected $asset_register; |
||
38 | |||
39 | /** |
||
40 | * @var string $editor_block_type |
||
41 | */ |
||
42 | private $editor_block_type; |
||
43 | |||
44 | /** |
||
45 | * @var WP_Block_Type $wp_block_type |
||
46 | */ |
||
47 | private $wp_block_type; |
||
48 | |||
49 | /** |
||
50 | * @var array $supported_post_types |
||
51 | */ |
||
52 | private $supported_post_types; |
||
53 | |||
54 | /** |
||
55 | * @var array $attributes |
||
56 | */ |
||
57 | private $attributes; |
||
58 | |||
59 | /** |
||
60 | * If set to true, then the block will render its content client side |
||
61 | * If false, then the block will render its content server side using the renderBlock() method |
||
62 | * |
||
63 | * @var bool $dynamic |
||
64 | */ |
||
65 | private $dynamic = false; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * BlockLoader constructor. |
||
70 | * |
||
71 | * @param AssetRegisterInterface $asset_register |
||
72 | */ |
||
73 | public function __construct(AssetRegisterInterface $asset_register) { |
||
76 | |||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function blockType() |
||
85 | |||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function namespacedBlockType() |
||
94 | |||
95 | |||
96 | /** |
||
97 | * @param string $editor_block_type |
||
98 | */ |
||
99 | protected function setBlockType($editor_block_type) |
||
103 | |||
104 | |||
105 | /** |
||
106 | * AssetRegister that this editor block uses for asset registration |
||
107 | * |
||
108 | * @return AssetRegisterInterface |
||
109 | */ |
||
110 | public function assetRegister() |
||
114 | |||
115 | |||
116 | |||
117 | /** |
||
118 | * @param WP_Block_Type $wp_block_type |
||
119 | */ |
||
120 | protected function setWpBlockType($wp_block_type) |
||
124 | |||
125 | |||
126 | /** |
||
127 | * @param array $supported_post_types |
||
128 | */ |
||
129 | protected function setSupportedPostTypes(array $supported_post_types) |
||
133 | |||
134 | |||
135 | /** |
||
136 | * @return array |
||
137 | */ |
||
138 | public function attributes() |
||
142 | |||
143 | |||
144 | /** |
||
145 | * @param array $attributes |
||
146 | */ |
||
147 | public function setAttributes(array $attributes) |
||
151 | |||
152 | |||
153 | /** |
||
154 | * @return bool |
||
155 | */ |
||
156 | public function isDynamic() |
||
160 | |||
161 | |||
162 | /** |
||
163 | * @param bool $dynamic |
||
164 | */ |
||
165 | public function setDynamic($dynamic = true) |
||
169 | |||
170 | |||
171 | /** |
||
172 | * Registers the Editor Block with WP core; |
||
173 | * Returns the registered block type on success, or false on failure. |
||
174 | * |
||
175 | * @return WP_Block_Type|false |
||
176 | */ |
||
177 | public function registerBlock() |
||
200 | |||
201 | |||
202 | /** |
||
203 | * @return WP_Block_Type|false The registered block type on success, or false on failure. |
||
204 | */ |
||
205 | public function unRegisterBlock() |
||
209 | |||
210 | |||
211 | /** |
||
212 | * returns true if the block type applies for the supplied post type |
||
213 | * and should be added to that post type's editor |
||
214 | * |
||
215 | * @param string $post_type |
||
216 | * @return boolean |
||
217 | */ |
||
218 | public function appliesToPostType($post_type) |
||
222 | |||
223 | |||
224 | /** |
||
225 | * @return array |
||
226 | */ |
||
227 | public function getEditorContainer() |
||
234 | |||
235 | |||
236 | |||
237 | /** |
||
238 | * returns the rendered HTML for the block |
||
239 | * |
||
240 | * @param array $attributes |
||
241 | * @return string |
||
242 | */ |
||
243 | public function renderBlock(array $attributes = array()) |
||
247 | } |
||
248 |