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