@@ -19,47 +19,47 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class EspressoEditorAssetManager extends AssetManager |
| 21 | 21 | { |
| 22 | - const JS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
| 23 | - const CSS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
| 24 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 25 | - const CSS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 22 | + const JS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
| 23 | + const CSS_HANDLE_EDITOR = 'eventespresso-editor'; |
|
| 24 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 25 | + const CSS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @throws InvalidDataTypeException |
|
| 29 | - * @throws InvalidEntityException |
|
| 30 | - * @throws DuplicateCollectionIdentifierException |
|
| 31 | - */ |
|
| 32 | - public function addAssets() |
|
| 33 | - { |
|
| 34 | - $this->registerJavascript(); |
|
| 35 | - $this->registerStyleSheets(); |
|
| 36 | - } |
|
| 27 | + /** |
|
| 28 | + * @throws InvalidDataTypeException |
|
| 29 | + * @throws InvalidEntityException |
|
| 30 | + * @throws DuplicateCollectionIdentifierException |
|
| 31 | + */ |
|
| 32 | + public function addAssets() |
|
| 33 | + { |
|
| 34 | + $this->registerJavascript(); |
|
| 35 | + $this->registerStyleSheets(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Register javascript assets |
|
| 41 | - * |
|
| 42 | - * @throws InvalidDataTypeException |
|
| 43 | - * @throws InvalidEntityException |
|
| 44 | - * @throws DuplicateCollectionIdentifierException |
|
| 45 | - */ |
|
| 46 | - private function registerJavascript() |
|
| 47 | - { |
|
| 48 | - $this->addJs(self::JS_HANDLE_EDITOR)->setRequiresTranslation(); |
|
| 49 | - $this->addJs(self::JS_HANDLE_EDITOR_HOCS)->setRequiresTranslation(); |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * Register javascript assets |
|
| 41 | + * |
|
| 42 | + * @throws InvalidDataTypeException |
|
| 43 | + * @throws InvalidEntityException |
|
| 44 | + * @throws DuplicateCollectionIdentifierException |
|
| 45 | + */ |
|
| 46 | + private function registerJavascript() |
|
| 47 | + { |
|
| 48 | + $this->addJs(self::JS_HANDLE_EDITOR)->setRequiresTranslation(); |
|
| 49 | + $this->addJs(self::JS_HANDLE_EDITOR_HOCS)->setRequiresTranslation(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Register CSS assets. |
|
| 55 | - * |
|
| 56 | - * @throws DuplicateCollectionIdentifierException |
|
| 57 | - * @throws InvalidDataTypeException |
|
| 58 | - * @throws InvalidEntityException |
|
| 59 | - */ |
|
| 60 | - private function registerStyleSheets() |
|
| 61 | - { |
|
| 62 | - $this->addCss(self::CSS_HANDLE_EDITOR); |
|
| 63 | - $this->addCss(self::CSS_HANDLE_EDITOR_HOCS); |
|
| 64 | - } |
|
| 53 | + /** |
|
| 54 | + * Register CSS assets. |
|
| 55 | + * |
|
| 56 | + * @throws DuplicateCollectionIdentifierException |
|
| 57 | + * @throws InvalidDataTypeException |
|
| 58 | + * @throws InvalidEntityException |
|
| 59 | + */ |
|
| 60 | + private function registerStyleSheets() |
|
| 61 | + { |
|
| 62 | + $this->addCss(self::CSS_HANDLE_EDITOR); |
|
| 63 | + $this->addCss(self::CSS_HANDLE_EDITOR_HOCS); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -32,462 +32,462 @@ |
||
| 32 | 32 | class CoreAssetManager extends AssetManager |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - // WordPress core / Third party JS asset handles |
|
| 36 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
| 35 | + // WordPress core / Third party JS asset handles |
|
| 36 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
| 37 | 37 | |
| 38 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
| 38 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
| 39 | 39 | |
| 40 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
| 40 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
| 41 | 41 | |
| 42 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
| 42 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
| 43 | 43 | |
| 44 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
| 44 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @since 4.9.71.p |
|
| 48 | - */ |
|
| 49 | - const JS_HANDLE_REACT = 'react'; |
|
| 46 | + /** |
|
| 47 | + * @since 4.9.71.p |
|
| 48 | + */ |
|
| 49 | + const JS_HANDLE_REACT = 'react'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @since 4.9.71.p |
|
| 53 | - */ |
|
| 54 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
| 51 | + /** |
|
| 52 | + * @since 4.9.71.p |
|
| 53 | + */ |
|
| 54 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @since 4.9.71.p |
|
| 58 | - */ |
|
| 59 | - const JS_HANDLE_LODASH = 'lodash'; |
|
| 56 | + /** |
|
| 57 | + * @since 4.9.71.p |
|
| 58 | + */ |
|
| 59 | + const JS_HANDLE_LODASH = 'lodash'; |
|
| 60 | 60 | |
| 61 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 61 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 62 | 62 | |
| 63 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 63 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 64 | 64 | |
| 65 | - const JS_HANDLE_UTILS = 'eventespresso-utils'; |
|
| 65 | + const JS_HANDLE_UTILS = 'eventespresso-utils'; |
|
| 66 | 66 | |
| 67 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
| 67 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
| 68 | 68 | |
| 69 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
| 69 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
| 70 | 70 | |
| 71 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
| 71 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
| 72 | 72 | |
| 73 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
| 73 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
| 74 | 74 | |
| 75 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 75 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 76 | 76 | |
| 77 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 77 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 78 | 78 | |
| 79 | - const JS_HANDLE_HOOKS = 'eventespresso-hooks'; |
|
| 79 | + const JS_HANDLE_HOOKS = 'eventespresso-hooks'; |
|
| 80 | 80 | |
| 81 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
| 81 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
| 82 | 82 | |
| 83 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
| 83 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
| 84 | 84 | |
| 85 | - const JS_HANDLE_I18N = 'eei18n'; |
|
| 85 | + const JS_HANDLE_I18N = 'eei18n'; |
|
| 86 | 86 | |
| 87 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
| 87 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
| 88 | 88 | |
| 89 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
| 89 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
| 90 | 90 | |
| 91 | - // EE CSS assets handles |
|
| 92 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 91 | + // EE CSS assets handles |
|
| 92 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 93 | 93 | |
| 94 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 95 | - |
|
| 96 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 97 | - |
|
| 98 | - const CSS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 99 | - |
|
| 100 | - const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default'; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @var EE_Currency_Config $currency_config |
|
| 104 | - */ |
|
| 105 | - protected $currency_config; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @var EE_Template_Config $template_config |
|
| 109 | - */ |
|
| 110 | - protected $template_config; |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * CoreAssetRegister constructor. |
|
| 115 | - * |
|
| 116 | - * @param AssetCollection $assets |
|
| 117 | - * @param EE_Currency_Config $currency_config |
|
| 118 | - * @param EE_Template_Config $template_config |
|
| 119 | - * @param DomainInterface $domain |
|
| 120 | - * @param Registry $registry |
|
| 121 | - */ |
|
| 122 | - public function __construct( |
|
| 123 | - AssetCollection $assets, |
|
| 124 | - EE_Currency_Config $currency_config, |
|
| 125 | - EE_Template_Config $template_config, |
|
| 126 | - DomainInterface $domain, |
|
| 127 | - Registry $registry |
|
| 128 | - ) { |
|
| 129 | - $this->currency_config = $currency_config; |
|
| 130 | - $this->template_config = $template_config; |
|
| 131 | - parent::__construct($domain, $assets, $registry); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @since 4.9.62.p |
|
| 137 | - * @throws DomainException |
|
| 138 | - * @throws DuplicateCollectionIdentifierException |
|
| 139 | - * @throws InvalidArgumentException |
|
| 140 | - * @throws InvalidDataTypeException |
|
| 141 | - * @throws InvalidEntityException |
|
| 142 | - * @throws InvalidInterfaceException |
|
| 143 | - */ |
|
| 144 | - public function addAssets() |
|
| 145 | - { |
|
| 146 | - $this->addJavascriptFiles(); |
|
| 147 | - $this->addStylesheetFiles(); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @since 4.9.62.p |
|
| 153 | - * @throws DomainException |
|
| 154 | - * @throws DuplicateCollectionIdentifierException |
|
| 155 | - * @throws InvalidArgumentException |
|
| 156 | - * @throws InvalidDataTypeException |
|
| 157 | - * @throws InvalidEntityException |
|
| 158 | - * @throws InvalidInterfaceException |
|
| 159 | - */ |
|
| 160 | - public function addJavascriptFiles() |
|
| 161 | - { |
|
| 162 | - $this->loadCoreJs(); |
|
| 163 | - $this->loadJqueryValidate(); |
|
| 164 | - $this->loadAccountingJs(); |
|
| 165 | - add_action( |
|
| 166 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
| 167 | - array($this, 'loadQtipJs') |
|
| 168 | - ); |
|
| 169 | - $this->registerAdminAssets(); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * @since 4.9.62.p |
|
| 175 | - * @throws DuplicateCollectionIdentifierException |
|
| 176 | - * @throws InvalidDataTypeException |
|
| 177 | - * @throws InvalidEntityException |
|
| 178 | - */ |
|
| 179 | - public function addStylesheetFiles() |
|
| 180 | - { |
|
| 181 | - $this->loadCoreCss(); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * core default javascript |
|
| 187 | - * |
|
| 188 | - * @since 4.9.62.p |
|
| 189 | - * @throws DomainException |
|
| 190 | - * @throws DuplicateCollectionIdentifierException |
|
| 191 | - * @throws InvalidArgumentException |
|
| 192 | - * @throws InvalidDataTypeException |
|
| 193 | - * @throws InvalidEntityException |
|
| 194 | - * @throws InvalidInterfaceException |
|
| 195 | - */ |
|
| 196 | - private function loadCoreJs() |
|
| 197 | - { |
|
| 198 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
| 199 | - $this->registerWpAssets(); |
|
| 200 | - |
|
| 201 | - $this->addJs(self::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
| 202 | - $this->addJs(self::JS_HANDLE_VENDOR); |
|
| 203 | - $this->addJs(self::JS_HANDLE_UTILS)->setRequiresTranslation(); |
|
| 204 | - $this->addJs(self::JS_HANDLE_VALIDATORS)->setRequiresTranslation(); |
|
| 205 | - $this->addJs(self::JS_HANDLE_HELPERS)->setRequiresTranslation(); |
|
| 206 | - $this->addJs(self::JS_HANDLE_MODEL)->setRequiresTranslation(); |
|
| 207 | - $this->addJs(self::JS_HANDLE_HOOKS); |
|
| 208 | - $this->addJs(self::JS_HANDLE_VALUE_OBJECTS)->setRequiresTranslation(); |
|
| 209 | - $this->addJs(self::JS_HANDLE_DATA_STORES)->setRequiresTranslation()->setInlineDataCallback( |
|
| 210 | - static function () { |
|
| 211 | - wp_add_inline_script( |
|
| 212 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 213 | - is_admin() |
|
| 214 | - ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
| 215 | - : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
| 216 | - ); |
|
| 217 | - } |
|
| 218 | - ); |
|
| 219 | - $this->addJs(self::JS_HANDLE_HOCS, self::JS_HANDLE_DATA_STORES)->setRequiresTranslation(); |
|
| 220 | - $this->addJs(self::JS_HANDLE_COMPONENTS, self::JS_HANDLE_DATA_STORES)->setRequiresTranslation(); |
|
| 221 | - |
|
| 222 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 223 | - $this->registry->addData( |
|
| 224 | - 'paths', |
|
| 225 | - array( |
|
| 226 | - 'base_rest_route' => rest_url(), |
|
| 227 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 228 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 229 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 230 | - 'site_url' => site_url('/'), |
|
| 231 | - 'admin_url' => admin_url('/'), |
|
| 232 | - ) |
|
| 233 | - ); |
|
| 234 | - // Event Espresso brand name |
|
| 235 | - $this->registry->addData('brandName', Domain::brandName()); |
|
| 236 | - /** site formatting values **/ |
|
| 237 | - $this->registry->addData( |
|
| 238 | - 'site_formats', |
|
| 239 | - array( |
|
| 240 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
| 241 | - ) |
|
| 242 | - ); |
|
| 243 | - /** currency data **/ |
|
| 244 | - $this->registry->addData( |
|
| 245 | - 'currency_config', |
|
| 246 | - $this->getCurrencySettings() |
|
| 247 | - ); |
|
| 248 | - /** site timezone */ |
|
| 249 | - $this->registry->addData( |
|
| 250 | - 'default_timezone', |
|
| 251 | - array( |
|
| 252 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 253 | - 'string' => get_option('timezone_string'), |
|
| 254 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 255 | - ) |
|
| 256 | - ); |
|
| 257 | - /** site locale (user locale if user logged in) */ |
|
| 258 | - $this->registry->addData( |
|
| 259 | - 'locale', |
|
| 260 | - array( |
|
| 261 | - 'user' => get_user_locale(), |
|
| 262 | - 'site' => get_locale() |
|
| 263 | - ) |
|
| 264 | - ); |
|
| 265 | - |
|
| 266 | - $this->addJavascript( |
|
| 267 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 268 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 269 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 270 | - ) |
|
| 271 | - ->setInlineDataCallback( |
|
| 272 | - static function () { |
|
| 273 | - wp_localize_script( |
|
| 274 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 275 | - CoreAssetManager::JS_HANDLE_I18N, |
|
| 276 | - EE_Registry::$i18n_js_strings |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - ); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
| 285 | - * WordPress in the running environment. |
|
| 286 | - * |
|
| 287 | - * @throws DuplicateCollectionIdentifierException |
|
| 288 | - * @throws InvalidDataTypeException |
|
| 289 | - * @throws InvalidEntityException |
|
| 290 | - * @throws DomainException |
|
| 291 | - * @since 4.9.71.p |
|
| 292 | - */ |
|
| 293 | - private function registerWpAssets() |
|
| 294 | - { |
|
| 295 | - global $wp_version; |
|
| 296 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
| 297 | - return; |
|
| 298 | - } |
|
| 299 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
| 300 | - ->setVersion('16.6.0'); |
|
| 301 | - $this->addVendorJavascript( |
|
| 302 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 303 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
| 304 | - )->setVersion('16.6.0'); |
|
| 305 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
| 306 | - ->setInlineDataCallback( |
|
| 307 | - static function() { |
|
| 308 | - wp_add_inline_script( |
|
| 309 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
| 310 | - 'window.lodash = _.noConflict();' |
|
| 311 | - ); |
|
| 312 | - } |
|
| 313 | - ) |
|
| 314 | - ->setVersion('4.17.11'); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Returns configuration data for the accounting-js library. |
|
| 320 | - * @since 4.9.71.p |
|
| 321 | - * @return array |
|
| 322 | - */ |
|
| 323 | - private function getAccountingSettings() { |
|
| 324 | - return array( |
|
| 325 | - 'currency' => array( |
|
| 326 | - 'symbol' => $this->currency_config->sign, |
|
| 327 | - 'format' => array( |
|
| 328 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
| 329 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
| 330 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
| 331 | - ), |
|
| 332 | - 'decimal' => $this->currency_config->dec_mrk, |
|
| 333 | - 'thousand' => $this->currency_config->thsnds, |
|
| 334 | - 'precision' => $this->currency_config->dec_plc, |
|
| 335 | - ), |
|
| 336 | - 'number' => array( |
|
| 337 | - 'precision' => $this->currency_config->dec_plc, |
|
| 338 | - 'thousand' => $this->currency_config->thsnds, |
|
| 339 | - 'decimal' => $this->currency_config->dec_mrk, |
|
| 340 | - ), |
|
| 341 | - ); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * Returns configuration data for the js Currency VO. |
|
| 347 | - * @since 4.9.71.p |
|
| 348 | - * @return array |
|
| 349 | - */ |
|
| 350 | - private function getCurrencySettings() |
|
| 351 | - { |
|
| 352 | - return array( |
|
| 353 | - 'code' => $this->currency_config->code, |
|
| 354 | - 'singularLabel' => $this->currency_config->name, |
|
| 355 | - 'pluralLabel' => $this->currency_config->plural, |
|
| 356 | - 'sign' => $this->currency_config->sign, |
|
| 357 | - 'signB4' => $this->currency_config->sign_b4, |
|
| 358 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 359 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 360 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 361 | - ); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * @since 4.9.62.p |
|
| 367 | - * @throws DuplicateCollectionIdentifierException |
|
| 368 | - * @throws InvalidDataTypeException |
|
| 369 | - * @throws InvalidEntityException |
|
| 370 | - */ |
|
| 371 | - private function loadCoreCss() |
|
| 372 | - { |
|
| 373 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 374 | - $this->addStylesheet( |
|
| 375 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 376 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
| 377 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
| 378 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 379 | - array('dashicons') |
|
| 380 | - ); |
|
| 381 | - //Load custom style sheet if available |
|
| 382 | - if ($this->template_config->custom_style_sheet !== null) { |
|
| 383 | - $this->addStylesheet( |
|
| 384 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 385 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 386 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
| 387 | - ); |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - $this->addCss(self::CSS_HANDLE_CORE_CSS_DEFAULT, 'dashicons'); |
|
| 391 | - $this->addCss(self::CSS_HANDLE_COMPONENTS, self::CSS_HANDLE_CORE_CSS_DEFAULT); |
|
| 392 | - $this->addCss(self::CSS_HANDLE_HOCS); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * jQuery Validate for form validation |
|
| 398 | - * |
|
| 399 | - * @since 4.9.62.p |
|
| 400 | - * @throws DomainException |
|
| 401 | - * @throws DuplicateCollectionIdentifierException |
|
| 402 | - * @throws InvalidDataTypeException |
|
| 403 | - * @throws InvalidEntityException |
|
| 404 | - */ |
|
| 405 | - private function loadJqueryValidate() |
|
| 406 | - { |
|
| 407 | - $this->addJavascript( |
|
| 408 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
| 409 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 410 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 411 | - ) |
|
| 412 | - ->setVersion('1.15.0'); |
|
| 413 | - |
|
| 414 | - $this->addJavascript( |
|
| 415 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
| 416 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 417 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
| 418 | - ) |
|
| 419 | - ->setVersion('1.15.0'); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * accounting.js for performing client-side calculations |
|
| 425 | - * |
|
| 426 | - * @since 4.9.62.p |
|
| 427 | - * @throws DomainException |
|
| 428 | - * @throws DuplicateCollectionIdentifierException |
|
| 429 | - * @throws InvalidDataTypeException |
|
| 430 | - * @throws InvalidEntityException |
|
| 431 | - */ |
|
| 432 | - private function loadAccountingJs() |
|
| 433 | - { |
|
| 434 | - //accounting.js library |
|
| 435 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
| 436 | - $this->addJavascript( |
|
| 437 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
| 438 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
| 439 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
| 440 | - ) |
|
| 441 | - ->setVersion('0.3.2'); |
|
| 442 | - |
|
| 443 | - $this->addJavascript( |
|
| 444 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 445 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
| 446 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
| 447 | - ) |
|
| 448 | - ->setInlineDataCallback( |
|
| 449 | - function () { |
|
| 450 | - wp_localize_script( |
|
| 451 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 452 | - 'EE_ACCOUNTING_CFG', |
|
| 453 | - $this->getAccountingSettings() |
|
| 454 | - ); |
|
| 455 | - } |
|
| 456 | - ) |
|
| 457 | - ->setVersion(); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * registers assets for cleaning your ears |
|
| 463 | - * |
|
| 464 | - * @param JavascriptAsset $script |
|
| 465 | - */ |
|
| 466 | - public function loadQtipJs(JavascriptAsset $script) |
|
| 467 | - { |
|
| 468 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
| 469 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
| 470 | - if ( |
|
| 471 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
| 472 | - && apply_filters('FHEE_load_qtip', false) |
|
| 473 | - ) { |
|
| 474 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - |
|
| 479 | - /** |
|
| 480 | - * assets that are used in the WordPress admin |
|
| 481 | - * |
|
| 482 | - * @since 4.9.62.p |
|
| 483 | - * @throws DuplicateCollectionIdentifierException |
|
| 484 | - * @throws InvalidDataTypeException |
|
| 485 | - * @throws InvalidEntityException |
|
| 486 | - */ |
|
| 487 | - private function registerAdminAssets() |
|
| 488 | - { |
|
| 489 | - $this->addJs(self::JS_HANDLE_WP_PLUGINS_PAGE)->setRequiresTranslation(); |
|
| 490 | - // note usage of the "JS_HANDLE.." constant is intentional here because css uses the same handle. |
|
| 491 | - $this->addCss(self::JS_HANDLE_WP_PLUGINS_PAGE); |
|
| 492 | - } |
|
| 94 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 95 | + |
|
| 96 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 97 | + |
|
| 98 | + const CSS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 99 | + |
|
| 100 | + const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default'; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @var EE_Currency_Config $currency_config |
|
| 104 | + */ |
|
| 105 | + protected $currency_config; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @var EE_Template_Config $template_config |
|
| 109 | + */ |
|
| 110 | + protected $template_config; |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * CoreAssetRegister constructor. |
|
| 115 | + * |
|
| 116 | + * @param AssetCollection $assets |
|
| 117 | + * @param EE_Currency_Config $currency_config |
|
| 118 | + * @param EE_Template_Config $template_config |
|
| 119 | + * @param DomainInterface $domain |
|
| 120 | + * @param Registry $registry |
|
| 121 | + */ |
|
| 122 | + public function __construct( |
|
| 123 | + AssetCollection $assets, |
|
| 124 | + EE_Currency_Config $currency_config, |
|
| 125 | + EE_Template_Config $template_config, |
|
| 126 | + DomainInterface $domain, |
|
| 127 | + Registry $registry |
|
| 128 | + ) { |
|
| 129 | + $this->currency_config = $currency_config; |
|
| 130 | + $this->template_config = $template_config; |
|
| 131 | + parent::__construct($domain, $assets, $registry); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @since 4.9.62.p |
|
| 137 | + * @throws DomainException |
|
| 138 | + * @throws DuplicateCollectionIdentifierException |
|
| 139 | + * @throws InvalidArgumentException |
|
| 140 | + * @throws InvalidDataTypeException |
|
| 141 | + * @throws InvalidEntityException |
|
| 142 | + * @throws InvalidInterfaceException |
|
| 143 | + */ |
|
| 144 | + public function addAssets() |
|
| 145 | + { |
|
| 146 | + $this->addJavascriptFiles(); |
|
| 147 | + $this->addStylesheetFiles(); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @since 4.9.62.p |
|
| 153 | + * @throws DomainException |
|
| 154 | + * @throws DuplicateCollectionIdentifierException |
|
| 155 | + * @throws InvalidArgumentException |
|
| 156 | + * @throws InvalidDataTypeException |
|
| 157 | + * @throws InvalidEntityException |
|
| 158 | + * @throws InvalidInterfaceException |
|
| 159 | + */ |
|
| 160 | + public function addJavascriptFiles() |
|
| 161 | + { |
|
| 162 | + $this->loadCoreJs(); |
|
| 163 | + $this->loadJqueryValidate(); |
|
| 164 | + $this->loadAccountingJs(); |
|
| 165 | + add_action( |
|
| 166 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
| 167 | + array($this, 'loadQtipJs') |
|
| 168 | + ); |
|
| 169 | + $this->registerAdminAssets(); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * @since 4.9.62.p |
|
| 175 | + * @throws DuplicateCollectionIdentifierException |
|
| 176 | + * @throws InvalidDataTypeException |
|
| 177 | + * @throws InvalidEntityException |
|
| 178 | + */ |
|
| 179 | + public function addStylesheetFiles() |
|
| 180 | + { |
|
| 181 | + $this->loadCoreCss(); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * core default javascript |
|
| 187 | + * |
|
| 188 | + * @since 4.9.62.p |
|
| 189 | + * @throws DomainException |
|
| 190 | + * @throws DuplicateCollectionIdentifierException |
|
| 191 | + * @throws InvalidArgumentException |
|
| 192 | + * @throws InvalidDataTypeException |
|
| 193 | + * @throws InvalidEntityException |
|
| 194 | + * @throws InvalidInterfaceException |
|
| 195 | + */ |
|
| 196 | + private function loadCoreJs() |
|
| 197 | + { |
|
| 198 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
| 199 | + $this->registerWpAssets(); |
|
| 200 | + |
|
| 201 | + $this->addJs(self::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
| 202 | + $this->addJs(self::JS_HANDLE_VENDOR); |
|
| 203 | + $this->addJs(self::JS_HANDLE_UTILS)->setRequiresTranslation(); |
|
| 204 | + $this->addJs(self::JS_HANDLE_VALIDATORS)->setRequiresTranslation(); |
|
| 205 | + $this->addJs(self::JS_HANDLE_HELPERS)->setRequiresTranslation(); |
|
| 206 | + $this->addJs(self::JS_HANDLE_MODEL)->setRequiresTranslation(); |
|
| 207 | + $this->addJs(self::JS_HANDLE_HOOKS); |
|
| 208 | + $this->addJs(self::JS_HANDLE_VALUE_OBJECTS)->setRequiresTranslation(); |
|
| 209 | + $this->addJs(self::JS_HANDLE_DATA_STORES)->setRequiresTranslation()->setInlineDataCallback( |
|
| 210 | + static function () { |
|
| 211 | + wp_add_inline_script( |
|
| 212 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 213 | + is_admin() |
|
| 214 | + ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
| 215 | + : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
| 216 | + ); |
|
| 217 | + } |
|
| 218 | + ); |
|
| 219 | + $this->addJs(self::JS_HANDLE_HOCS, self::JS_HANDLE_DATA_STORES)->setRequiresTranslation(); |
|
| 220 | + $this->addJs(self::JS_HANDLE_COMPONENTS, self::JS_HANDLE_DATA_STORES)->setRequiresTranslation(); |
|
| 221 | + |
|
| 222 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 223 | + $this->registry->addData( |
|
| 224 | + 'paths', |
|
| 225 | + array( |
|
| 226 | + 'base_rest_route' => rest_url(), |
|
| 227 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 228 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 229 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 230 | + 'site_url' => site_url('/'), |
|
| 231 | + 'admin_url' => admin_url('/'), |
|
| 232 | + ) |
|
| 233 | + ); |
|
| 234 | + // Event Espresso brand name |
|
| 235 | + $this->registry->addData('brandName', Domain::brandName()); |
|
| 236 | + /** site formatting values **/ |
|
| 237 | + $this->registry->addData( |
|
| 238 | + 'site_formats', |
|
| 239 | + array( |
|
| 240 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
| 241 | + ) |
|
| 242 | + ); |
|
| 243 | + /** currency data **/ |
|
| 244 | + $this->registry->addData( |
|
| 245 | + 'currency_config', |
|
| 246 | + $this->getCurrencySettings() |
|
| 247 | + ); |
|
| 248 | + /** site timezone */ |
|
| 249 | + $this->registry->addData( |
|
| 250 | + 'default_timezone', |
|
| 251 | + array( |
|
| 252 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 253 | + 'string' => get_option('timezone_string'), |
|
| 254 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 255 | + ) |
|
| 256 | + ); |
|
| 257 | + /** site locale (user locale if user logged in) */ |
|
| 258 | + $this->registry->addData( |
|
| 259 | + 'locale', |
|
| 260 | + array( |
|
| 261 | + 'user' => get_user_locale(), |
|
| 262 | + 'site' => get_locale() |
|
| 263 | + ) |
|
| 264 | + ); |
|
| 265 | + |
|
| 266 | + $this->addJavascript( |
|
| 267 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 268 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 269 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 270 | + ) |
|
| 271 | + ->setInlineDataCallback( |
|
| 272 | + static function () { |
|
| 273 | + wp_localize_script( |
|
| 274 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 275 | + CoreAssetManager::JS_HANDLE_I18N, |
|
| 276 | + EE_Registry::$i18n_js_strings |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + ); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
| 285 | + * WordPress in the running environment. |
|
| 286 | + * |
|
| 287 | + * @throws DuplicateCollectionIdentifierException |
|
| 288 | + * @throws InvalidDataTypeException |
|
| 289 | + * @throws InvalidEntityException |
|
| 290 | + * @throws DomainException |
|
| 291 | + * @since 4.9.71.p |
|
| 292 | + */ |
|
| 293 | + private function registerWpAssets() |
|
| 294 | + { |
|
| 295 | + global $wp_version; |
|
| 296 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
| 297 | + return; |
|
| 298 | + } |
|
| 299 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
| 300 | + ->setVersion('16.6.0'); |
|
| 301 | + $this->addVendorJavascript( |
|
| 302 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 303 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
| 304 | + )->setVersion('16.6.0'); |
|
| 305 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
| 306 | + ->setInlineDataCallback( |
|
| 307 | + static function() { |
|
| 308 | + wp_add_inline_script( |
|
| 309 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
| 310 | + 'window.lodash = _.noConflict();' |
|
| 311 | + ); |
|
| 312 | + } |
|
| 313 | + ) |
|
| 314 | + ->setVersion('4.17.11'); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Returns configuration data for the accounting-js library. |
|
| 320 | + * @since 4.9.71.p |
|
| 321 | + * @return array |
|
| 322 | + */ |
|
| 323 | + private function getAccountingSettings() { |
|
| 324 | + return array( |
|
| 325 | + 'currency' => array( |
|
| 326 | + 'symbol' => $this->currency_config->sign, |
|
| 327 | + 'format' => array( |
|
| 328 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
| 329 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
| 330 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
| 331 | + ), |
|
| 332 | + 'decimal' => $this->currency_config->dec_mrk, |
|
| 333 | + 'thousand' => $this->currency_config->thsnds, |
|
| 334 | + 'precision' => $this->currency_config->dec_plc, |
|
| 335 | + ), |
|
| 336 | + 'number' => array( |
|
| 337 | + 'precision' => $this->currency_config->dec_plc, |
|
| 338 | + 'thousand' => $this->currency_config->thsnds, |
|
| 339 | + 'decimal' => $this->currency_config->dec_mrk, |
|
| 340 | + ), |
|
| 341 | + ); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * Returns configuration data for the js Currency VO. |
|
| 347 | + * @since 4.9.71.p |
|
| 348 | + * @return array |
|
| 349 | + */ |
|
| 350 | + private function getCurrencySettings() |
|
| 351 | + { |
|
| 352 | + return array( |
|
| 353 | + 'code' => $this->currency_config->code, |
|
| 354 | + 'singularLabel' => $this->currency_config->name, |
|
| 355 | + 'pluralLabel' => $this->currency_config->plural, |
|
| 356 | + 'sign' => $this->currency_config->sign, |
|
| 357 | + 'signB4' => $this->currency_config->sign_b4, |
|
| 358 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 359 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 360 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 361 | + ); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * @since 4.9.62.p |
|
| 367 | + * @throws DuplicateCollectionIdentifierException |
|
| 368 | + * @throws InvalidDataTypeException |
|
| 369 | + * @throws InvalidEntityException |
|
| 370 | + */ |
|
| 371 | + private function loadCoreCss() |
|
| 372 | + { |
|
| 373 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 374 | + $this->addStylesheet( |
|
| 375 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 376 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
| 377 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
| 378 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 379 | + array('dashicons') |
|
| 380 | + ); |
|
| 381 | + //Load custom style sheet if available |
|
| 382 | + if ($this->template_config->custom_style_sheet !== null) { |
|
| 383 | + $this->addStylesheet( |
|
| 384 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 385 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 386 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
| 387 | + ); |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + $this->addCss(self::CSS_HANDLE_CORE_CSS_DEFAULT, 'dashicons'); |
|
| 391 | + $this->addCss(self::CSS_HANDLE_COMPONENTS, self::CSS_HANDLE_CORE_CSS_DEFAULT); |
|
| 392 | + $this->addCss(self::CSS_HANDLE_HOCS); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * jQuery Validate for form validation |
|
| 398 | + * |
|
| 399 | + * @since 4.9.62.p |
|
| 400 | + * @throws DomainException |
|
| 401 | + * @throws DuplicateCollectionIdentifierException |
|
| 402 | + * @throws InvalidDataTypeException |
|
| 403 | + * @throws InvalidEntityException |
|
| 404 | + */ |
|
| 405 | + private function loadJqueryValidate() |
|
| 406 | + { |
|
| 407 | + $this->addJavascript( |
|
| 408 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
| 409 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 410 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 411 | + ) |
|
| 412 | + ->setVersion('1.15.0'); |
|
| 413 | + |
|
| 414 | + $this->addJavascript( |
|
| 415 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
| 416 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 417 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
| 418 | + ) |
|
| 419 | + ->setVersion('1.15.0'); |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * accounting.js for performing client-side calculations |
|
| 425 | + * |
|
| 426 | + * @since 4.9.62.p |
|
| 427 | + * @throws DomainException |
|
| 428 | + * @throws DuplicateCollectionIdentifierException |
|
| 429 | + * @throws InvalidDataTypeException |
|
| 430 | + * @throws InvalidEntityException |
|
| 431 | + */ |
|
| 432 | + private function loadAccountingJs() |
|
| 433 | + { |
|
| 434 | + //accounting.js library |
|
| 435 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
| 436 | + $this->addJavascript( |
|
| 437 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
| 438 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
| 439 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
| 440 | + ) |
|
| 441 | + ->setVersion('0.3.2'); |
|
| 442 | + |
|
| 443 | + $this->addJavascript( |
|
| 444 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 445 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
| 446 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
| 447 | + ) |
|
| 448 | + ->setInlineDataCallback( |
|
| 449 | + function () { |
|
| 450 | + wp_localize_script( |
|
| 451 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 452 | + 'EE_ACCOUNTING_CFG', |
|
| 453 | + $this->getAccountingSettings() |
|
| 454 | + ); |
|
| 455 | + } |
|
| 456 | + ) |
|
| 457 | + ->setVersion(); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * registers assets for cleaning your ears |
|
| 463 | + * |
|
| 464 | + * @param JavascriptAsset $script |
|
| 465 | + */ |
|
| 466 | + public function loadQtipJs(JavascriptAsset $script) |
|
| 467 | + { |
|
| 468 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
| 469 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
| 470 | + if ( |
|
| 471 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
| 472 | + && apply_filters('FHEE_load_qtip', false) |
|
| 473 | + ) { |
|
| 474 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + |
|
| 479 | + /** |
|
| 480 | + * assets that are used in the WordPress admin |
|
| 481 | + * |
|
| 482 | + * @since 4.9.62.p |
|
| 483 | + * @throws DuplicateCollectionIdentifierException |
|
| 484 | + * @throws InvalidDataTypeException |
|
| 485 | + * @throws InvalidEntityException |
|
| 486 | + */ |
|
| 487 | + private function registerAdminAssets() |
|
| 488 | + { |
|
| 489 | + $this->addJs(self::JS_HANDLE_WP_PLUGINS_PAGE)->setRequiresTranslation(); |
|
| 490 | + // note usage of the "JS_HANDLE.." constant is intentional here because css uses the same handle. |
|
| 491 | + $this->addCss(self::JS_HANDLE_WP_PLUGINS_PAGE); |
|
| 492 | + } |
|
| 493 | 493 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $this->addJs(self::JS_HANDLE_HOOKS); |
| 208 | 208 | $this->addJs(self::JS_HANDLE_VALUE_OBJECTS)->setRequiresTranslation(); |
| 209 | 209 | $this->addJs(self::JS_HANDLE_DATA_STORES)->setRequiresTranslation()->setInlineDataCallback( |
| 210 | - static function () { |
|
| 210 | + static function() { |
|
| 211 | 211 | wp_add_inline_script( |
| 212 | 212 | CoreAssetManager::JS_HANDLE_DATA_STORES, |
| 213 | 213 | is_admin() |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $this->addJavascript( |
| 267 | 267 | CoreAssetManager::JS_HANDLE_CORE, |
| 268 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 268 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
| 269 | 269 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
| 270 | 270 | ) |
| 271 | 271 | ->setInlineDataCallback( |
| 272 | - static function () { |
|
| 272 | + static function() { |
|
| 273 | 273 | wp_localize_script( |
| 274 | 274 | CoreAssetManager::JS_HANDLE_CORE, |
| 275 | 275 | CoreAssetManager::JS_HANDLE_I18N, |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | if ($this->template_config->enable_default_style && ! is_admin()) { |
| 374 | 374 | $this->addStylesheet( |
| 375 | 375 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
| 376 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
| 376 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
| 377 | 377 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
| 378 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 378 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
| 379 | 379 | array('dashicons') |
| 380 | 380 | ); |
| 381 | 381 | //Load custom style sheet if available |
| 382 | 382 | if ($this->template_config->custom_style_sheet !== null) { |
| 383 | 383 | $this->addStylesheet( |
| 384 | 384 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
| 385 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 385 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
| 386 | 386 | array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
| 387 | 387 | ); |
| 388 | 388 | } |
@@ -406,14 +406,14 @@ discard block |
||
| 406 | 406 | { |
| 407 | 407 | $this->addJavascript( |
| 408 | 408 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
| 409 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 409 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
| 410 | 410 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
| 411 | 411 | ) |
| 412 | 412 | ->setVersion('1.15.0'); |
| 413 | 413 | |
| 414 | 414 | $this->addJavascript( |
| 415 | 415 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
| 416 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 416 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
| 417 | 417 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
| 418 | 418 | ) |
| 419 | 419 | ->setVersion('1.15.0'); |
@@ -435,18 +435,18 @@ discard block |
||
| 435 | 435 | // @link http://josscrowcroft.github.io/accounting.js/ |
| 436 | 436 | $this->addJavascript( |
| 437 | 437 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
| 438 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
| 438 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
| 439 | 439 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
| 440 | 440 | ) |
| 441 | 441 | ->setVersion('0.3.2'); |
| 442 | 442 | |
| 443 | 443 | $this->addJavascript( |
| 444 | 444 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
| 445 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
| 445 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
| 446 | 446 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
| 447 | 447 | ) |
| 448 | 448 | ->setInlineDataCallback( |
| 449 | - function () { |
|
| 449 | + function() { |
|
| 450 | 450 | wp_localize_script( |
| 451 | 451 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
| 452 | 452 | 'EE_ACCOUNTING_CFG', |