1 | <?php |
||
20 | abstract class Block implements BlockInterface |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * BlockAssetManager that this editor block uses for asset registration |
||
25 | * |
||
26 | * @var BlockAssetManagerInterface $block_asset_manager |
||
27 | */ |
||
28 | protected $block_asset_manager; |
||
29 | |||
30 | /** |
||
31 | * @var array $attributes |
||
32 | */ |
||
33 | private $attributes; |
||
34 | |||
35 | /** |
||
36 | * If set to true, then the block will render its content client side |
||
37 | * If false, then the block will render its content server side using the renderBlock() method |
||
38 | * |
||
39 | * @var bool $dynamic |
||
40 | */ |
||
41 | private $dynamic = false; |
||
42 | |||
43 | /** |
||
44 | * @var string $block_type |
||
45 | */ |
||
46 | private $block_type; |
||
47 | |||
48 | /** |
||
49 | * @var array $supported_post_types |
||
50 | */ |
||
51 | private $supported_post_types; |
||
52 | |||
53 | /** |
||
54 | * @var WP_Block_Type $wp_block_type |
||
55 | */ |
||
56 | private $wp_block_type; |
||
57 | |||
58 | |||
59 | /** |
||
60 | * BlockLoader constructor. |
||
61 | * |
||
62 | * @param BlockAssetManagerInterface $block_asset_manager |
||
63 | */ |
||
64 | public function __construct(BlockAssetManagerInterface $block_asset_manager) |
||
68 | |||
69 | |||
70 | /** |
||
71 | * @return string |
||
72 | */ |
||
73 | public function blockType() |
||
77 | |||
78 | |||
79 | /** |
||
80 | * @return string |
||
81 | */ |
||
82 | public function namespacedBlockType() |
||
86 | |||
87 | |||
88 | /** |
||
89 | * @param string $block_type |
||
90 | */ |
||
91 | protected function setBlockType($block_type) |
||
95 | |||
96 | |||
97 | /** |
||
98 | * BlockAssetManager that this editor block uses for asset registration |
||
99 | * |
||
100 | * @return BlockAssetManagerInterface |
||
101 | */ |
||
102 | public function assetManager() |
||
106 | |||
107 | |||
108 | /** |
||
109 | * @param WP_Block_Type $wp_block_type |
||
110 | */ |
||
111 | protected function setWpBlockType($wp_block_type) |
||
115 | |||
116 | |||
117 | /** |
||
118 | * @param array $supported_post_types |
||
119 | */ |
||
120 | protected function setSupportedPostTypes(array $supported_post_types) |
||
124 | |||
125 | |||
126 | /** |
||
127 | * @return array |
||
128 | */ |
||
129 | public function attributes() |
||
133 | |||
134 | |||
135 | /** |
||
136 | * @param array $attributes |
||
137 | */ |
||
138 | public function setAttributes(array $attributes) |
||
142 | |||
143 | |||
144 | /** |
||
145 | * @return bool |
||
146 | */ |
||
147 | public function isDynamic() |
||
151 | |||
152 | |||
153 | /** |
||
154 | * @param bool $dynamic |
||
155 | */ |
||
156 | public function setDynamic($dynamic = true) |
||
160 | |||
161 | |||
162 | /** |
||
163 | * Registers the Editor Block with WP core; |
||
164 | * Returns the registered block type on success, or false on failure. |
||
165 | * |
||
166 | * @return WP_Block_Type|false |
||
167 | */ |
||
168 | public function registerBlock() |
||
189 | |||
190 | |||
191 | /** |
||
192 | * @return WP_Block_Type|false The registered block type on success, or false on failure. |
||
193 | */ |
||
194 | public function unRegisterBlock() |
||
198 | |||
199 | |||
200 | /** |
||
201 | * returns true if the block type applies for the supplied post type |
||
202 | * and should be added to that post type's editor |
||
203 | * |
||
204 | * @param string $post_type |
||
205 | * @return boolean |
||
206 | */ |
||
207 | public function appliesToPostType($post_type) |
||
211 | |||
212 | |||
213 | /** |
||
214 | * @return array |
||
215 | */ |
||
216 | public function getEditorContainer() |
||
223 | |||
224 | |||
225 | /** |
||
226 | * returns the rendered HTML for the block |
||
227 | * |
||
228 | * @param array $attributes |
||
229 | * @return string |
||
230 | */ |
||
231 | public function renderBlock(array $attributes = array()) |
||
235 | } |
||
236 |