@@ -22,310 +22,310 @@ |
||
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->addScript($this->getScriptHandle()); |
|
140 | - $this->addStyle($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 + array( CoreAssetManager::JS_HANDLE_COMPONENTS ) |
|
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 + array( CoreAssetManager::CSS_HANDLE_COMPONENTS ) |
|
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_EDITOR_HOCS, |
|
258 | - $this->getScriptHandle(), |
|
259 | - ); |
|
260 | - return $dependencies; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * @param array $dependencies |
|
266 | - * @return array |
|
267 | - */ |
|
268 | - protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
269 | - { |
|
270 | - $dependencies += array( |
|
271 | - $this->getStyleHandle() |
|
272 | - ); |
|
273 | - return $dependencies; |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * @return JavascriptAsset|null |
|
279 | - */ |
|
280 | - public function getEditorScript() |
|
281 | - { |
|
282 | - return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @return StylesheetAsset|null |
|
288 | - */ |
|
289 | - public function getEditorStyle() |
|
290 | - { |
|
291 | - return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * @return JavascriptAsset|null |
|
297 | - */ |
|
298 | - public function getScript() |
|
299 | - { |
|
300 | - return $this->assets->getJavascriptAsset($this->script_handle); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * @return StylesheetAsset|null |
|
306 | - */ |
|
307 | - public function getStyle() |
|
308 | - { |
|
309 | - return $this->assets->getStylesheetAsset($this->style_handle); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * @return void |
|
315 | - */ |
|
316 | - public function enqueueAssets() |
|
317 | - { |
|
318 | - $assets = array( |
|
319 | - $this->getEditorScript(), |
|
320 | - $this->getEditorStyle(), |
|
321 | - $this->getScript(), |
|
322 | - $this->getStyle(), |
|
323 | - ); |
|
324 | - foreach ($assets as $asset) { |
|
325 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
326 | - $asset->enqueueAsset(); |
|
327 | - } |
|
328 | - } |
|
329 | - } |
|
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->addScript($this->getScriptHandle()); |
|
140 | + $this->addStyle($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 + array( CoreAssetManager::JS_HANDLE_COMPONENTS ) |
|
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 + array( CoreAssetManager::CSS_HANDLE_COMPONENTS ) |
|
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_EDITOR_HOCS, |
|
258 | + $this->getScriptHandle(), |
|
259 | + ); |
|
260 | + return $dependencies; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * @param array $dependencies |
|
266 | + * @return array |
|
267 | + */ |
|
268 | + protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
269 | + { |
|
270 | + $dependencies += array( |
|
271 | + $this->getStyleHandle() |
|
272 | + ); |
|
273 | + return $dependencies; |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * @return JavascriptAsset|null |
|
279 | + */ |
|
280 | + public function getEditorScript() |
|
281 | + { |
|
282 | + return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @return StylesheetAsset|null |
|
288 | + */ |
|
289 | + public function getEditorStyle() |
|
290 | + { |
|
291 | + return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * @return JavascriptAsset|null |
|
297 | + */ |
|
298 | + public function getScript() |
|
299 | + { |
|
300 | + return $this->assets->getJavascriptAsset($this->script_handle); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * @return StylesheetAsset|null |
|
306 | + */ |
|
307 | + public function getStyle() |
|
308 | + { |
|
309 | + return $this->assets->getStylesheetAsset($this->style_handle); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * @return void |
|
315 | + */ |
|
316 | + public function enqueueAssets() |
|
317 | + { |
|
318 | + $assets = array( |
|
319 | + $this->getEditorScript(), |
|
320 | + $this->getEditorStyle(), |
|
321 | + $this->getScript(), |
|
322 | + $this->getStyle(), |
|
323 | + ); |
|
324 | + foreach ($assets as $asset) { |
|
325 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
326 | + $asset->enqueueAsset(); |
|
327 | + } |
|
328 | + } |
|
329 | + } |
|
330 | 330 | |
331 | 331 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function setEditorScriptHandle($editor_script_handle) |
59 | 59 | { |
60 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | + if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
61 | + $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle; |
|
62 | 62 | } |
63 | 63 | $this->editor_script_handle = $editor_script_handle; |
64 | 64 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function setEditorStyleHandle($editor_style_handle) |
80 | 80 | { |
81 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
82 | + $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle; |
|
83 | 83 | } |
84 | 84 | $this->editor_style_handle = $editor_style_handle; |
85 | 85 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function setScriptHandle($script_handle) |
101 | 101 | { |
102 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | + if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
103 | + $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle; |
|
104 | 104 | } |
105 | 105 | $this->script_handle = $script_handle; |
106 | 106 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function setStyleHandle($style_handle) |
122 | 122 | { |
123 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | + if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
124 | + $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle; |
|
125 | 125 | } |
126 | 126 | $this->style_handle = $style_handle; |
127 | 127 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function addEditorScript($handle, array $dependencies = array()) |
154 | 154 | { |
155 | - if($this->assets->hasJavascriptAsset($handle)){ |
|
155 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
156 | 156 | return $this->assets->getJavascriptAsset($handle); |
157 | 157 | } |
158 | 158 | return parent::addJavascript( |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $this->domain->assetNamespace(), |
213 | 213 | $handle |
214 | 214 | ), |
215 | - $dependencies + array( CoreAssetManager::JS_HANDLE_COMPONENTS ) |
|
215 | + $dependencies + array(CoreAssetManager::JS_HANDLE_COMPONENTS) |
|
216 | 216 | ) |
217 | 217 | ->setRequiresTranslation(); |
218 | 218 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $this->domain->assetNamespace(), |
239 | 239 | $handle |
240 | 240 | ), |
241 | - $dependencies + array( CoreAssetManager::CSS_HANDLE_COMPONENTS ) |
|
241 | + $dependencies + array(CoreAssetManager::CSS_HANDLE_COMPONENTS) |
|
242 | 242 | ); |
243 | 243 | } |
244 | 244 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | protected function addDefaultBlockScriptDependencies(array $dependencies) |
251 | 251 | { |
252 | 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 |
|
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 | 256 | 'wp-components', // Provides many prebuilt components and controls |
257 | 257 | CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
258 | 258 | $this->getScriptHandle(), |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | |
331 | 331 | $this->addJavascript( |
332 | 332 | CoreAssetManager::JS_HANDLE_CORE, |
333 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
333 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
334 | 334 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
335 | 335 | ) |
336 | 336 | ->setInlineDataCallback( |
337 | - function () { |
|
337 | + function() { |
|
338 | 338 | wp_localize_script( |
339 | 339 | CoreAssetManager::JS_HANDLE_CORE, |
340 | 340 | CoreAssetManager::JS_HANDLE_I18N, |
@@ -438,16 +438,16 @@ discard block |
||
438 | 438 | if ($this->template_config->enable_default_style && ! is_admin()) { |
439 | 439 | $this->addStylesheet( |
440 | 440 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
441 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
441 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
442 | 442 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
443 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
443 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
444 | 444 | array('dashicons') |
445 | 445 | ); |
446 | 446 | //Load custom style sheet if available |
447 | 447 | if ($this->template_config->custom_style_sheet !== null) { |
448 | 448 | $this->addStylesheet( |
449 | 449 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
450 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
450 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
451 | 451 | array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
452 | 452 | ); |
453 | 453 | } |
@@ -475,14 +475,14 @@ discard block |
||
475 | 475 | { |
476 | 476 | $this->addJavascript( |
477 | 477 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
478 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
478 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
479 | 479 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
480 | 480 | ) |
481 | 481 | ->setVersion('1.15.0'); |
482 | 482 | |
483 | 483 | $this->addJavascript( |
484 | 484 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
485 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
485 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
486 | 486 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
487 | 487 | ) |
488 | 488 | ->setVersion('1.15.0'); |
@@ -504,18 +504,18 @@ discard block |
||
504 | 504 | // @link http://josscrowcroft.github.io/accounting.js/ |
505 | 505 | $this->addJavascript( |
506 | 506 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
507 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
507 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
508 | 508 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
509 | 509 | ) |
510 | 510 | ->setVersion('0.3.2'); |
511 | 511 | |
512 | 512 | $this->addJavascript( |
513 | 513 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
514 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
514 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
515 | 515 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
516 | 516 | ) |
517 | 517 | ->setInlineDataCallback( |
518 | - function () { |
|
518 | + function() { |
|
519 | 519 | wp_localize_script( |
520 | 520 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
521 | 521 | 'EE_ACCOUNTING_CFG', |
@@ -31,543 +31,543 @@ |
||
31 | 31 | class CoreAssetManager extends AssetManager |
32 | 32 | { |
33 | 33 | |
34 | - // WordPress core / Third party JS asset handles |
|
35 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
34 | + // WordPress core / Third party JS asset handles |
|
35 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
36 | 36 | |
37 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
37 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
38 | 38 | |
39 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
39 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
40 | 40 | |
41 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
41 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
42 | 42 | |
43 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
43 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since $VID:$ |
|
47 | - */ |
|
48 | - const JS_HANDLE_REACT = 'react'; |
|
45 | + /** |
|
46 | + * @since $VID:$ |
|
47 | + */ |
|
48 | + const JS_HANDLE_REACT = 'react'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @since $VID:$ |
|
57 | - */ |
|
58 | - const JS_HANDLE_LODASH = 'lodash'; |
|
55 | + /** |
|
56 | + * @since $VID:$ |
|
57 | + */ |
|
58 | + const JS_HANDLE_LODASH = 'lodash'; |
|
59 | 59 | |
60 | - // EE JS assets handles |
|
61 | - const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
60 | + // EE JS assets handles |
|
61 | + const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
62 | 62 | |
63 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
63 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
64 | 64 | |
65 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
65 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
66 | 66 | |
67 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
67 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
68 | 68 | |
69 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
69 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
70 | 70 | |
71 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
71 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
72 | 72 | |
73 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
73 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
74 | 74 | |
75 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
75 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
76 | 76 | |
77 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | - |
|
79 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
77 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | + |
|
79 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
80 | 80 | |
81 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
81 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
82 | 82 | |
83 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
83 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
84 | 84 | |
85 | - const JS_HANDLE_I18N = 'eei18n'; |
|
86 | - |
|
87 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | - |
|
89 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | - |
|
91 | - // EE CSS assets handles |
|
92 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | - |
|
94 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | - |
|
96 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var EE_Currency_Config $currency_config |
|
100 | - */ |
|
101 | - protected $currency_config; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var EE_Template_Config $template_config |
|
105 | - */ |
|
106 | - protected $template_config; |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * CoreAssetRegister constructor. |
|
111 | - * |
|
112 | - * @param AssetCollection $assets |
|
113 | - * @param EE_Currency_Config $currency_config |
|
114 | - * @param EE_Template_Config $template_config |
|
115 | - * @param DomainInterface $domain |
|
116 | - * @param Registry $registry |
|
117 | - */ |
|
118 | - public function __construct( |
|
119 | - AssetCollection $assets, |
|
120 | - EE_Currency_Config $currency_config, |
|
121 | - EE_Template_Config $template_config, |
|
122 | - DomainInterface $domain, |
|
123 | - Registry $registry |
|
124 | - ) { |
|
125 | - $this->currency_config = $currency_config; |
|
126 | - $this->template_config = $template_config; |
|
127 | - parent::__construct($domain, $assets, $registry); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @since 4.9.62.p |
|
133 | - * @throws DomainException |
|
134 | - * @throws DuplicateCollectionIdentifierException |
|
135 | - * @throws InvalidArgumentException |
|
136 | - * @throws InvalidDataTypeException |
|
137 | - * @throws InvalidEntityException |
|
138 | - * @throws InvalidInterfaceException |
|
139 | - */ |
|
140 | - public function addAssets() |
|
141 | - { |
|
142 | - $this->addJavascriptFiles(); |
|
143 | - $this->addStylesheetFiles(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @since 4.9.62.p |
|
149 | - * @throws DomainException |
|
150 | - * @throws DuplicateCollectionIdentifierException |
|
151 | - * @throws InvalidArgumentException |
|
152 | - * @throws InvalidDataTypeException |
|
153 | - * @throws InvalidEntityException |
|
154 | - * @throws InvalidInterfaceException |
|
155 | - */ |
|
156 | - public function addJavascriptFiles() |
|
157 | - { |
|
158 | - $this->loadCoreJs(); |
|
159 | - $this->loadJqueryValidate(); |
|
160 | - $this->loadAccountingJs(); |
|
161 | - add_action( |
|
162 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | - array($this, 'loadQtipJs') |
|
164 | - ); |
|
165 | - $this->registerAdminAssets(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @since 4.9.62.p |
|
171 | - * @throws DuplicateCollectionIdentifierException |
|
172 | - * @throws InvalidDataTypeException |
|
173 | - * @throws InvalidEntityException |
|
174 | - */ |
|
175 | - public function addStylesheetFiles() |
|
176 | - { |
|
177 | - $this->loadCoreCss(); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * core default javascript |
|
183 | - * |
|
184 | - * @since 4.9.62.p |
|
185 | - * @throws DomainException |
|
186 | - * @throws DuplicateCollectionIdentifierException |
|
187 | - * @throws InvalidArgumentException |
|
188 | - * @throws InvalidDataTypeException |
|
189 | - * @throws InvalidEntityException |
|
190 | - * @throws InvalidInterfaceException |
|
191 | - */ |
|
192 | - private function loadCoreJs() |
|
193 | - { |
|
194 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | - $this->registerWpAssets(); |
|
196 | - |
|
197 | - $this->addJavascript( |
|
198 | - CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | - ); |
|
201 | - |
|
202 | - $this->addJavascript( |
|
203 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | - array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | - ) |
|
207 | - ->setHasInlineData(); |
|
208 | - |
|
209 | - $this->addJavascript( |
|
210 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | - array( |
|
213 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | - CoreAssetManager::JS_HANDLE_REACT, |
|
215 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | - ) |
|
218 | - ); |
|
219 | - |
|
220 | - $this->addJavascript( |
|
221 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | - )->setRequiresTranslation(); |
|
224 | - |
|
225 | - $this->addJavascript( |
|
226 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | - array( |
|
229 | - CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | - ) |
|
231 | - )->setRequiresTranslation(); |
|
232 | - |
|
233 | - $this->addJavascript( |
|
234 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | - array( |
|
237 | - CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | - ) |
|
239 | - )->setRequiresTranslation(); |
|
240 | - |
|
241 | - $this->addJavascript( |
|
242 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | - array( |
|
245 | - CoreAssetManager::JS_HANDLE_MODEL |
|
246 | - ) |
|
247 | - )->setRequiresTranslation(); |
|
248 | - |
|
249 | - $this->addJavascript( |
|
250 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | - array( |
|
253 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | - 'wp-data', |
|
255 | - 'wp-api-request', |
|
256 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | - ) |
|
258 | - ) |
|
259 | - ->setRequiresTranslation(); |
|
260 | - |
|
261 | - $this->addJavascript( |
|
262 | - CoreAssetManager::JS_HANDLE_HOCS, |
|
263 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
264 | - array( |
|
265 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
266 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
267 | - 'wp-components', |
|
268 | - ) |
|
269 | - )->setRequiresTranslation(); |
|
270 | - |
|
271 | - $this->addJavascript( |
|
272 | - CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
273 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
274 | - array( |
|
275 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | - 'wp-components', |
|
278 | - ) |
|
279 | - ) |
|
280 | - ->setRequiresTranslation(); |
|
281 | - |
|
282 | - $this->addJavascript( |
|
283 | - CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
284 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
285 | - array( |
|
286 | - CoreAssetManager::JS_HANDLE_COMPONENTS |
|
287 | - ) |
|
288 | - )->setRequiresTranslation(); |
|
289 | - |
|
290 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
291 | - $this->registry->addData( |
|
292 | - 'paths', |
|
293 | - array( |
|
294 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
295 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
296 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
297 | - 'site_url' => site_url('/'), |
|
298 | - 'admin_url' => admin_url('/'), |
|
299 | - ) |
|
300 | - ); |
|
301 | - /** site formatting values **/ |
|
302 | - $this->registry->addData( |
|
303 | - 'site_formats', |
|
304 | - array( |
|
305 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
306 | - ) |
|
307 | - ); |
|
308 | - /** currency data **/ |
|
309 | - $this->registry->addData( |
|
310 | - 'currency_config', |
|
311 | - $this->getCurrencySettings() |
|
312 | - ); |
|
313 | - /** site timezone */ |
|
314 | - $this->registry->addData( |
|
315 | - 'default_timezone', |
|
316 | - array( |
|
317 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
318 | - 'string' => get_option('timezone_string'), |
|
319 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
320 | - ) |
|
321 | - ); |
|
322 | - /** site locale (user locale if user logged in) */ |
|
323 | - $this->registry->addData( |
|
324 | - 'locale', |
|
325 | - array( |
|
326 | - 'user' => get_user_locale(), |
|
327 | - 'site' => get_locale() |
|
328 | - ) |
|
329 | - ); |
|
330 | - |
|
331 | - $this->addJavascript( |
|
332 | - CoreAssetManager::JS_HANDLE_CORE, |
|
333 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
334 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
335 | - ) |
|
336 | - ->setInlineDataCallback( |
|
337 | - function () { |
|
338 | - wp_localize_script( |
|
339 | - CoreAssetManager::JS_HANDLE_CORE, |
|
340 | - CoreAssetManager::JS_HANDLE_I18N, |
|
341 | - EE_Registry::$i18n_js_strings |
|
342 | - ); |
|
343 | - } |
|
344 | - ); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
350 | - * WordPress in the running environment. |
|
351 | - * |
|
352 | - * @throws DuplicateCollectionIdentifierException |
|
353 | - * @throws InvalidDataTypeException |
|
354 | - * @throws InvalidEntityException |
|
355 | - * @throws DomainException |
|
356 | - * @since $VID:$ |
|
357 | - */ |
|
358 | - private function registerWpAssets() |
|
359 | - { |
|
360 | - global $wp_version; |
|
361 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
362 | - return; |
|
363 | - } |
|
364 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
365 | - ->setVersion('16.6.0'); |
|
366 | - $this->addVendorJavascript( |
|
367 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
368 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
369 | - )->setVersion('16.6.0'); |
|
370 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
371 | - ->setInlineDataCallback( |
|
372 | - function() { |
|
373 | - wp_add_inline_script( |
|
374 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
375 | - 'window.lodash = _.noConflict();' |
|
376 | - ); |
|
377 | - } |
|
378 | - ) |
|
379 | - ->setVersion('4.17.11'); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * Returns configuration data for the accounting-js library. |
|
385 | - * @since $VID:$ |
|
386 | - * @return array |
|
387 | - */ |
|
388 | - private function getAccountingSettings() { |
|
389 | - return array( |
|
390 | - 'currency' => array( |
|
391 | - 'symbol' => $this->currency_config->sign, |
|
392 | - 'format' => array( |
|
393 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
394 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
395 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
396 | - ), |
|
397 | - 'decimal' => $this->currency_config->dec_mrk, |
|
398 | - 'thousand' => $this->currency_config->thsnds, |
|
399 | - 'precision' => $this->currency_config->dec_plc, |
|
400 | - ), |
|
401 | - 'number' => array( |
|
402 | - 'precision' => $this->currency_config->dec_plc, |
|
403 | - 'thousand' => $this->currency_config->thsnds, |
|
404 | - 'decimal' => $this->currency_config->dec_mrk, |
|
405 | - ), |
|
406 | - ); |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Returns configuration data for the js Currency VO. |
|
412 | - * @since $VID:$ |
|
413 | - * @return array |
|
414 | - */ |
|
415 | - private function getCurrencySettings() |
|
416 | - { |
|
417 | - return array( |
|
418 | - 'code' => $this->currency_config->code, |
|
419 | - 'singularLabel' => $this->currency_config->name, |
|
420 | - 'pluralLabel' => $this->currency_config->plural, |
|
421 | - 'sign' => $this->currency_config->sign, |
|
422 | - 'signB4' => $this->currency_config->sign_b4, |
|
423 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
424 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
425 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
426 | - ); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * @since 4.9.62.p |
|
432 | - * @throws DuplicateCollectionIdentifierException |
|
433 | - * @throws InvalidDataTypeException |
|
434 | - * @throws InvalidEntityException |
|
435 | - */ |
|
436 | - private function loadCoreCss() |
|
437 | - { |
|
438 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
439 | - $this->addStylesheet( |
|
440 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
441 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
442 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
443 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
444 | - array('dashicons') |
|
445 | - ); |
|
446 | - //Load custom style sheet if available |
|
447 | - if ($this->template_config->custom_style_sheet !== null) { |
|
448 | - $this->addStylesheet( |
|
449 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
450 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
451 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
452 | - ); |
|
453 | - } |
|
454 | - } |
|
455 | - $this->addStylesheet( |
|
456 | - CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
457 | - $this->registry->getCssUrl( |
|
458 | - $this->domain->assetNamespace(), |
|
459 | - 'components' |
|
460 | - ) |
|
461 | - ); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * jQuery Validate for form validation |
|
467 | - * |
|
468 | - * @since 4.9.62.p |
|
469 | - * @throws DomainException |
|
470 | - * @throws DuplicateCollectionIdentifierException |
|
471 | - * @throws InvalidDataTypeException |
|
472 | - * @throws InvalidEntityException |
|
473 | - */ |
|
474 | - private function loadJqueryValidate() |
|
475 | - { |
|
476 | - $this->addJavascript( |
|
477 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
478 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
479 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
480 | - ) |
|
481 | - ->setVersion('1.15.0'); |
|
482 | - |
|
483 | - $this->addJavascript( |
|
484 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
485 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
486 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
487 | - ) |
|
488 | - ->setVersion('1.15.0'); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * accounting.js for performing client-side calculations |
|
494 | - * |
|
495 | - * @since 4.9.62.p |
|
496 | - * @throws DomainException |
|
497 | - * @throws DuplicateCollectionIdentifierException |
|
498 | - * @throws InvalidDataTypeException |
|
499 | - * @throws InvalidEntityException |
|
500 | - */ |
|
501 | - private function loadAccountingJs() |
|
502 | - { |
|
503 | - //accounting.js library |
|
504 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
505 | - $this->addJavascript( |
|
506 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
507 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
508 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
509 | - ) |
|
510 | - ->setVersion('0.3.2'); |
|
511 | - |
|
512 | - $this->addJavascript( |
|
513 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
514 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
515 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
516 | - ) |
|
517 | - ->setInlineDataCallback( |
|
518 | - function () { |
|
519 | - wp_localize_script( |
|
520 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
521 | - 'EE_ACCOUNTING_CFG', |
|
522 | - $this->getAccountingSettings() |
|
523 | - ); |
|
524 | - } |
|
525 | - ) |
|
526 | - ->setVersion(); |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * registers assets for cleaning your ears |
|
532 | - * |
|
533 | - * @param JavascriptAsset $script |
|
534 | - */ |
|
535 | - public function loadQtipJs(JavascriptAsset $script) |
|
536 | - { |
|
537 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
538 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
539 | - if ( |
|
540 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
541 | - && apply_filters('FHEE_load_qtip', false) |
|
542 | - ) { |
|
543 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
544 | - } |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * assets that are used in the WordPress admin |
|
550 | - * |
|
551 | - * @since 4.9.62.p |
|
552 | - * @throws DuplicateCollectionIdentifierException |
|
553 | - * @throws InvalidDataTypeException |
|
554 | - * @throws InvalidEntityException |
|
555 | - */ |
|
556 | - private function registerAdminAssets() |
|
557 | - { |
|
558 | - $this->addJavascript( |
|
559 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
560 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
561 | - array( |
|
562 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
563 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
564 | - ) |
|
565 | - ) |
|
566 | - ->setRequiresTranslation(); |
|
567 | - |
|
568 | - $this->addStylesheet( |
|
569 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
570 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
571 | - ); |
|
572 | - } |
|
85 | + const JS_HANDLE_I18N = 'eei18n'; |
|
86 | + |
|
87 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | + |
|
89 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | + |
|
91 | + // EE CSS assets handles |
|
92 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | + |
|
94 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | + |
|
96 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var EE_Currency_Config $currency_config |
|
100 | + */ |
|
101 | + protected $currency_config; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var EE_Template_Config $template_config |
|
105 | + */ |
|
106 | + protected $template_config; |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * CoreAssetRegister constructor. |
|
111 | + * |
|
112 | + * @param AssetCollection $assets |
|
113 | + * @param EE_Currency_Config $currency_config |
|
114 | + * @param EE_Template_Config $template_config |
|
115 | + * @param DomainInterface $domain |
|
116 | + * @param Registry $registry |
|
117 | + */ |
|
118 | + public function __construct( |
|
119 | + AssetCollection $assets, |
|
120 | + EE_Currency_Config $currency_config, |
|
121 | + EE_Template_Config $template_config, |
|
122 | + DomainInterface $domain, |
|
123 | + Registry $registry |
|
124 | + ) { |
|
125 | + $this->currency_config = $currency_config; |
|
126 | + $this->template_config = $template_config; |
|
127 | + parent::__construct($domain, $assets, $registry); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @since 4.9.62.p |
|
133 | + * @throws DomainException |
|
134 | + * @throws DuplicateCollectionIdentifierException |
|
135 | + * @throws InvalidArgumentException |
|
136 | + * @throws InvalidDataTypeException |
|
137 | + * @throws InvalidEntityException |
|
138 | + * @throws InvalidInterfaceException |
|
139 | + */ |
|
140 | + public function addAssets() |
|
141 | + { |
|
142 | + $this->addJavascriptFiles(); |
|
143 | + $this->addStylesheetFiles(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @since 4.9.62.p |
|
149 | + * @throws DomainException |
|
150 | + * @throws DuplicateCollectionIdentifierException |
|
151 | + * @throws InvalidArgumentException |
|
152 | + * @throws InvalidDataTypeException |
|
153 | + * @throws InvalidEntityException |
|
154 | + * @throws InvalidInterfaceException |
|
155 | + */ |
|
156 | + public function addJavascriptFiles() |
|
157 | + { |
|
158 | + $this->loadCoreJs(); |
|
159 | + $this->loadJqueryValidate(); |
|
160 | + $this->loadAccountingJs(); |
|
161 | + add_action( |
|
162 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | + array($this, 'loadQtipJs') |
|
164 | + ); |
|
165 | + $this->registerAdminAssets(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @since 4.9.62.p |
|
171 | + * @throws DuplicateCollectionIdentifierException |
|
172 | + * @throws InvalidDataTypeException |
|
173 | + * @throws InvalidEntityException |
|
174 | + */ |
|
175 | + public function addStylesheetFiles() |
|
176 | + { |
|
177 | + $this->loadCoreCss(); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * core default javascript |
|
183 | + * |
|
184 | + * @since 4.9.62.p |
|
185 | + * @throws DomainException |
|
186 | + * @throws DuplicateCollectionIdentifierException |
|
187 | + * @throws InvalidArgumentException |
|
188 | + * @throws InvalidDataTypeException |
|
189 | + * @throws InvalidEntityException |
|
190 | + * @throws InvalidInterfaceException |
|
191 | + */ |
|
192 | + private function loadCoreJs() |
|
193 | + { |
|
194 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | + $this->registerWpAssets(); |
|
196 | + |
|
197 | + $this->addJavascript( |
|
198 | + CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | + ); |
|
201 | + |
|
202 | + $this->addJavascript( |
|
203 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | + array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | + ) |
|
207 | + ->setHasInlineData(); |
|
208 | + |
|
209 | + $this->addJavascript( |
|
210 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | + array( |
|
213 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | + CoreAssetManager::JS_HANDLE_REACT, |
|
215 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | + ) |
|
218 | + ); |
|
219 | + |
|
220 | + $this->addJavascript( |
|
221 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | + )->setRequiresTranslation(); |
|
224 | + |
|
225 | + $this->addJavascript( |
|
226 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | + array( |
|
229 | + CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | + ) |
|
231 | + )->setRequiresTranslation(); |
|
232 | + |
|
233 | + $this->addJavascript( |
|
234 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | + array( |
|
237 | + CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | + ) |
|
239 | + )->setRequiresTranslation(); |
|
240 | + |
|
241 | + $this->addJavascript( |
|
242 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | + array( |
|
245 | + CoreAssetManager::JS_HANDLE_MODEL |
|
246 | + ) |
|
247 | + )->setRequiresTranslation(); |
|
248 | + |
|
249 | + $this->addJavascript( |
|
250 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | + array( |
|
253 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | + 'wp-data', |
|
255 | + 'wp-api-request', |
|
256 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | + ) |
|
258 | + ) |
|
259 | + ->setRequiresTranslation(); |
|
260 | + |
|
261 | + $this->addJavascript( |
|
262 | + CoreAssetManager::JS_HANDLE_HOCS, |
|
263 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
264 | + array( |
|
265 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
266 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
267 | + 'wp-components', |
|
268 | + ) |
|
269 | + )->setRequiresTranslation(); |
|
270 | + |
|
271 | + $this->addJavascript( |
|
272 | + CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
273 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
274 | + array( |
|
275 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | + 'wp-components', |
|
278 | + ) |
|
279 | + ) |
|
280 | + ->setRequiresTranslation(); |
|
281 | + |
|
282 | + $this->addJavascript( |
|
283 | + CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
284 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
285 | + array( |
|
286 | + CoreAssetManager::JS_HANDLE_COMPONENTS |
|
287 | + ) |
|
288 | + )->setRequiresTranslation(); |
|
289 | + |
|
290 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
291 | + $this->registry->addData( |
|
292 | + 'paths', |
|
293 | + array( |
|
294 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
295 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
296 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
297 | + 'site_url' => site_url('/'), |
|
298 | + 'admin_url' => admin_url('/'), |
|
299 | + ) |
|
300 | + ); |
|
301 | + /** site formatting values **/ |
|
302 | + $this->registry->addData( |
|
303 | + 'site_formats', |
|
304 | + array( |
|
305 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
306 | + ) |
|
307 | + ); |
|
308 | + /** currency data **/ |
|
309 | + $this->registry->addData( |
|
310 | + 'currency_config', |
|
311 | + $this->getCurrencySettings() |
|
312 | + ); |
|
313 | + /** site timezone */ |
|
314 | + $this->registry->addData( |
|
315 | + 'default_timezone', |
|
316 | + array( |
|
317 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
318 | + 'string' => get_option('timezone_string'), |
|
319 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
320 | + ) |
|
321 | + ); |
|
322 | + /** site locale (user locale if user logged in) */ |
|
323 | + $this->registry->addData( |
|
324 | + 'locale', |
|
325 | + array( |
|
326 | + 'user' => get_user_locale(), |
|
327 | + 'site' => get_locale() |
|
328 | + ) |
|
329 | + ); |
|
330 | + |
|
331 | + $this->addJavascript( |
|
332 | + CoreAssetManager::JS_HANDLE_CORE, |
|
333 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
334 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
335 | + ) |
|
336 | + ->setInlineDataCallback( |
|
337 | + function () { |
|
338 | + wp_localize_script( |
|
339 | + CoreAssetManager::JS_HANDLE_CORE, |
|
340 | + CoreAssetManager::JS_HANDLE_I18N, |
|
341 | + EE_Registry::$i18n_js_strings |
|
342 | + ); |
|
343 | + } |
|
344 | + ); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
350 | + * WordPress in the running environment. |
|
351 | + * |
|
352 | + * @throws DuplicateCollectionIdentifierException |
|
353 | + * @throws InvalidDataTypeException |
|
354 | + * @throws InvalidEntityException |
|
355 | + * @throws DomainException |
|
356 | + * @since $VID:$ |
|
357 | + */ |
|
358 | + private function registerWpAssets() |
|
359 | + { |
|
360 | + global $wp_version; |
|
361 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
362 | + return; |
|
363 | + } |
|
364 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
365 | + ->setVersion('16.6.0'); |
|
366 | + $this->addVendorJavascript( |
|
367 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
368 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
369 | + )->setVersion('16.6.0'); |
|
370 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
371 | + ->setInlineDataCallback( |
|
372 | + function() { |
|
373 | + wp_add_inline_script( |
|
374 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
375 | + 'window.lodash = _.noConflict();' |
|
376 | + ); |
|
377 | + } |
|
378 | + ) |
|
379 | + ->setVersion('4.17.11'); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * Returns configuration data for the accounting-js library. |
|
385 | + * @since $VID:$ |
|
386 | + * @return array |
|
387 | + */ |
|
388 | + private function getAccountingSettings() { |
|
389 | + return array( |
|
390 | + 'currency' => array( |
|
391 | + 'symbol' => $this->currency_config->sign, |
|
392 | + 'format' => array( |
|
393 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
394 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
395 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
396 | + ), |
|
397 | + 'decimal' => $this->currency_config->dec_mrk, |
|
398 | + 'thousand' => $this->currency_config->thsnds, |
|
399 | + 'precision' => $this->currency_config->dec_plc, |
|
400 | + ), |
|
401 | + 'number' => array( |
|
402 | + 'precision' => $this->currency_config->dec_plc, |
|
403 | + 'thousand' => $this->currency_config->thsnds, |
|
404 | + 'decimal' => $this->currency_config->dec_mrk, |
|
405 | + ), |
|
406 | + ); |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Returns configuration data for the js Currency VO. |
|
412 | + * @since $VID:$ |
|
413 | + * @return array |
|
414 | + */ |
|
415 | + private function getCurrencySettings() |
|
416 | + { |
|
417 | + return array( |
|
418 | + 'code' => $this->currency_config->code, |
|
419 | + 'singularLabel' => $this->currency_config->name, |
|
420 | + 'pluralLabel' => $this->currency_config->plural, |
|
421 | + 'sign' => $this->currency_config->sign, |
|
422 | + 'signB4' => $this->currency_config->sign_b4, |
|
423 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
424 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
425 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
426 | + ); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * @since 4.9.62.p |
|
432 | + * @throws DuplicateCollectionIdentifierException |
|
433 | + * @throws InvalidDataTypeException |
|
434 | + * @throws InvalidEntityException |
|
435 | + */ |
|
436 | + private function loadCoreCss() |
|
437 | + { |
|
438 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
439 | + $this->addStylesheet( |
|
440 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
441 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
442 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
443 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
444 | + array('dashicons') |
|
445 | + ); |
|
446 | + //Load custom style sheet if available |
|
447 | + if ($this->template_config->custom_style_sheet !== null) { |
|
448 | + $this->addStylesheet( |
|
449 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
450 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
451 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
452 | + ); |
|
453 | + } |
|
454 | + } |
|
455 | + $this->addStylesheet( |
|
456 | + CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
457 | + $this->registry->getCssUrl( |
|
458 | + $this->domain->assetNamespace(), |
|
459 | + 'components' |
|
460 | + ) |
|
461 | + ); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * jQuery Validate for form validation |
|
467 | + * |
|
468 | + * @since 4.9.62.p |
|
469 | + * @throws DomainException |
|
470 | + * @throws DuplicateCollectionIdentifierException |
|
471 | + * @throws InvalidDataTypeException |
|
472 | + * @throws InvalidEntityException |
|
473 | + */ |
|
474 | + private function loadJqueryValidate() |
|
475 | + { |
|
476 | + $this->addJavascript( |
|
477 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
478 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
479 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
480 | + ) |
|
481 | + ->setVersion('1.15.0'); |
|
482 | + |
|
483 | + $this->addJavascript( |
|
484 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
485 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
486 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
487 | + ) |
|
488 | + ->setVersion('1.15.0'); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * accounting.js for performing client-side calculations |
|
494 | + * |
|
495 | + * @since 4.9.62.p |
|
496 | + * @throws DomainException |
|
497 | + * @throws DuplicateCollectionIdentifierException |
|
498 | + * @throws InvalidDataTypeException |
|
499 | + * @throws InvalidEntityException |
|
500 | + */ |
|
501 | + private function loadAccountingJs() |
|
502 | + { |
|
503 | + //accounting.js library |
|
504 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
505 | + $this->addJavascript( |
|
506 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
507 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
508 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
509 | + ) |
|
510 | + ->setVersion('0.3.2'); |
|
511 | + |
|
512 | + $this->addJavascript( |
|
513 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
514 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
515 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
516 | + ) |
|
517 | + ->setInlineDataCallback( |
|
518 | + function () { |
|
519 | + wp_localize_script( |
|
520 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
521 | + 'EE_ACCOUNTING_CFG', |
|
522 | + $this->getAccountingSettings() |
|
523 | + ); |
|
524 | + } |
|
525 | + ) |
|
526 | + ->setVersion(); |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * registers assets for cleaning your ears |
|
532 | + * |
|
533 | + * @param JavascriptAsset $script |
|
534 | + */ |
|
535 | + public function loadQtipJs(JavascriptAsset $script) |
|
536 | + { |
|
537 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
538 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
539 | + if ( |
|
540 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
541 | + && apply_filters('FHEE_load_qtip', false) |
|
542 | + ) { |
|
543 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
544 | + } |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * assets that are used in the WordPress admin |
|
550 | + * |
|
551 | + * @since 4.9.62.p |
|
552 | + * @throws DuplicateCollectionIdentifierException |
|
553 | + * @throws InvalidDataTypeException |
|
554 | + * @throws InvalidEntityException |
|
555 | + */ |
|
556 | + private function registerAdminAssets() |
|
557 | + { |
|
558 | + $this->addJavascript( |
|
559 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
560 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
561 | + array( |
|
562 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
563 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
564 | + ) |
|
565 | + ) |
|
566 | + ->setRequiresTranslation(); |
|
567 | + |
|
568 | + $this->addStylesheet( |
|
569 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
570 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
571 | + ); |
|
572 | + } |
|
573 | 573 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.71.rc.006'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.71.rc.006'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |