@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
46 | 46 | |
47 | - const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
47 | + const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
48 | 48 | |
49 | 49 | const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores'; |
50 | 50 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | //js.api |
184 | 184 | $this->addJavascript( |
185 | 185 | CoreAssetManager::JS_HANDLE_EE_JS_API, |
186 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
186 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
187 | 187 | array( |
188 | 188 | CoreAssetManager::JS_HANDLE_UNDERSCORE, |
189 | 189 | CoreAssetManager::JS_HANDLE_EE_JS_CORE |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | |
203 | 203 | $this->addJavascript( |
204 | 204 | CoreAssetManager::JS_HANDLE_EE_CORE, |
205 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
205 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
206 | 206 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
207 | 207 | ) |
208 | 208 | ->setInlineDataCallback( |
209 | - function () { |
|
209 | + function() { |
|
210 | 210 | wp_localize_script( |
211 | 211 | CoreAssetManager::JS_HANDLE_EE_CORE, |
212 | 212 | CoreAssetManager::JS_HANDLE_EE_I18N, |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | if ($this->template_config->enable_default_style && ! is_admin()) { |
229 | 229 | $this->addStylesheet( |
230 | 230 | CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
231 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
231 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
232 | 232 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
233 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
233 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
234 | 234 | array('dashicons') |
235 | 235 | ); |
236 | 236 | //Load custom style sheet if available |
237 | 237 | if ($this->template_config->custom_style_sheet !== null) { |
238 | 238 | $this->addStylesheet( |
239 | 239 | CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
240 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
240 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
241 | 241 | array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
242 | 242 | ); |
243 | 243 | } |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | { |
258 | 258 | $this->addJavascript( |
259 | 259 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
260 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
260 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
261 | 261 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
262 | 262 | ) |
263 | 263 | ->setVersion('1.15.0'); |
264 | 264 | |
265 | 265 | $this->addJavascript( |
266 | 266 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
267 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
267 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
268 | 268 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
269 | 269 | ) |
270 | 270 | ->setVersion('1.15.0'); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // @link http://josscrowcroft.github.io/accounting.js/ |
286 | 286 | $this->addJavascript( |
287 | 287 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
288 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
288 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
289 | 289 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
290 | 290 | ) |
291 | 291 | ->setVersion('0.3.2'); |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | $currency_config = $this->currency_config; |
294 | 294 | $this->addJavascript( |
295 | 295 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
296 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
296 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
297 | 297 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
298 | 298 | ) |
299 | 299 | ->setInlineDataCallback( |
300 | - function () use ($currency_config) { |
|
300 | + function() use ($currency_config) { |
|
301 | 301 | wp_localize_script( |
302 | 302 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
303 | 303 | 'EE_ACCOUNTING_CFG', |
@@ -28,354 +28,354 @@ |
||
28 | 28 | class CoreAssetManager extends AssetManager |
29 | 29 | { |
30 | 30 | |
31 | - // WordPress core / Third party JS asset handles |
|
32 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
31 | + // WordPress core / Third party JS asset handles |
|
32 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
33 | 33 | |
34 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
34 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
35 | 35 | |
36 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
36 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
37 | 37 | |
38 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
39 | - |
|
40 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
41 | - |
|
42 | - // EE JS assets handles |
|
43 | - const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
44 | - |
|
45 | - const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
46 | - |
|
47 | - const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
48 | - |
|
49 | - const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores'; |
|
50 | - |
|
51 | - const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components'; |
|
52 | - |
|
53 | - const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
54 | - |
|
55 | - const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
56 | - |
|
57 | - const JS_HANDLE_EE_I18N = 'eei18n'; |
|
58 | - |
|
59 | - const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
60 | - |
|
61 | - const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
62 | - |
|
63 | - // EE CSS assets handles |
|
64 | - const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
65 | - |
|
66 | - const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var EE_Currency_Config $currency_config |
|
70 | - */ |
|
71 | - protected $currency_config; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var EE_Template_Config $template_config |
|
75 | - */ |
|
76 | - protected $template_config; |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * CoreAssetRegister constructor. |
|
81 | - * |
|
82 | - * @param AssetCollection $assets |
|
83 | - * @param EE_Currency_Config $currency_config |
|
84 | - * @param EE_Template_Config $template_config |
|
85 | - * @param DomainInterface $domain |
|
86 | - * @param Registry $registry |
|
87 | - */ |
|
88 | - public function __construct( |
|
89 | - AssetCollection $assets, |
|
90 | - EE_Currency_Config $currency_config, |
|
91 | - EE_Template_Config $template_config, |
|
92 | - DomainInterface $domain, |
|
93 | - Registry $registry |
|
94 | - ) { |
|
95 | - $this->currency_config = $currency_config; |
|
96 | - $this->template_config = $template_config; |
|
97 | - parent::__construct($domain, $assets, $registry); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @since 4.9.62.p |
|
103 | - * @throws DuplicateCollectionIdentifierException |
|
104 | - * @throws InvalidArgumentException |
|
105 | - * @throws InvalidDataTypeException |
|
106 | - * @throws InvalidEntityException |
|
107 | - */ |
|
108 | - public function addAssets() |
|
109 | - { |
|
110 | - $this->addJavascriptFiles(); |
|
111 | - $this->addStylesheetFiles(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @since 4.9.62.p |
|
117 | - * @throws DuplicateCollectionIdentifierException |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidEntityException |
|
121 | - */ |
|
122 | - public function addJavascriptFiles() |
|
123 | - { |
|
124 | - $this->loadCoreJs(); |
|
125 | - $this->loadJqueryValidate(); |
|
126 | - $this->loadAccountingJs(); |
|
127 | - add_action( |
|
128 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
129 | - array($this, 'loadQtipJs') |
|
130 | - ); |
|
131 | - $this->registerAdminAssets(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @since 4.9.62.p |
|
137 | - * @throws DuplicateCollectionIdentifierException |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidEntityException |
|
140 | - */ |
|
141 | - public function addStylesheetFiles() |
|
142 | - { |
|
143 | - $this->loadCoreCss(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * core default javascript |
|
149 | - * |
|
150 | - * @since 4.9.62.p |
|
151 | - * @throws DuplicateCollectionIdentifierException |
|
152 | - * @throws InvalidArgumentException |
|
153 | - * @throws InvalidDataTypeException |
|
154 | - * @throws InvalidEntityException |
|
155 | - */ |
|
156 | - private function loadCoreJs() |
|
157 | - { |
|
158 | - $this->addJavascript( |
|
159 | - CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
160 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
161 | - ); |
|
162 | - |
|
163 | - $this->addJavascript( |
|
164 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
165 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
166 | - array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
167 | - ) |
|
168 | - ->setHasInlineData(); |
|
169 | - |
|
170 | - $this->addJavascript( |
|
171 | - CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
172 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
173 | - array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
174 | - ); |
|
175 | - |
|
176 | - $this->addJavascript( |
|
177 | - CoreAssetManager::JS_HANDLE_EE_DATA_STORES, |
|
178 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
179 | - array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data') |
|
180 | - ) |
|
181 | - ->setRequiresTranslation(); |
|
182 | - |
|
183 | - $this->addJavascript( |
|
184 | - CoreAssetManager::JS_HANDLE_EE_COMPONENTS, |
|
185 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
186 | - array(CoreAssetManager::JS_HANDLE_EE_DATA_STORES) |
|
187 | - ) |
|
188 | - ->setRequiresTranslation(); |
|
189 | - |
|
190 | - global $wp_version; |
|
191 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
192 | - //js.api |
|
193 | - $this->addJavascript( |
|
194 | - CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
195 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
196 | - array( |
|
197 | - CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
198 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
199 | - ) |
|
200 | - ); |
|
201 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
202 | - $this->registry->addData( |
|
203 | - 'paths', |
|
204 | - array( |
|
205 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
206 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
207 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName() |
|
208 | - ) |
|
209 | - ); |
|
210 | - } |
|
211 | - |
|
212 | - $this->addJavascript( |
|
213 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
214 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
215 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
216 | - ) |
|
217 | - ->setInlineDataCallback( |
|
218 | - function () { |
|
219 | - wp_localize_script( |
|
220 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
221 | - CoreAssetManager::JS_HANDLE_EE_I18N, |
|
222 | - EE_Registry::$i18n_js_strings |
|
223 | - ); |
|
224 | - } |
|
225 | - ); |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * @since 4.9.62.p |
|
231 | - * @throws DuplicateCollectionIdentifierException |
|
232 | - * @throws InvalidDataTypeException |
|
233 | - * @throws InvalidEntityException |
|
234 | - */ |
|
235 | - private function loadCoreCss() |
|
236 | - { |
|
237 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
238 | - $this->addStylesheet( |
|
239 | - CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
240 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
241 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
242 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
243 | - array('dashicons') |
|
244 | - ); |
|
245 | - //Load custom style sheet if available |
|
246 | - if ($this->template_config->custom_style_sheet !== null) { |
|
247 | - $this->addStylesheet( |
|
248 | - CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
249 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
250 | - array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
251 | - ); |
|
252 | - } |
|
253 | - } |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * jQuery Validate for form validation |
|
259 | - * |
|
260 | - * @since 4.9.62.p |
|
261 | - * @throws DuplicateCollectionIdentifierException |
|
262 | - * @throws InvalidDataTypeException |
|
263 | - * @throws InvalidEntityException |
|
264 | - */ |
|
265 | - private function loadJqueryValidate() |
|
266 | - { |
|
267 | - $this->addJavascript( |
|
268 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
269 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
270 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
271 | - ) |
|
272 | - ->setVersion('1.15.0'); |
|
273 | - |
|
274 | - $this->addJavascript( |
|
275 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
276 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
277 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
278 | - ) |
|
279 | - ->setVersion('1.15.0'); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * accounting.js for performing client-side calculations |
|
285 | - * |
|
286 | - * @since 4.9.62.p |
|
287 | - * @throws DuplicateCollectionIdentifierException |
|
288 | - * @throws InvalidDataTypeException |
|
289 | - * @throws InvalidEntityException |
|
290 | - */ |
|
291 | - private function loadAccountingJs() |
|
292 | - { |
|
293 | - //accounting.js library |
|
294 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
295 | - $this->addJavascript( |
|
296 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
297 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
298 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
299 | - ) |
|
300 | - ->setVersion('0.3.2'); |
|
301 | - |
|
302 | - $currency_config = $this->currency_config; |
|
303 | - $this->addJavascript( |
|
304 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
305 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
306 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
307 | - ) |
|
308 | - ->setInlineDataCallback( |
|
309 | - function () use ($currency_config) { |
|
310 | - wp_localize_script( |
|
311 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
312 | - 'EE_ACCOUNTING_CFG', |
|
313 | - array( |
|
314 | - 'currency' => array( |
|
315 | - 'symbol' => $currency_config->sign, |
|
316 | - 'format' => array( |
|
317 | - 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
318 | - 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
319 | - 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
320 | - ), |
|
321 | - 'decimal' => $currency_config->dec_mrk, |
|
322 | - 'thousand' => $currency_config->thsnds, |
|
323 | - 'precision' => $currency_config->dec_plc, |
|
324 | - ), |
|
325 | - 'number' => array( |
|
326 | - 'precision' => $currency_config->dec_plc, |
|
327 | - 'thousand' => $currency_config->thsnds, |
|
328 | - 'decimal' => $currency_config->dec_mrk, |
|
329 | - ), |
|
330 | - ) |
|
331 | - ); |
|
332 | - } |
|
333 | - ) |
|
334 | - ->setVersion(); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * registers assets for cleaning your ears |
|
340 | - * |
|
341 | - * @param JavascriptAsset $script |
|
342 | - */ |
|
343 | - public function loadQtipJs(JavascriptAsset $script) |
|
344 | - { |
|
345 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
346 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
347 | - if ( |
|
348 | - $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
349 | - && apply_filters('FHEE_load_qtip', false) |
|
350 | - ) { |
|
351 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
352 | - } |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * assets that are used in the WordPress admin |
|
358 | - * |
|
359 | - * @since 4.9.62.p |
|
360 | - * @throws DuplicateCollectionIdentifierException |
|
361 | - * @throws InvalidDataTypeException |
|
362 | - * @throws InvalidEntityException |
|
363 | - */ |
|
364 | - private function registerAdminAssets() |
|
365 | - { |
|
366 | - $this->addJavascript( |
|
367 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
368 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
369 | - array( |
|
370 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
371 | - CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
372 | - ) |
|
373 | - ) |
|
374 | - ->setRequiresTranslation(); |
|
375 | - |
|
376 | - $this->addStylesheet( |
|
377 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
378 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
379 | - ); |
|
380 | - } |
|
38 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
39 | + |
|
40 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
41 | + |
|
42 | + // EE JS assets handles |
|
43 | + const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
44 | + |
|
45 | + const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
46 | + |
|
47 | + const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor'; |
|
48 | + |
|
49 | + const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores'; |
|
50 | + |
|
51 | + const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components'; |
|
52 | + |
|
53 | + const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
54 | + |
|
55 | + const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
56 | + |
|
57 | + const JS_HANDLE_EE_I18N = 'eei18n'; |
|
58 | + |
|
59 | + const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
60 | + |
|
61 | + const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
62 | + |
|
63 | + // EE CSS assets handles |
|
64 | + const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
65 | + |
|
66 | + const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var EE_Currency_Config $currency_config |
|
70 | + */ |
|
71 | + protected $currency_config; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var EE_Template_Config $template_config |
|
75 | + */ |
|
76 | + protected $template_config; |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * CoreAssetRegister constructor. |
|
81 | + * |
|
82 | + * @param AssetCollection $assets |
|
83 | + * @param EE_Currency_Config $currency_config |
|
84 | + * @param EE_Template_Config $template_config |
|
85 | + * @param DomainInterface $domain |
|
86 | + * @param Registry $registry |
|
87 | + */ |
|
88 | + public function __construct( |
|
89 | + AssetCollection $assets, |
|
90 | + EE_Currency_Config $currency_config, |
|
91 | + EE_Template_Config $template_config, |
|
92 | + DomainInterface $domain, |
|
93 | + Registry $registry |
|
94 | + ) { |
|
95 | + $this->currency_config = $currency_config; |
|
96 | + $this->template_config = $template_config; |
|
97 | + parent::__construct($domain, $assets, $registry); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @since 4.9.62.p |
|
103 | + * @throws DuplicateCollectionIdentifierException |
|
104 | + * @throws InvalidArgumentException |
|
105 | + * @throws InvalidDataTypeException |
|
106 | + * @throws InvalidEntityException |
|
107 | + */ |
|
108 | + public function addAssets() |
|
109 | + { |
|
110 | + $this->addJavascriptFiles(); |
|
111 | + $this->addStylesheetFiles(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @since 4.9.62.p |
|
117 | + * @throws DuplicateCollectionIdentifierException |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidEntityException |
|
121 | + */ |
|
122 | + public function addJavascriptFiles() |
|
123 | + { |
|
124 | + $this->loadCoreJs(); |
|
125 | + $this->loadJqueryValidate(); |
|
126 | + $this->loadAccountingJs(); |
|
127 | + add_action( |
|
128 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
129 | + array($this, 'loadQtipJs') |
|
130 | + ); |
|
131 | + $this->registerAdminAssets(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @since 4.9.62.p |
|
137 | + * @throws DuplicateCollectionIdentifierException |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidEntityException |
|
140 | + */ |
|
141 | + public function addStylesheetFiles() |
|
142 | + { |
|
143 | + $this->loadCoreCss(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * core default javascript |
|
149 | + * |
|
150 | + * @since 4.9.62.p |
|
151 | + * @throws DuplicateCollectionIdentifierException |
|
152 | + * @throws InvalidArgumentException |
|
153 | + * @throws InvalidDataTypeException |
|
154 | + * @throws InvalidEntityException |
|
155 | + */ |
|
156 | + private function loadCoreJs() |
|
157 | + { |
|
158 | + $this->addJavascript( |
|
159 | + CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
160 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
161 | + ); |
|
162 | + |
|
163 | + $this->addJavascript( |
|
164 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
165 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
166 | + array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
167 | + ) |
|
168 | + ->setHasInlineData(); |
|
169 | + |
|
170 | + $this->addJavascript( |
|
171 | + CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
172 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
173 | + array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
174 | + ); |
|
175 | + |
|
176 | + $this->addJavascript( |
|
177 | + CoreAssetManager::JS_HANDLE_EE_DATA_STORES, |
|
178 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
179 | + array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data') |
|
180 | + ) |
|
181 | + ->setRequiresTranslation(); |
|
182 | + |
|
183 | + $this->addJavascript( |
|
184 | + CoreAssetManager::JS_HANDLE_EE_COMPONENTS, |
|
185 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
186 | + array(CoreAssetManager::JS_HANDLE_EE_DATA_STORES) |
|
187 | + ) |
|
188 | + ->setRequiresTranslation(); |
|
189 | + |
|
190 | + global $wp_version; |
|
191 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
192 | + //js.api |
|
193 | + $this->addJavascript( |
|
194 | + CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
195 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
196 | + array( |
|
197 | + CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
198 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
199 | + ) |
|
200 | + ); |
|
201 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
202 | + $this->registry->addData( |
|
203 | + 'paths', |
|
204 | + array( |
|
205 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
206 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
207 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName() |
|
208 | + ) |
|
209 | + ); |
|
210 | + } |
|
211 | + |
|
212 | + $this->addJavascript( |
|
213 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
214 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
215 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
216 | + ) |
|
217 | + ->setInlineDataCallback( |
|
218 | + function () { |
|
219 | + wp_localize_script( |
|
220 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
221 | + CoreAssetManager::JS_HANDLE_EE_I18N, |
|
222 | + EE_Registry::$i18n_js_strings |
|
223 | + ); |
|
224 | + } |
|
225 | + ); |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * @since 4.9.62.p |
|
231 | + * @throws DuplicateCollectionIdentifierException |
|
232 | + * @throws InvalidDataTypeException |
|
233 | + * @throws InvalidEntityException |
|
234 | + */ |
|
235 | + private function loadCoreCss() |
|
236 | + { |
|
237 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
238 | + $this->addStylesheet( |
|
239 | + CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
240 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
241 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
242 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
243 | + array('dashicons') |
|
244 | + ); |
|
245 | + //Load custom style sheet if available |
|
246 | + if ($this->template_config->custom_style_sheet !== null) { |
|
247 | + $this->addStylesheet( |
|
248 | + CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
249 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
250 | + array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
251 | + ); |
|
252 | + } |
|
253 | + } |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * jQuery Validate for form validation |
|
259 | + * |
|
260 | + * @since 4.9.62.p |
|
261 | + * @throws DuplicateCollectionIdentifierException |
|
262 | + * @throws InvalidDataTypeException |
|
263 | + * @throws InvalidEntityException |
|
264 | + */ |
|
265 | + private function loadJqueryValidate() |
|
266 | + { |
|
267 | + $this->addJavascript( |
|
268 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
269 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
270 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
271 | + ) |
|
272 | + ->setVersion('1.15.0'); |
|
273 | + |
|
274 | + $this->addJavascript( |
|
275 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
276 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
277 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
278 | + ) |
|
279 | + ->setVersion('1.15.0'); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * accounting.js for performing client-side calculations |
|
285 | + * |
|
286 | + * @since 4.9.62.p |
|
287 | + * @throws DuplicateCollectionIdentifierException |
|
288 | + * @throws InvalidDataTypeException |
|
289 | + * @throws InvalidEntityException |
|
290 | + */ |
|
291 | + private function loadAccountingJs() |
|
292 | + { |
|
293 | + //accounting.js library |
|
294 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
295 | + $this->addJavascript( |
|
296 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
297 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
298 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
299 | + ) |
|
300 | + ->setVersion('0.3.2'); |
|
301 | + |
|
302 | + $currency_config = $this->currency_config; |
|
303 | + $this->addJavascript( |
|
304 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
305 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
306 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
307 | + ) |
|
308 | + ->setInlineDataCallback( |
|
309 | + function () use ($currency_config) { |
|
310 | + wp_localize_script( |
|
311 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
312 | + 'EE_ACCOUNTING_CFG', |
|
313 | + array( |
|
314 | + 'currency' => array( |
|
315 | + 'symbol' => $currency_config->sign, |
|
316 | + 'format' => array( |
|
317 | + 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
318 | + 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
319 | + 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
320 | + ), |
|
321 | + 'decimal' => $currency_config->dec_mrk, |
|
322 | + 'thousand' => $currency_config->thsnds, |
|
323 | + 'precision' => $currency_config->dec_plc, |
|
324 | + ), |
|
325 | + 'number' => array( |
|
326 | + 'precision' => $currency_config->dec_plc, |
|
327 | + 'thousand' => $currency_config->thsnds, |
|
328 | + 'decimal' => $currency_config->dec_mrk, |
|
329 | + ), |
|
330 | + ) |
|
331 | + ); |
|
332 | + } |
|
333 | + ) |
|
334 | + ->setVersion(); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * registers assets for cleaning your ears |
|
340 | + * |
|
341 | + * @param JavascriptAsset $script |
|
342 | + */ |
|
343 | + public function loadQtipJs(JavascriptAsset $script) |
|
344 | + { |
|
345 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
346 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
347 | + if ( |
|
348 | + $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
349 | + && apply_filters('FHEE_load_qtip', false) |
|
350 | + ) { |
|
351 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
352 | + } |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * assets that are used in the WordPress admin |
|
358 | + * |
|
359 | + * @since 4.9.62.p |
|
360 | + * @throws DuplicateCollectionIdentifierException |
|
361 | + * @throws InvalidDataTypeException |
|
362 | + * @throws InvalidEntityException |
|
363 | + */ |
|
364 | + private function registerAdminAssets() |
|
365 | + { |
|
366 | + $this->addJavascript( |
|
367 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
368 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
369 | + array( |
|
370 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
371 | + CoreAssetManager::JS_HANDLE_EE_VENDOR, |
|
372 | + ) |
|
373 | + ) |
|
374 | + ->setRequiresTranslation(); |
|
375 | + |
|
376 | + $this->addStylesheet( |
|
377 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
378 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
379 | + ); |
|
380 | + } |
|
381 | 381 | } |
@@ -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->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->has($handle)){ |
|
156 | - return $this->assets->get($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->has($handle)) { |
|
182 | - return $this->assets->get($handle); |
|
183 | - } |
|
184 | - return parent::addStylesheet( |
|
185 | - $handle, |
|
186 | - $this->registry->getCssUrl( |
|
187 | - $this->domain->assetNamespace(), |
|
188 | - $handle |
|
189 | - ), |
|
190 | - $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->has($handle)) { |
|
207 | - return $this->assets->get($handle); |
|
208 | - } |
|
209 | - return parent::addJavascript( |
|
210 | - $handle, |
|
211 | - $this->registry->getJsUrl( |
|
212 | - $this->domain->assetNamespace(), |
|
213 | - $handle |
|
214 | - ), |
|
215 | - $this->addDefaultBlockScriptDependencies($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->has($handle)) { |
|
233 | - return $this->assets->get($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 string $handle |
|
265 | - * @since $VID:$ |
|
266 | - * @return mixed|null |
|
267 | - */ |
|
268 | - public function getAsset($handle) |
|
269 | - { |
|
270 | - if ($this->assets->has($handle)) { |
|
271 | - return $this->assets->get($handle); |
|
272 | - } |
|
273 | - return null; |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * @return JavascriptAsset|null |
|
279 | - */ |
|
280 | - public function getEditorScript() |
|
281 | - { |
|
282 | - return $this->getAsset($this->editor_script_handle); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @return StylesheetAsset|null |
|
288 | - */ |
|
289 | - public function getEditorStyle() |
|
290 | - { |
|
291 | - return $this->getAsset($this->editor_style_handle); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * @return JavascriptAsset|null |
|
297 | - */ |
|
298 | - public function getScript() |
|
299 | - { |
|
300 | - return $this->getAsset($this->script_handle); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * @return StylesheetAsset|null |
|
306 | - */ |
|
307 | - public function getStyle() |
|
308 | - { |
|
309 | - return $this->getAsset($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->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->has($handle)){ |
|
156 | + return $this->assets->get($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->has($handle)) { |
|
182 | + return $this->assets->get($handle); |
|
183 | + } |
|
184 | + return parent::addStylesheet( |
|
185 | + $handle, |
|
186 | + $this->registry->getCssUrl( |
|
187 | + $this->domain->assetNamespace(), |
|
188 | + $handle |
|
189 | + ), |
|
190 | + $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->has($handle)) { |
|
207 | + return $this->assets->get($handle); |
|
208 | + } |
|
209 | + return parent::addJavascript( |
|
210 | + $handle, |
|
211 | + $this->registry->getJsUrl( |
|
212 | + $this->domain->assetNamespace(), |
|
213 | + $handle |
|
214 | + ), |
|
215 | + $this->addDefaultBlockScriptDependencies($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->has($handle)) { |
|
233 | + return $this->assets->get($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 string $handle |
|
265 | + * @since $VID:$ |
|
266 | + * @return mixed|null |
|
267 | + */ |
|
268 | + public function getAsset($handle) |
|
269 | + { |
|
270 | + if ($this->assets->has($handle)) { |
|
271 | + return $this->assets->get($handle); |
|
272 | + } |
|
273 | + return null; |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * @return JavascriptAsset|null |
|
279 | + */ |
|
280 | + public function getEditorScript() |
|
281 | + { |
|
282 | + return $this->getAsset($this->editor_script_handle); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @return StylesheetAsset|null |
|
288 | + */ |
|
289 | + public function getEditorStyle() |
|
290 | + { |
|
291 | + return $this->getAsset($this->editor_style_handle); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * @return JavascriptAsset|null |
|
297 | + */ |
|
298 | + public function getScript() |
|
299 | + { |
|
300 | + return $this->getAsset($this->script_handle); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * @return StylesheetAsset|null |
|
306 | + */ |
|
307 | + public function getStyle() |
|
308 | + { |
|
309 | + return $this->getAsset($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->has($handle)){ |
|
155 | + if ($this->assets->has($handle)) { |
|
156 | 156 | return $this->assets->get($handle); |
157 | 157 | } |
158 | 158 | return parent::addJavascript( |
@@ -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_EE_COMPONENTS |
258 | 258 | ); |