@@ -29,172 +29,172 @@ |
||
29 | 29 | class CoreAssetManager extends AssetManager |
30 | 30 | { |
31 | 31 | |
32 | - // WordPress core / Third party JS asset handles |
|
33 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
34 | - |
|
35 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
36 | - |
|
37 | - const JS_HANDLE_I18N = 'eei18n'; |
|
38 | - |
|
39 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
40 | - |
|
41 | - const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | - |
|
43 | - const RAMDA_VERSION = '0.27.1'; |
|
44 | - |
|
45 | - // EE CSS assets handles |
|
46 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
47 | - |
|
48 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var EE_Currency_Config $currency_config |
|
52 | - */ |
|
53 | - protected $currency_config; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EE_Template_Config $template_config |
|
57 | - */ |
|
58 | - protected $template_config; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * CoreAssetRegister constructor. |
|
63 | - * |
|
64 | - * @param AssetCollection $assets |
|
65 | - * @param EE_Currency_Config $currency_config |
|
66 | - * @param EE_Template_Config $template_config |
|
67 | - * @param DomainInterface $domain |
|
68 | - * @param Registry $registry |
|
69 | - */ |
|
70 | - public function __construct( |
|
71 | - AssetCollection $assets, |
|
72 | - EE_Currency_Config $currency_config, |
|
73 | - EE_Template_Config $template_config, |
|
74 | - DomainInterface $domain, |
|
75 | - Registry $registry |
|
76 | - ) { |
|
77 | - $this->currency_config = $currency_config; |
|
78 | - $this->template_config = $template_config; |
|
79 | - parent::__construct($domain, $assets, $registry); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @throws DomainException |
|
85 | - * @throws DuplicateCollectionIdentifierException |
|
86 | - * @throws InvalidArgumentException |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - * @throws InvalidEntityException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @since 4.9.62.p |
|
91 | - */ |
|
92 | - public function addAssets() |
|
93 | - { |
|
94 | - $this->addJavascriptFiles(); |
|
95 | - $this->addStylesheetFiles(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @throws DomainException |
|
101 | - * @throws DuplicateCollectionIdentifierException |
|
102 | - * @throws InvalidArgumentException |
|
103 | - * @throws InvalidDataTypeException |
|
104 | - * @throws InvalidEntityException |
|
105 | - * @throws InvalidInterfaceException |
|
106 | - * @since 4.9.62.p |
|
107 | - */ |
|
108 | - public function addJavascriptFiles() |
|
109 | - { |
|
110 | - $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
111 | - $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
112 | - $this->addJavascript( |
|
113 | - CoreAssetManager::JS_HANDLE_CORE, |
|
114 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
115 | - [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
116 | - )->setInlineDataCallback( |
|
117 | - function () { |
|
118 | - wp_localize_script( |
|
119 | - CoreAssetManager::JS_HANDLE_CORE, |
|
120 | - CoreAssetManager::JS_HANDLE_I18N, |
|
121 | - EE_Registry::$i18n_js_strings |
|
122 | - ); |
|
123 | - } |
|
124 | - ); |
|
125 | - $this->loadQtipJs(); |
|
126 | - $this->addVendorJavascript( |
|
127 | - CoreAssetManager::JS_HANDLE_RAMDA, |
|
128 | - [], |
|
129 | - true, |
|
130 | - CoreAssetManager::RAMDA_VERSION |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @throws DuplicateCollectionIdentifierException |
|
137 | - * @throws InvalidDataTypeException |
|
138 | - * @throws InvalidEntityException |
|
139 | - * @throws DomainException |
|
140 | - * @since 4.9.62.p |
|
141 | - */ |
|
142 | - public function addStylesheetFiles() |
|
143 | - { |
|
144 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
145 | - $this->addStylesheet( |
|
146 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
147 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
148 | - ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
149 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
150 | - ['dashicons'] |
|
151 | - ); |
|
152 | - //Load custom style sheet if available |
|
153 | - if ($this->template_config->custom_style_sheet !== null) { |
|
154 | - $this->addStylesheet( |
|
155 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
156 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
157 | - [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
158 | - ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Returns configuration data for the js Currency VO. |
|
166 | - * |
|
167 | - * @return array |
|
168 | - * @since 4.9.71.p |
|
169 | - */ |
|
170 | - private function getCurrencySettings() |
|
171 | - { |
|
172 | - return [ |
|
173 | - 'code' => $this->currency_config->code, |
|
174 | - 'singularLabel' => $this->currency_config->name, |
|
175 | - 'pluralLabel' => $this->currency_config->plural, |
|
176 | - 'sign' => $this->currency_config->sign, |
|
177 | - 'signB4' => $this->currency_config->sign_b4, |
|
178 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
179 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
180 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
181 | - ]; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * replacement: |
|
187 | - * EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
188 | - * |
|
189 | - * @param JavascriptAsset $script |
|
190 | - * @deprecated $VID:$ |
|
191 | - */ |
|
192 | - public function loadQtipJs(JavascriptAsset $script = null) |
|
193 | - { |
|
194 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
195 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
196 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
197 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
198 | - } |
|
199 | - } |
|
32 | + // WordPress core / Third party JS asset handles |
|
33 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
34 | + |
|
35 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
36 | + |
|
37 | + const JS_HANDLE_I18N = 'eei18n'; |
|
38 | + |
|
39 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
40 | + |
|
41 | + const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | + |
|
43 | + const RAMDA_VERSION = '0.27.1'; |
|
44 | + |
|
45 | + // EE CSS assets handles |
|
46 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
47 | + |
|
48 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var EE_Currency_Config $currency_config |
|
52 | + */ |
|
53 | + protected $currency_config; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EE_Template_Config $template_config |
|
57 | + */ |
|
58 | + protected $template_config; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * CoreAssetRegister constructor. |
|
63 | + * |
|
64 | + * @param AssetCollection $assets |
|
65 | + * @param EE_Currency_Config $currency_config |
|
66 | + * @param EE_Template_Config $template_config |
|
67 | + * @param DomainInterface $domain |
|
68 | + * @param Registry $registry |
|
69 | + */ |
|
70 | + public function __construct( |
|
71 | + AssetCollection $assets, |
|
72 | + EE_Currency_Config $currency_config, |
|
73 | + EE_Template_Config $template_config, |
|
74 | + DomainInterface $domain, |
|
75 | + Registry $registry |
|
76 | + ) { |
|
77 | + $this->currency_config = $currency_config; |
|
78 | + $this->template_config = $template_config; |
|
79 | + parent::__construct($domain, $assets, $registry); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @throws DomainException |
|
85 | + * @throws DuplicateCollectionIdentifierException |
|
86 | + * @throws InvalidArgumentException |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + * @throws InvalidEntityException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @since 4.9.62.p |
|
91 | + */ |
|
92 | + public function addAssets() |
|
93 | + { |
|
94 | + $this->addJavascriptFiles(); |
|
95 | + $this->addStylesheetFiles(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @throws DomainException |
|
101 | + * @throws DuplicateCollectionIdentifierException |
|
102 | + * @throws InvalidArgumentException |
|
103 | + * @throws InvalidDataTypeException |
|
104 | + * @throws InvalidEntityException |
|
105 | + * @throws InvalidInterfaceException |
|
106 | + * @since 4.9.62.p |
|
107 | + */ |
|
108 | + public function addJavascriptFiles() |
|
109 | + { |
|
110 | + $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
111 | + $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
112 | + $this->addJavascript( |
|
113 | + CoreAssetManager::JS_HANDLE_CORE, |
|
114 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
115 | + [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
116 | + )->setInlineDataCallback( |
|
117 | + function () { |
|
118 | + wp_localize_script( |
|
119 | + CoreAssetManager::JS_HANDLE_CORE, |
|
120 | + CoreAssetManager::JS_HANDLE_I18N, |
|
121 | + EE_Registry::$i18n_js_strings |
|
122 | + ); |
|
123 | + } |
|
124 | + ); |
|
125 | + $this->loadQtipJs(); |
|
126 | + $this->addVendorJavascript( |
|
127 | + CoreAssetManager::JS_HANDLE_RAMDA, |
|
128 | + [], |
|
129 | + true, |
|
130 | + CoreAssetManager::RAMDA_VERSION |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @throws DuplicateCollectionIdentifierException |
|
137 | + * @throws InvalidDataTypeException |
|
138 | + * @throws InvalidEntityException |
|
139 | + * @throws DomainException |
|
140 | + * @since 4.9.62.p |
|
141 | + */ |
|
142 | + public function addStylesheetFiles() |
|
143 | + { |
|
144 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
145 | + $this->addStylesheet( |
|
146 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
147 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
148 | + ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
149 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
150 | + ['dashicons'] |
|
151 | + ); |
|
152 | + //Load custom style sheet if available |
|
153 | + if ($this->template_config->custom_style_sheet !== null) { |
|
154 | + $this->addStylesheet( |
|
155 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
156 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
157 | + [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
158 | + ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Returns configuration data for the js Currency VO. |
|
166 | + * |
|
167 | + * @return array |
|
168 | + * @since 4.9.71.p |
|
169 | + */ |
|
170 | + private function getCurrencySettings() |
|
171 | + { |
|
172 | + return [ |
|
173 | + 'code' => $this->currency_config->code, |
|
174 | + 'singularLabel' => $this->currency_config->name, |
|
175 | + 'pluralLabel' => $this->currency_config->plural, |
|
176 | + 'sign' => $this->currency_config->sign, |
|
177 | + 'signB4' => $this->currency_config->sign_b4, |
|
178 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
179 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
180 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
181 | + ]; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * replacement: |
|
187 | + * EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
188 | + * |
|
189 | + * @param JavascriptAsset $script |
|
190 | + * @deprecated $VID:$ |
|
191 | + */ |
|
192 | + public function loadQtipJs(JavascriptAsset $script = null) |
|
193 | + { |
|
194 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
195 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
196 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
197 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
198 | + } |
|
199 | + } |
|
200 | 200 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
40 | 40 | |
41 | - const JS_HANDLE_RAMDA = 'ramda'; |
|
41 | + const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | 42 | |
43 | 43 | const RAMDA_VERSION = '0.27.1'; |
44 | 44 | |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
112 | 112 | $this->addJavascript( |
113 | 113 | CoreAssetManager::JS_HANDLE_CORE, |
114 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
114 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
115 | 115 | [JqueryAssetManager::JS_HANDLE_JQUERY] |
116 | 116 | )->setInlineDataCallback( |
117 | - function () { |
|
117 | + function() { |
|
118 | 118 | wp_localize_script( |
119 | 119 | CoreAssetManager::JS_HANDLE_CORE, |
120 | 120 | CoreAssetManager::JS_HANDLE_I18N, |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | if ($this->template_config->enable_default_style && ! is_admin()) { |
145 | 145 | $this->addStylesheet( |
146 | 146 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
147 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
147 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css') |
|
148 | 148 | ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
149 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
149 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
150 | 150 | ['dashicons'] |
151 | 151 | ); |
152 | 152 | //Load custom style sheet if available |
153 | 153 | if ($this->template_config->custom_style_sheet !== null) { |
154 | 154 | $this->addStylesheet( |
155 | 155 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
156 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
156 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
157 | 157 | [CoreAssetManager::CSS_HANDLE_DEFAULT] |
158 | 158 | ); |
159 | 159 | } |