1 | <?php |
||
26 | abstract class EditorBlock implements EditorBlockInterface |
||
27 | { |
||
28 | |||
29 | const NS = 'event-espresso/'; |
||
30 | |||
31 | /** |
||
32 | * @var DomainInterface $domain |
||
33 | */ |
||
34 | protected $domain; |
||
35 | |||
36 | /** |
||
37 | * @var LoaderInterface $loader |
||
38 | */ |
||
39 | protected $loader; |
||
40 | |||
41 | /** |
||
42 | * @var string $editor_block_type |
||
43 | */ |
||
44 | private $editor_block_type; |
||
45 | |||
46 | /** |
||
47 | * @var WP_Block_Type $wp_block_type |
||
48 | */ |
||
49 | private $wp_block_type; |
||
50 | |||
51 | /** |
||
52 | * @var array $supported_post_types |
||
53 | */ |
||
54 | private $supported_post_types; |
||
55 | |||
56 | /** |
||
57 | * @var array $attributes |
||
58 | */ |
||
59 | private $attributes; |
||
60 | |||
61 | /** |
||
62 | * If set to true, then the block will render its content client side |
||
63 | * If false, then the block will render its content server side using the renderBlock() method |
||
64 | * |
||
65 | * @var bool $dynamic |
||
66 | */ |
||
67 | private $dynamic = false; |
||
68 | |||
69 | |||
70 | /** |
||
71 | * EditorBlockLoader constructor. |
||
72 | * |
||
73 | * @param DomainInterface $domain |
||
74 | * @param LoaderInterface $loader |
||
75 | */ |
||
76 | public function __construct(DomainInterface $domain, LoaderInterface $loader) |
||
81 | |||
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | public function editorBlockType() |
||
90 | |||
91 | |||
92 | /** |
||
93 | * @return string |
||
94 | */ |
||
95 | public function namespacedEditorBlockType() |
||
99 | |||
100 | |||
101 | /** |
||
102 | * @param string $editor_block_type |
||
103 | */ |
||
104 | protected function setEditorBlockType($editor_block_type) |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @param WP_Block_Type $wp_block_type |
||
112 | */ |
||
113 | protected function setWpBlockType($wp_block_type) |
||
117 | |||
118 | |||
119 | /** |
||
120 | * @param array $supported_post_types |
||
121 | */ |
||
122 | protected function setSupportedPostTypes(array $supported_post_types) |
||
126 | |||
127 | |||
128 | /** |
||
129 | * @return array |
||
130 | */ |
||
131 | public function attributes() |
||
135 | |||
136 | |||
137 | /** |
||
138 | * @param array $attributes |
||
139 | */ |
||
140 | public function setAttributes(array $attributes) |
||
144 | |||
145 | |||
146 | /** |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function isDynamic() |
||
153 | |||
154 | |||
155 | /** |
||
156 | * @param bool $dynamic |
||
157 | */ |
||
158 | public function setDynamic($dynamic = true) |
||
162 | |||
163 | |||
164 | /** |
||
165 | * Registers the Editor Block with WP core; |
||
166 | * Returns the registered block type on success, or false on failure. |
||
167 | * |
||
168 | * @return WP_Block_Type|false |
||
169 | */ |
||
170 | public function registerBlock() |
||
193 | |||
194 | |||
195 | /** |
||
196 | * @return WP_Block_Type|false The registered block type on success, or false on failure. |
||
197 | */ |
||
198 | public function unRegisterBlock() |
||
202 | |||
203 | |||
204 | /** |
||
205 | * returns true if the block type applies for the supplied post type |
||
206 | * and should be added to that post type's editor |
||
207 | * |
||
208 | * @param string $post_type |
||
209 | * @return boolean |
||
210 | */ |
||
211 | public function appliesToPostType($post_type) |
||
215 | |||
216 | |||
217 | /** |
||
218 | * @return array |
||
219 | */ |
||
220 | public function getEditorContainer() |
||
227 | |||
228 | |||
229 | /** |
||
230 | * @return void |
||
231 | */ |
||
232 | public function registerScripts() |
||
246 | |||
247 | |||
248 | /** |
||
249 | * @return void |
||
250 | */ |
||
251 | public function registerStyles() |
||
260 | } |
||
261 |