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