@@ -22,309 +22,309 @@ |
||
22 | 22 | abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var string $editor_script_handle |
|
27 | - */ |
|
28 | - private $editor_script_handle; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $editor_style_handle |
|
32 | - */ |
|
33 | - private $editor_style_handle; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $script_handle |
|
37 | - */ |
|
38 | - private $script_handle; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $style_handle |
|
42 | - */ |
|
43 | - private $style_handle; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getEditorScriptHandle() |
|
50 | - { |
|
51 | - return $this->editor_script_handle; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $editor_script_handle |
|
57 | - */ |
|
58 | - public function setEditorScriptHandle($editor_script_handle) |
|
59 | - { |
|
60 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | - } |
|
63 | - $this->editor_script_handle = $editor_script_handle; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function getEditorStyleHandle() |
|
71 | - { |
|
72 | - return $this->editor_style_handle; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $editor_style_handle |
|
78 | - */ |
|
79 | - public function setEditorStyleHandle($editor_style_handle) |
|
80 | - { |
|
81 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | - } |
|
84 | - $this->editor_style_handle = $editor_style_handle; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getScriptHandle() |
|
92 | - { |
|
93 | - return $this->script_handle; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $script_handle |
|
99 | - */ |
|
100 | - public function setScriptHandle($script_handle) |
|
101 | - { |
|
102 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | - } |
|
105 | - $this->script_handle = $script_handle; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getStyleHandle() |
|
113 | - { |
|
114 | - return $this->style_handle; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $style_handle |
|
120 | - */ |
|
121 | - public function setStyleHandle($style_handle) |
|
122 | - { |
|
123 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | - } |
|
126 | - $this->style_handle = $style_handle; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @since $VID:$ |
|
131 | - * @throws InvalidDataTypeException |
|
132 | - * @throws InvalidEntityException |
|
133 | - * @throws DuplicateCollectionIdentifierException |
|
134 | - */ |
|
135 | - public function addAssets() |
|
136 | - { |
|
137 | - $this->addEditorScript($this->getEditorScriptHandle()); |
|
138 | - $this->addEditorStyle($this->getEditorStyleHandle()); |
|
139 | - $this->setScriptHandle($this->getScriptHandle()); |
|
140 | - $this->setStyleHandle($this->getStyleHandle()); |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param $handle |
|
146 | - * @param array $dependencies |
|
147 | - * @since $VID:$ |
|
148 | - * @return JavascriptAsset |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidEntityException |
|
151 | - * @throws DuplicateCollectionIdentifierException |
|
152 | - */ |
|
153 | - public function addEditorScript($handle, array $dependencies = array()) |
|
154 | - { |
|
155 | - if($this->assets->hasJavascriptAsset($handle)){ |
|
156 | - return $this->assets->getJavascriptAsset($handle); |
|
157 | - } |
|
158 | - return parent::addJavascript( |
|
159 | - $handle, |
|
160 | - $this->registry->getJsUrl( |
|
161 | - $this->domain->assetNamespace(), |
|
162 | - $handle |
|
163 | - ), |
|
164 | - $this->addDefaultBlockScriptDependencies($dependencies) |
|
165 | - ) |
|
166 | - ->setRequiresTranslation(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param $handle |
|
172 | - * @param array $dependencies |
|
173 | - * @since $VID:$ |
|
174 | - * @return StylesheetAsset |
|
175 | - * @throws InvalidDataTypeException |
|
176 | - * @throws InvalidEntityException |
|
177 | - * @throws DuplicateCollectionIdentifierException |
|
178 | - */ |
|
179 | - public function addEditorStyle($handle, array $dependencies = array()) |
|
180 | - { |
|
181 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
182 | - return $this->assets->getStylesheetAsset($handle); |
|
183 | - } |
|
184 | - return parent::addStylesheet( |
|
185 | - $handle, |
|
186 | - $this->registry->getCssUrl( |
|
187 | - $this->domain->assetNamespace(), |
|
188 | - $handle |
|
189 | - ), |
|
190 | - $this->addDefaultBlockStyleDependencies($dependencies) |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * @param $handle |
|
197 | - * @param array $dependencies |
|
198 | - * @since $VID:$ |
|
199 | - * @return JavascriptAsset |
|
200 | - * @throws InvalidDataTypeException |
|
201 | - * @throws InvalidEntityException |
|
202 | - * @throws DuplicateCollectionIdentifierException |
|
203 | - */ |
|
204 | - public function addScript($handle, array $dependencies = array()) |
|
205 | - { |
|
206 | - if ($this->assets->hasJavascriptAsset($handle)) { |
|
207 | - return $this->assets->getJavascriptAsset($handle); |
|
208 | - } |
|
209 | - return parent::addJavascript( |
|
210 | - $handle, |
|
211 | - $this->registry->getJsUrl( |
|
212 | - $this->domain->assetNamespace(), |
|
213 | - $handle |
|
214 | - ), |
|
215 | - $dependencies |
|
216 | - ) |
|
217 | - ->setRequiresTranslation(); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @param $handle |
|
223 | - * @param array $dependencies |
|
224 | - * @since $VID:$ |
|
225 | - * @return StylesheetAsset |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - * @throws InvalidEntityException |
|
228 | - * @throws DuplicateCollectionIdentifierException |
|
229 | - */ |
|
230 | - public function addStyle($handle, array $dependencies = array()) |
|
231 | - { |
|
232 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
233 | - return $this->assets->getStylesheetAsset($handle); |
|
234 | - } |
|
235 | - return parent::addStylesheet( |
|
236 | - $handle, |
|
237 | - $this->registry->getCssUrl( |
|
238 | - $this->domain->assetNamespace(), |
|
239 | - $handle |
|
240 | - ), |
|
241 | - $dependencies |
|
242 | - ); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param array $dependencies |
|
248 | - * @return array |
|
249 | - */ |
|
250 | - protected function addDefaultBlockScriptDependencies(array $dependencies) |
|
251 | - { |
|
252 | - $dependencies += array( |
|
253 | - 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | - 'wp-i18n', // Provides localization functions |
|
255 | - 'wp-element', // Provides React.Component |
|
256 | - 'wp-components', // Provides many prebuilt components and controls |
|
257 | - CoreAssetManager::JS_HANDLE_EE_COMPONENTS |
|
258 | - ); |
|
259 | - return $dependencies; |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * @param array $dependencies |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
268 | - { |
|
269 | - $dependencies += array( |
|
270 | - CoreAssetManager::CSS_HANDLE_EE_COMPONENTS, |
|
271 | - ); |
|
272 | - return $dependencies; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return JavascriptAsset|null |
|
278 | - */ |
|
279 | - public function getEditorScript() |
|
280 | - { |
|
281 | - return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @return StylesheetAsset|null |
|
287 | - */ |
|
288 | - public function getEditorStyle() |
|
289 | - { |
|
290 | - return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @return JavascriptAsset|null |
|
296 | - */ |
|
297 | - public function getScript() |
|
298 | - { |
|
299 | - return $this->assets->getJavascriptAsset($this->script_handle); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * @return StylesheetAsset|null |
|
305 | - */ |
|
306 | - public function getStyle() |
|
307 | - { |
|
308 | - return $this->assets->getStylesheetAsset($this->style_handle); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * @return void |
|
314 | - */ |
|
315 | - public function enqueueAssets() |
|
316 | - { |
|
317 | - $assets = array( |
|
318 | - $this->getEditorScript(), |
|
319 | - $this->getEditorStyle(), |
|
320 | - $this->getScript(), |
|
321 | - $this->getStyle(), |
|
322 | - ); |
|
323 | - foreach ($assets as $asset) { |
|
324 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
325 | - $asset->enqueueAsset(); |
|
326 | - } |
|
327 | - } |
|
328 | - } |
|
25 | + /** |
|
26 | + * @var string $editor_script_handle |
|
27 | + */ |
|
28 | + private $editor_script_handle; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $editor_style_handle |
|
32 | + */ |
|
33 | + private $editor_style_handle; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $script_handle |
|
37 | + */ |
|
38 | + private $script_handle; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $style_handle |
|
42 | + */ |
|
43 | + private $style_handle; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getEditorScriptHandle() |
|
50 | + { |
|
51 | + return $this->editor_script_handle; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $editor_script_handle |
|
57 | + */ |
|
58 | + public function setEditorScriptHandle($editor_script_handle) |
|
59 | + { |
|
60 | + if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | + $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | + } |
|
63 | + $this->editor_script_handle = $editor_script_handle; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function getEditorStyleHandle() |
|
71 | + { |
|
72 | + return $this->editor_style_handle; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $editor_style_handle |
|
78 | + */ |
|
79 | + public function setEditorStyleHandle($editor_style_handle) |
|
80 | + { |
|
81 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | + $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | + } |
|
84 | + $this->editor_style_handle = $editor_style_handle; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getScriptHandle() |
|
92 | + { |
|
93 | + return $this->script_handle; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $script_handle |
|
99 | + */ |
|
100 | + public function setScriptHandle($script_handle) |
|
101 | + { |
|
102 | + if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | + $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | + } |
|
105 | + $this->script_handle = $script_handle; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getStyleHandle() |
|
113 | + { |
|
114 | + return $this->style_handle; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $style_handle |
|
120 | + */ |
|
121 | + public function setStyleHandle($style_handle) |
|
122 | + { |
|
123 | + if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | + $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | + } |
|
126 | + $this->style_handle = $style_handle; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @since $VID:$ |
|
131 | + * @throws InvalidDataTypeException |
|
132 | + * @throws InvalidEntityException |
|
133 | + * @throws DuplicateCollectionIdentifierException |
|
134 | + */ |
|
135 | + public function addAssets() |
|
136 | + { |
|
137 | + $this->addEditorScript($this->getEditorScriptHandle()); |
|
138 | + $this->addEditorStyle($this->getEditorStyleHandle()); |
|
139 | + $this->setScriptHandle($this->getScriptHandle()); |
|
140 | + $this->setStyleHandle($this->getStyleHandle()); |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param $handle |
|
146 | + * @param array $dependencies |
|
147 | + * @since $VID:$ |
|
148 | + * @return JavascriptAsset |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidEntityException |
|
151 | + * @throws DuplicateCollectionIdentifierException |
|
152 | + */ |
|
153 | + public function addEditorScript($handle, array $dependencies = array()) |
|
154 | + { |
|
155 | + if($this->assets->hasJavascriptAsset($handle)){ |
|
156 | + return $this->assets->getJavascriptAsset($handle); |
|
157 | + } |
|
158 | + return parent::addJavascript( |
|
159 | + $handle, |
|
160 | + $this->registry->getJsUrl( |
|
161 | + $this->domain->assetNamespace(), |
|
162 | + $handle |
|
163 | + ), |
|
164 | + $this->addDefaultBlockScriptDependencies($dependencies) |
|
165 | + ) |
|
166 | + ->setRequiresTranslation(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param $handle |
|
172 | + * @param array $dependencies |
|
173 | + * @since $VID:$ |
|
174 | + * @return StylesheetAsset |
|
175 | + * @throws InvalidDataTypeException |
|
176 | + * @throws InvalidEntityException |
|
177 | + * @throws DuplicateCollectionIdentifierException |
|
178 | + */ |
|
179 | + public function addEditorStyle($handle, array $dependencies = array()) |
|
180 | + { |
|
181 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
182 | + return $this->assets->getStylesheetAsset($handle); |
|
183 | + } |
|
184 | + return parent::addStylesheet( |
|
185 | + $handle, |
|
186 | + $this->registry->getCssUrl( |
|
187 | + $this->domain->assetNamespace(), |
|
188 | + $handle |
|
189 | + ), |
|
190 | + $this->addDefaultBlockStyleDependencies($dependencies) |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * @param $handle |
|
197 | + * @param array $dependencies |
|
198 | + * @since $VID:$ |
|
199 | + * @return JavascriptAsset |
|
200 | + * @throws InvalidDataTypeException |
|
201 | + * @throws InvalidEntityException |
|
202 | + * @throws DuplicateCollectionIdentifierException |
|
203 | + */ |
|
204 | + public function addScript($handle, array $dependencies = array()) |
|
205 | + { |
|
206 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
207 | + return $this->assets->getJavascriptAsset($handle); |
|
208 | + } |
|
209 | + return parent::addJavascript( |
|
210 | + $handle, |
|
211 | + $this->registry->getJsUrl( |
|
212 | + $this->domain->assetNamespace(), |
|
213 | + $handle |
|
214 | + ), |
|
215 | + $dependencies |
|
216 | + ) |
|
217 | + ->setRequiresTranslation(); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @param $handle |
|
223 | + * @param array $dependencies |
|
224 | + * @since $VID:$ |
|
225 | + * @return StylesheetAsset |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + * @throws InvalidEntityException |
|
228 | + * @throws DuplicateCollectionIdentifierException |
|
229 | + */ |
|
230 | + public function addStyle($handle, array $dependencies = array()) |
|
231 | + { |
|
232 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
233 | + return $this->assets->getStylesheetAsset($handle); |
|
234 | + } |
|
235 | + return parent::addStylesheet( |
|
236 | + $handle, |
|
237 | + $this->registry->getCssUrl( |
|
238 | + $this->domain->assetNamespace(), |
|
239 | + $handle |
|
240 | + ), |
|
241 | + $dependencies |
|
242 | + ); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param array $dependencies |
|
248 | + * @return array |
|
249 | + */ |
|
250 | + protected function addDefaultBlockScriptDependencies(array $dependencies) |
|
251 | + { |
|
252 | + $dependencies += array( |
|
253 | + 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | + 'wp-i18n', // Provides localization functions |
|
255 | + 'wp-element', // Provides React.Component |
|
256 | + 'wp-components', // Provides many prebuilt components and controls |
|
257 | + CoreAssetManager::JS_HANDLE_EE_COMPONENTS |
|
258 | + ); |
|
259 | + return $dependencies; |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * @param array $dependencies |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
268 | + { |
|
269 | + $dependencies += array( |
|
270 | + CoreAssetManager::CSS_HANDLE_EE_COMPONENTS, |
|
271 | + ); |
|
272 | + return $dependencies; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return JavascriptAsset|null |
|
278 | + */ |
|
279 | + public function getEditorScript() |
|
280 | + { |
|
281 | + return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @return StylesheetAsset|null |
|
287 | + */ |
|
288 | + public function getEditorStyle() |
|
289 | + { |
|
290 | + return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @return JavascriptAsset|null |
|
296 | + */ |
|
297 | + public function getScript() |
|
298 | + { |
|
299 | + return $this->assets->getJavascriptAsset($this->script_handle); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * @return StylesheetAsset|null |
|
305 | + */ |
|
306 | + public function getStyle() |
|
307 | + { |
|
308 | + return $this->assets->getStylesheetAsset($this->style_handle); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * @return void |
|
314 | + */ |
|
315 | + public function enqueueAssets() |
|
316 | + { |
|
317 | + $assets = array( |
|
318 | + $this->getEditorScript(), |
|
319 | + $this->getEditorStyle(), |
|
320 | + $this->getScript(), |
|
321 | + $this->getStyle(), |
|
322 | + ); |
|
323 | + foreach ($assets as $asset) { |
|
324 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
325 | + $asset->enqueueAsset(); |
|
326 | + } |
|
327 | + } |
|
328 | + } |
|
329 | 329 | |
330 | 330 | } |
@@ -24,236 +24,236 @@ |
||
24 | 24 | class EventAttendees extends Block |
25 | 25 | { |
26 | 26 | |
27 | - const BLOCK_TYPE = 'event-attendees'; |
|
27 | + const BLOCK_TYPE = 'event-attendees'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var EspressoEventAttendees $shortcode |
|
31 | - */ |
|
32 | - protected $shortcode; |
|
29 | + /** |
|
30 | + * @var EspressoEventAttendees $shortcode |
|
31 | + */ |
|
32 | + protected $shortcode; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * EventAttendees constructor. |
|
37 | - * |
|
38 | - * @param CoreBlocksAssetManager $block_asset_manager |
|
39 | - * @param RequestInterface $request |
|
40 | - * @param EspressoEventAttendees $shortcode |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - CoreBlocksAssetManager $block_asset_manager, |
|
44 | - RequestInterface $request, |
|
45 | - EspressoEventAttendees $shortcode |
|
46 | - ) { |
|
47 | - parent::__construct($block_asset_manager, $request); |
|
48 | - $this->shortcode = $shortcode; |
|
49 | - } |
|
35 | + /** |
|
36 | + * EventAttendees constructor. |
|
37 | + * |
|
38 | + * @param CoreBlocksAssetManager $block_asset_manager |
|
39 | + * @param RequestInterface $request |
|
40 | + * @param EspressoEventAttendees $shortcode |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + CoreBlocksAssetManager $block_asset_manager, |
|
44 | + RequestInterface $request, |
|
45 | + EspressoEventAttendees $shortcode |
|
46 | + ) { |
|
47 | + parent::__construct($block_asset_manager, $request); |
|
48 | + $this->shortcode = $shortcode; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Perform any early setup required by the block |
|
54 | - * including setting the block type and supported post types |
|
55 | - * |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function initialize() |
|
59 | - { |
|
60 | - $this->setBlockType(self::BLOCK_TYPE); |
|
61 | - $this->setSupportedRoutes( |
|
62 | - array( |
|
63 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor', |
|
64 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor', |
|
65 | - 'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer', |
|
66 | - 'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest' |
|
67 | - ) |
|
68 | - ); |
|
69 | - $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
70 | - ? $this->request->getRequestParam('post', 0) |
|
71 | - : 0; |
|
72 | - $this->setAttributes( |
|
73 | - array( |
|
74 | - 'eventId' => array( |
|
75 | - 'type' => 'number', |
|
76 | - 'default' => $EVT_ID, |
|
77 | - ), |
|
78 | - 'datetimeId' => array( |
|
79 | - 'type' => 'number', |
|
80 | - 'default' => 0, |
|
81 | - ), |
|
82 | - 'ticketId' => array( |
|
83 | - 'type' => 'number', |
|
84 | - 'default' => 0, |
|
85 | - ), |
|
86 | - 'status' => array( |
|
87 | - 'type' => 'string', |
|
88 | - 'default' => EEM_Registration::status_id_approved, |
|
89 | - ), |
|
90 | - 'limit' => array( |
|
91 | - 'type' => 'number', |
|
92 | - 'default' => 10, |
|
93 | - ), |
|
94 | - 'showGravatar' => array( |
|
95 | - 'type' => 'boolean', |
|
96 | - 'default' => false, |
|
97 | - ), |
|
98 | - 'avatarClass' => array( |
|
99 | - 'type' => 'string', |
|
100 | - 'default' => 'contact', |
|
101 | - ), |
|
102 | - 'avatarSize' => array( |
|
103 | - 'type' => 'number', |
|
104 | - 'default' => 24, |
|
105 | - ), |
|
106 | - 'displayOnArchives' => array( |
|
107 | - 'type' => 'boolean', |
|
108 | - 'default' => false, |
|
109 | - ), |
|
110 | - ) |
|
111 | - ); |
|
112 | - $this->setDynamic(); |
|
113 | - } |
|
52 | + /** |
|
53 | + * Perform any early setup required by the block |
|
54 | + * including setting the block type and supported post types |
|
55 | + * |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function initialize() |
|
59 | + { |
|
60 | + $this->setBlockType(self::BLOCK_TYPE); |
|
61 | + $this->setSupportedRoutes( |
|
62 | + array( |
|
63 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor', |
|
64 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor', |
|
65 | + 'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer', |
|
66 | + 'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest' |
|
67 | + ) |
|
68 | + ); |
|
69 | + $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
70 | + ? $this->request->getRequestParam('post', 0) |
|
71 | + : 0; |
|
72 | + $this->setAttributes( |
|
73 | + array( |
|
74 | + 'eventId' => array( |
|
75 | + 'type' => 'number', |
|
76 | + 'default' => $EVT_ID, |
|
77 | + ), |
|
78 | + 'datetimeId' => array( |
|
79 | + 'type' => 'number', |
|
80 | + 'default' => 0, |
|
81 | + ), |
|
82 | + 'ticketId' => array( |
|
83 | + 'type' => 'number', |
|
84 | + 'default' => 0, |
|
85 | + ), |
|
86 | + 'status' => array( |
|
87 | + 'type' => 'string', |
|
88 | + 'default' => EEM_Registration::status_id_approved, |
|
89 | + ), |
|
90 | + 'limit' => array( |
|
91 | + 'type' => 'number', |
|
92 | + 'default' => 10, |
|
93 | + ), |
|
94 | + 'showGravatar' => array( |
|
95 | + 'type' => 'boolean', |
|
96 | + 'default' => false, |
|
97 | + ), |
|
98 | + 'avatarClass' => array( |
|
99 | + 'type' => 'string', |
|
100 | + 'default' => 'contact', |
|
101 | + ), |
|
102 | + 'avatarSize' => array( |
|
103 | + 'type' => 'number', |
|
104 | + 'default' => 24, |
|
105 | + ), |
|
106 | + 'displayOnArchives' => array( |
|
107 | + 'type' => 'boolean', |
|
108 | + 'default' => false, |
|
109 | + ), |
|
110 | + ) |
|
111 | + ); |
|
112 | + $this->setDynamic(); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * returns an array where the key corresponds to the incoming attribute name from the WP block |
|
118 | - * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
119 | - * |
|
120 | - * @since $VID:$ |
|
121 | - * @return array |
|
122 | - */ |
|
123 | - private function getAttributesMap() |
|
124 | - { |
|
125 | - return array( |
|
126 | - 'eventId' => array('attribute' => 'event_id', 'sanitize' => 'absint'), |
|
127 | - 'datetimeId' => array('attribute' => 'datetime_id', 'sanitize' => 'absint'), |
|
128 | - 'ticketId' => array('attribute' => 'ticket_id', 'sanitize' => 'absint'), |
|
129 | - 'status' => array('attribute' => 'status', 'sanitize' => 'sanitize_text_field'), |
|
130 | - 'limit' => array('attribute' => 'limit', 'sanitize' => 'intval'), |
|
131 | - 'showGravatar' => array('attribute' => 'show_gravatar', 'sanitize' => 'bool'), |
|
132 | - 'avatarClass' => array('attribute' => 'avatar_class', 'sanitize' => 'sanitize_text_field' ), |
|
133 | - 'avatarSize' => array('attribute' => 'avatar_size', 'sanitize' => 'absint' ), |
|
134 | - 'displayOnArchives' => array('attribute' => 'display_on_archives', 'sanitize' => 'bool'), |
|
135 | - ); |
|
136 | - } |
|
116 | + /** |
|
117 | + * returns an array where the key corresponds to the incoming attribute name from the WP block |
|
118 | + * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
119 | + * |
|
120 | + * @since $VID:$ |
|
121 | + * @return array |
|
122 | + */ |
|
123 | + private function getAttributesMap() |
|
124 | + { |
|
125 | + return array( |
|
126 | + 'eventId' => array('attribute' => 'event_id', 'sanitize' => 'absint'), |
|
127 | + 'datetimeId' => array('attribute' => 'datetime_id', 'sanitize' => 'absint'), |
|
128 | + 'ticketId' => array('attribute' => 'ticket_id', 'sanitize' => 'absint'), |
|
129 | + 'status' => array('attribute' => 'status', 'sanitize' => 'sanitize_text_field'), |
|
130 | + 'limit' => array('attribute' => 'limit', 'sanitize' => 'intval'), |
|
131 | + 'showGravatar' => array('attribute' => 'show_gravatar', 'sanitize' => 'bool'), |
|
132 | + 'avatarClass' => array('attribute' => 'avatar_class', 'sanitize' => 'sanitize_text_field' ), |
|
133 | + 'avatarSize' => array('attribute' => 'avatar_size', 'sanitize' => 'absint' ), |
|
134 | + 'displayOnArchives' => array('attribute' => 'display_on_archives', 'sanitize' => 'bool'), |
|
135 | + ); |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * @param array $attributes |
|
141 | - * @since $VID:$ |
|
142 | - * @return array |
|
143 | - */ |
|
144 | - private function parseAttributes(array $attributes) |
|
145 | - { |
|
146 | - foreach ($attributes as $attribute => $value) { |
|
147 | - $convert = $this->getAttributesMap(); |
|
148 | - if (isset($convert[ $attribute ])) { |
|
149 | - $sanitize = $convert[ $attribute ]['sanitize']; |
|
150 | - $converted_attribute_key = $convert[ $attribute ]['attribute']; |
|
151 | - if ($sanitize === 'bool') { |
|
152 | - $attributes[ $converted_attribute_key ] = filter_var( |
|
153 | - $value, |
|
154 | - FILTER_VALIDATE_BOOLEAN |
|
155 | - ); |
|
156 | - } else { |
|
157 | - $attributes[ $converted_attribute_key ] = $sanitize($value); |
|
158 | - } |
|
159 | - if ($attribute !== $converted_attribute_key) { |
|
160 | - unset($attributes[ $attribute ]); |
|
161 | - } |
|
162 | - // don't pass along attributes with a 0 value |
|
163 | - if ($attributes[ $converted_attribute_key ] === 0) { |
|
164 | - unset($attributes[ $converted_attribute_key ]); |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - return $attributes; |
|
169 | - } |
|
139 | + /** |
|
140 | + * @param array $attributes |
|
141 | + * @since $VID:$ |
|
142 | + * @return array |
|
143 | + */ |
|
144 | + private function parseAttributes(array $attributes) |
|
145 | + { |
|
146 | + foreach ($attributes as $attribute => $value) { |
|
147 | + $convert = $this->getAttributesMap(); |
|
148 | + if (isset($convert[ $attribute ])) { |
|
149 | + $sanitize = $convert[ $attribute ]['sanitize']; |
|
150 | + $converted_attribute_key = $convert[ $attribute ]['attribute']; |
|
151 | + if ($sanitize === 'bool') { |
|
152 | + $attributes[ $converted_attribute_key ] = filter_var( |
|
153 | + $value, |
|
154 | + FILTER_VALIDATE_BOOLEAN |
|
155 | + ); |
|
156 | + } else { |
|
157 | + $attributes[ $converted_attribute_key ] = $sanitize($value); |
|
158 | + } |
|
159 | + if ($attribute !== $converted_attribute_key) { |
|
160 | + unset($attributes[ $attribute ]); |
|
161 | + } |
|
162 | + // don't pass along attributes with a 0 value |
|
163 | + if ($attributes[ $converted_attribute_key ] === 0) { |
|
164 | + unset($attributes[ $converted_attribute_key ]); |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + return $attributes; |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | - /** |
|
173 | - * This ensures we're only sending along the needed attribute for grabbing attendees. |
|
174 | - * In order: |
|
175 | - * |
|
176 | - * - if ticket_id is present then datetime or event id are unneeded. |
|
177 | - * - if datetime_id is present than event_id is not needed. |
|
178 | - * |
|
179 | - * @param array $attributes |
|
180 | - * @return array |
|
181 | - */ |
|
182 | - private function includeNecessaryOnly(array $attributes) |
|
183 | - { |
|
184 | - if ($attributes['ticket_id'] > 0) { |
|
185 | - unset($attributes['event_id'], $attributes['datetime_id']); |
|
186 | - } |
|
187 | - if ($attributes['datetime_id'] > 0) { |
|
188 | - unset($attributes['event_id']); |
|
189 | - } |
|
190 | - return $attributes; |
|
191 | - } |
|
172 | + /** |
|
173 | + * This ensures we're only sending along the needed attribute for grabbing attendees. |
|
174 | + * In order: |
|
175 | + * |
|
176 | + * - if ticket_id is present then datetime or event id are unneeded. |
|
177 | + * - if datetime_id is present than event_id is not needed. |
|
178 | + * |
|
179 | + * @param array $attributes |
|
180 | + * @return array |
|
181 | + */ |
|
182 | + private function includeNecessaryOnly(array $attributes) |
|
183 | + { |
|
184 | + if ($attributes['ticket_id'] > 0) { |
|
185 | + unset($attributes['event_id'], $attributes['datetime_id']); |
|
186 | + } |
|
187 | + if ($attributes['datetime_id'] > 0) { |
|
188 | + unset($attributes['event_id']); |
|
189 | + } |
|
190 | + return $attributes; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * Returns true when there are no id values in the attributes. |
|
196 | - * |
|
197 | - * @param array $attributes |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - private function hasNoIds(array $attributes) |
|
201 | - { |
|
202 | - return empty($attributes['event_id']) && empty($attributes['datetime_id']) && empty($attributes['ticket_id']); |
|
203 | - } |
|
194 | + /** |
|
195 | + * Returns true when there are no id values in the attributes. |
|
196 | + * |
|
197 | + * @param array $attributes |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + private function hasNoIds(array $attributes) |
|
201 | + { |
|
202 | + return empty($attributes['event_id']) && empty($attributes['datetime_id']) && empty($attributes['ticket_id']); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Returns the rendered HTML for the block |
|
207 | - * |
|
208 | - * @param array $attributes |
|
209 | - * @return string |
|
210 | - * @throws EE_Error |
|
211 | - * @throws InvalidDataTypeException |
|
212 | - * @throws InvalidInterfaceException |
|
213 | - * @throws InvalidArgumentException |
|
214 | - * @throws DomainException |
|
215 | - */ |
|
216 | - public function renderBlock(array $attributes = array()) |
|
217 | - { |
|
218 | - $attributes = $this->includeNecessaryOnly($this->parseAttributes($attributes)); |
|
219 | - $rendered_content = $this->shortcode->processShortcode($attributes); |
|
220 | - if (empty($rendered_content)) { |
|
221 | - return $this->noContentRender($attributes); |
|
222 | - } |
|
223 | - if ($this->hasNoIds($attributes) && $this->request->isWordPressApi()) { |
|
224 | - $rendered_content = '<div class="components-notice is-success"><p>' . esc_html__( |
|
225 | - 'The content displayed is for the most recent active or upcoming event. You can display attendees from a different event, ticket or datetime via the block settings.', |
|
226 | - 'event_espresso' |
|
227 | - ) . '</p></div>' . $rendered_content; |
|
228 | - } |
|
229 | - return $rendered_content; |
|
230 | - } |
|
205 | + /** |
|
206 | + * Returns the rendered HTML for the block |
|
207 | + * |
|
208 | + * @param array $attributes |
|
209 | + * @return string |
|
210 | + * @throws EE_Error |
|
211 | + * @throws InvalidDataTypeException |
|
212 | + * @throws InvalidInterfaceException |
|
213 | + * @throws InvalidArgumentException |
|
214 | + * @throws DomainException |
|
215 | + */ |
|
216 | + public function renderBlock(array $attributes = array()) |
|
217 | + { |
|
218 | + $attributes = $this->includeNecessaryOnly($this->parseAttributes($attributes)); |
|
219 | + $rendered_content = $this->shortcode->processShortcode($attributes); |
|
220 | + if (empty($rendered_content)) { |
|
221 | + return $this->noContentRender($attributes); |
|
222 | + } |
|
223 | + if ($this->hasNoIds($attributes) && $this->request->isWordPressApi()) { |
|
224 | + $rendered_content = '<div class="components-notice is-success"><p>' . esc_html__( |
|
225 | + 'The content displayed is for the most recent active or upcoming event. You can display attendees from a different event, ticket or datetime via the block settings.', |
|
226 | + 'event_espresso' |
|
227 | + ) . '</p></div>' . $rendered_content; |
|
228 | + } |
|
229 | + return $rendered_content; |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * Returns rendered content for block when there is no content for rendering due to various conditions. |
|
235 | - * This content ONLY appears in the editor context. |
|
236 | - * |
|
237 | - * @param array $attributes |
|
238 | - * @return string |
|
239 | - */ |
|
240 | - private function noContentRender(array $attributes) |
|
241 | - { |
|
242 | - $content = ''; |
|
243 | - if ($this->request->isWordPressApi()) { |
|
244 | - if (empty($attributes['event_id'])) { |
|
245 | - $content .= esc_html__( |
|
246 | - 'There are no active or selected events to pull attendees from at this moment. This message only appears in the editor.', |
|
247 | - 'event_espresso' |
|
248 | - ); |
|
249 | - } else { |
|
250 | - $content .= esc_html__( |
|
251 | - 'There was a problem displaying the content for the selected options. This message only appears in the editor.', |
|
252 | - 'event_espresso' |
|
253 | - ); |
|
254 | - } |
|
255 | - $content = $content !== '' ? '<div class="components-notice is-error"><p>' . $content . '</p></div>' : $content; |
|
256 | - } |
|
257 | - return $content; |
|
258 | - } |
|
233 | + /** |
|
234 | + * Returns rendered content for block when there is no content for rendering due to various conditions. |
|
235 | + * This content ONLY appears in the editor context. |
|
236 | + * |
|
237 | + * @param array $attributes |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + private function noContentRender(array $attributes) |
|
241 | + { |
|
242 | + $content = ''; |
|
243 | + if ($this->request->isWordPressApi()) { |
|
244 | + if (empty($attributes['event_id'])) { |
|
245 | + $content .= esc_html__( |
|
246 | + 'There are no active or selected events to pull attendees from at this moment. This message only appears in the editor.', |
|
247 | + 'event_espresso' |
|
248 | + ); |
|
249 | + } else { |
|
250 | + $content .= esc_html__( |
|
251 | + 'There was a problem displaying the content for the selected options. This message only appears in the editor.', |
|
252 | + 'event_espresso' |
|
253 | + ); |
|
254 | + } |
|
255 | + $content = $content !== '' ? '<div class="components-notice is-error"><p>' . $content . '</p></div>' : $content; |
|
256 | + } |
|
257 | + return $content; |
|
258 | + } |
|
259 | 259 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | 'status' => array('attribute' => 'status', 'sanitize' => 'sanitize_text_field'), |
130 | 130 | 'limit' => array('attribute' => 'limit', 'sanitize' => 'intval'), |
131 | 131 | 'showGravatar' => array('attribute' => 'show_gravatar', 'sanitize' => 'bool'), |
132 | - 'avatarClass' => array('attribute' => 'avatar_class', 'sanitize' => 'sanitize_text_field' ), |
|
133 | - 'avatarSize' => array('attribute' => 'avatar_size', 'sanitize' => 'absint' ), |
|
132 | + 'avatarClass' => array('attribute' => 'avatar_class', 'sanitize' => 'sanitize_text_field'), |
|
133 | + 'avatarSize' => array('attribute' => 'avatar_size', 'sanitize' => 'absint'), |
|
134 | 134 | 'displayOnArchives' => array('attribute' => 'display_on_archives', 'sanitize' => 'bool'), |
135 | 135 | ); |
136 | 136 | } |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | { |
146 | 146 | foreach ($attributes as $attribute => $value) { |
147 | 147 | $convert = $this->getAttributesMap(); |
148 | - if (isset($convert[ $attribute ])) { |
|
149 | - $sanitize = $convert[ $attribute ]['sanitize']; |
|
150 | - $converted_attribute_key = $convert[ $attribute ]['attribute']; |
|
148 | + if (isset($convert[$attribute])) { |
|
149 | + $sanitize = $convert[$attribute]['sanitize']; |
|
150 | + $converted_attribute_key = $convert[$attribute]['attribute']; |
|
151 | 151 | if ($sanitize === 'bool') { |
152 | - $attributes[ $converted_attribute_key ] = filter_var( |
|
152 | + $attributes[$converted_attribute_key] = filter_var( |
|
153 | 153 | $value, |
154 | 154 | FILTER_VALIDATE_BOOLEAN |
155 | 155 | ); |
156 | 156 | } else { |
157 | - $attributes[ $converted_attribute_key ] = $sanitize($value); |
|
157 | + $attributes[$converted_attribute_key] = $sanitize($value); |
|
158 | 158 | } |
159 | 159 | if ($attribute !== $converted_attribute_key) { |
160 | - unset($attributes[ $attribute ]); |
|
160 | + unset($attributes[$attribute]); |
|
161 | 161 | } |
162 | 162 | // don't pass along attributes with a 0 value |
163 | - if ($attributes[ $converted_attribute_key ] === 0) { |
|
164 | - unset($attributes[ $converted_attribute_key ]); |
|
163 | + if ($attributes[$converted_attribute_key] === 0) { |
|
164 | + unset($attributes[$converted_attribute_key]); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | return $this->noContentRender($attributes); |
222 | 222 | } |
223 | 223 | if ($this->hasNoIds($attributes) && $this->request->isWordPressApi()) { |
224 | - $rendered_content = '<div class="components-notice is-success"><p>' . esc_html__( |
|
224 | + $rendered_content = '<div class="components-notice is-success"><p>'.esc_html__( |
|
225 | 225 | 'The content displayed is for the most recent active or upcoming event. You can display attendees from a different event, ticket or datetime via the block settings.', |
226 | 226 | 'event_espresso' |
227 | - ) . '</p></div>' . $rendered_content; |
|
227 | + ).'</p></div>'.$rendered_content; |
|
228 | 228 | } |
229 | 229 | return $rendered_content; |
230 | 230 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | 'event_espresso' |
253 | 253 | ); |
254 | 254 | } |
255 | - $content = $content !== '' ? '<div class="components-notice is-error"><p>' . $content . '</p></div>' : $content; |
|
255 | + $content = $content !== '' ? '<div class="components-notice is-error"><p>'.$content.'</p></div>' : $content; |
|
256 | 256 | } |
257 | 257 | return $content; |
258 | 258 | } |
@@ -17,43 +17,43 @@ |
||
17 | 17 | class Attendee extends AttendeeCalculationsBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $wpdb_row |
|
22 | - * @param WP_REST_Request $request |
|
23 | - * @param AttendeeControllerBase $controller |
|
24 | - * @since 4.9.66.p |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller) |
|
28 | - { |
|
29 | - if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) { |
|
30 | - $email_address = $wpdb_row['Attendee_Meta.ATT_email']; |
|
31 | - } |
|
32 | - if (empty($email_address)) { |
|
33 | - return get_avatar_url('', array('default' => 'mm', 'force_default' => true)); |
|
34 | - } |
|
35 | - $avatar = get_avatar_url($email_address); |
|
36 | - return $avatar ? $avatar : ''; |
|
37 | - } |
|
20 | + /** |
|
21 | + * @param array $wpdb_row |
|
22 | + * @param WP_REST_Request $request |
|
23 | + * @param AttendeeControllerBase $controller |
|
24 | + * @since 4.9.66.p |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller) |
|
28 | + { |
|
29 | + if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) { |
|
30 | + $email_address = $wpdb_row['Attendee_Meta.ATT_email']; |
|
31 | + } |
|
32 | + if (empty($email_address)) { |
|
33 | + return get_avatar_url('', array('default' => 'mm', 'force_default' => true)); |
|
34 | + } |
|
35 | + $avatar = get_avatar_url($email_address); |
|
36 | + return $avatar ? $avatar : ''; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
42 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
43 | - * |
|
44 | - * @since 4.9.68.p |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function schemaForCalculations() |
|
48 | - { |
|
49 | - return array( |
|
50 | - 'user_avatar' => array( |
|
51 | - 'description' => esc_html__( |
|
52 | - 'The avatar url for the attendee (if available).', |
|
53 | - 'event_espresso' |
|
54 | - ), |
|
55 | - 'type' => 'string', |
|
56 | - ), |
|
57 | - ); |
|
58 | - } |
|
40 | + /** |
|
41 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
42 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
43 | + * |
|
44 | + * @since 4.9.68.p |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function schemaForCalculations() |
|
48 | + { |
|
49 | + return array( |
|
50 | + 'user_avatar' => array( |
|
51 | + 'description' => esc_html__( |
|
52 | + 'The avatar url for the attendee (if available).', |
|
53 | + 'event_espresso' |
|
54 | + ), |
|
55 | + 'type' => 'string', |
|
56 | + ), |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | } |