@@ -20,127 +20,127 @@ |
||
| 20 | 20 | class AssetRequests extends Route |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * returns true if the current request matches this route |
|
| 25 | - * |
|
| 26 | - * @return bool |
|
| 27 | - * @since $VID:$ |
|
| 28 | - */ |
|
| 29 | - public function matchesCurrentRequest() |
|
| 30 | - { |
|
| 31 | - return $this->request->isAdmin() |
|
| 32 | - || $this->request->isFrontend() |
|
| 33 | - || $this->request->isIframe() |
|
| 34 | - || $this->request->isWordPressApi(); |
|
| 35 | - } |
|
| 23 | + /** |
|
| 24 | + * returns true if the current request matches this route |
|
| 25 | + * |
|
| 26 | + * @return bool |
|
| 27 | + * @since $VID:$ |
|
| 28 | + */ |
|
| 29 | + public function matchesCurrentRequest() |
|
| 30 | + { |
|
| 31 | + return $this->request->isAdmin() |
|
| 32 | + || $this->request->isFrontend() |
|
| 33 | + || $this->request->isIframe() |
|
| 34 | + || $this->request->isWordPressApi(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @since $VID:$ |
|
| 40 | - */ |
|
| 41 | - protected function registerDependencies() |
|
| 42 | - { |
|
| 43 | - $default_dependencies = [ |
|
| 44 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 45 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 46 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 47 | - ]; |
|
| 48 | - $this->dependency_map->registerDependencies(JqueryAssetManager::class, $default_dependencies); |
|
| 49 | - $this->dependency_map->registerDependencies(ReactAssetManager::class, $default_dependencies); |
|
| 50 | - $this->dependency_map->registerDependencies( |
|
| 51 | - CoreAssetManager::class, |
|
| 52 | - [ |
|
| 53 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 54 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 55 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 56 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 57 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 58 | - ] |
|
| 59 | - ); |
|
| 60 | - $this->dependency_map->registerDependencies( |
|
| 61 | - 'EventEspresso\core\services\editor\BlockRegistrationManager', |
|
| 62 | - [ |
|
| 63 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
| 64 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
| 65 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 66 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 67 | - ] |
|
| 68 | - ); |
|
| 69 | - $this->dependency_map->registerDependencies( |
|
| 70 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager', |
|
| 71 | - [ |
|
| 72 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 73 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 74 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 75 | - ] |
|
| 76 | - ); |
|
| 77 | - $this->dependency_map->registerDependencies( |
|
| 78 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer', |
|
| 79 | - [ |
|
| 80 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 81 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 82 | - ] |
|
| 83 | - ); |
|
| 84 | - $this->dependency_map->registerDependencies( |
|
| 85 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees', |
|
| 86 | - [ |
|
| 87 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => EE_Dependency_Map::load_from_cache, |
|
| 88 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 89 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => EE_Dependency_Map::load_from_cache, |
|
| 90 | - ] |
|
| 91 | - ); |
|
| 92 | - if (apply_filters( |
|
| 93 | - 'FHEE__EventEspresso_core_domain_entities_routing_handlers_shared_AssetRequests__load_Barista', |
|
| 94 | - true |
|
| 95 | - )) { |
|
| 96 | - $this->dependency_map->registerDependencies( |
|
| 97 | - 'EventEspresso\core\services\assets\Barista', |
|
| 98 | - ['EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache] |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - } |
|
| 38 | + /** |
|
| 39 | + * @since $VID:$ |
|
| 40 | + */ |
|
| 41 | + protected function registerDependencies() |
|
| 42 | + { |
|
| 43 | + $default_dependencies = [ |
|
| 44 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 45 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 46 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 47 | + ]; |
|
| 48 | + $this->dependency_map->registerDependencies(JqueryAssetManager::class, $default_dependencies); |
|
| 49 | + $this->dependency_map->registerDependencies(ReactAssetManager::class, $default_dependencies); |
|
| 50 | + $this->dependency_map->registerDependencies( |
|
| 51 | + CoreAssetManager::class, |
|
| 52 | + [ |
|
| 53 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 54 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 55 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 56 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 57 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 58 | + ] |
|
| 59 | + ); |
|
| 60 | + $this->dependency_map->registerDependencies( |
|
| 61 | + 'EventEspresso\core\services\editor\BlockRegistrationManager', |
|
| 62 | + [ |
|
| 63 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
| 64 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
| 65 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 66 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 67 | + ] |
|
| 68 | + ); |
|
| 69 | + $this->dependency_map->registerDependencies( |
|
| 70 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager', |
|
| 71 | + [ |
|
| 72 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 73 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
| 74 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 75 | + ] |
|
| 76 | + ); |
|
| 77 | + $this->dependency_map->registerDependencies( |
|
| 78 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer', |
|
| 79 | + [ |
|
| 80 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 81 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 82 | + ] |
|
| 83 | + ); |
|
| 84 | + $this->dependency_map->registerDependencies( |
|
| 85 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees', |
|
| 86 | + [ |
|
| 87 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => EE_Dependency_Map::load_from_cache, |
|
| 88 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 89 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => EE_Dependency_Map::load_from_cache, |
|
| 90 | + ] |
|
| 91 | + ); |
|
| 92 | + if (apply_filters( |
|
| 93 | + 'FHEE__EventEspresso_core_domain_entities_routing_handlers_shared_AssetRequests__load_Barista', |
|
| 94 | + true |
|
| 95 | + )) { |
|
| 96 | + $this->dependency_map->registerDependencies( |
|
| 97 | + 'EventEspresso\core\services\assets\Barista', |
|
| 98 | + ['EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache] |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * implements logic required to run during request |
|
| 106 | - * |
|
| 107 | - * @return bool |
|
| 108 | - * @since $VID:$ |
|
| 109 | - */ |
|
| 110 | - protected function requestHandler() |
|
| 111 | - { |
|
| 112 | - if (apply_filters( |
|
| 113 | - 'FHEE__EventEspresso_core_domain_entities_routing_handlers_shared_AssetRequests__load_Barista', |
|
| 114 | - true |
|
| 115 | - )) { |
|
| 116 | - /** @var Barista $barista */ |
|
| 117 | - $barista = $this->loader->getShared('EventEspresso\core\services\assets\Barista'); |
|
| 118 | - $barista->initialize(); |
|
| 119 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 120 | - } |
|
| 121 | - $this->loader->getShared(JqueryAssetManager::class); |
|
| 122 | - $this->loader->getShared(CoreAssetManager::class); |
|
| 123 | - if ($this->canLoadBlocks()) { |
|
| 124 | - $this->loader->getShared( |
|
| 125 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
| 126 | - ); |
|
| 127 | - } |
|
| 128 | - return true; |
|
| 129 | - } |
|
| 104 | + /** |
|
| 105 | + * implements logic required to run during request |
|
| 106 | + * |
|
| 107 | + * @return bool |
|
| 108 | + * @since $VID:$ |
|
| 109 | + */ |
|
| 110 | + protected function requestHandler() |
|
| 111 | + { |
|
| 112 | + if (apply_filters( |
|
| 113 | + 'FHEE__EventEspresso_core_domain_entities_routing_handlers_shared_AssetRequests__load_Barista', |
|
| 114 | + true |
|
| 115 | + )) { |
|
| 116 | + /** @var Barista $barista */ |
|
| 117 | + $barista = $this->loader->getShared('EventEspresso\core\services\assets\Barista'); |
|
| 118 | + $barista->initialize(); |
|
| 119 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 120 | + } |
|
| 121 | + $this->loader->getShared(JqueryAssetManager::class); |
|
| 122 | + $this->loader->getShared(CoreAssetManager::class); |
|
| 123 | + if ($this->canLoadBlocks()) { |
|
| 124 | + $this->loader->getShared( |
|
| 125 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
| 126 | + ); |
|
| 127 | + } |
|
| 128 | + return true; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Return whether blocks can be registered/loaded or not. |
|
| 134 | - * |
|
| 135 | - * @return bool |
|
| 136 | - * @since $VID:$ |
|
| 137 | - */ |
|
| 138 | - private function canLoadBlocks() |
|
| 139 | - { |
|
| 140 | - return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
| 141 | - && function_exists('register_block_type') |
|
| 142 | - // don't load blocks if in the Divi page builder editor context |
|
| 143 | - // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
| 144 | - && ! $this->request->getRequestParam('et_fb', false); |
|
| 145 | - } |
|
| 132 | + /** |
|
| 133 | + * Return whether blocks can be registered/loaded or not. |
|
| 134 | + * |
|
| 135 | + * @return bool |
|
| 136 | + * @since $VID:$ |
|
| 137 | + */ |
|
| 138 | + private function canLoadBlocks() |
|
| 139 | + { |
|
| 140 | + return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
| 141 | + && function_exists('register_block_type') |
|
| 142 | + // don't load blocks if in the Divi page builder editor context |
|
| 143 | + // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
| 144 | + && ! $this->request->getRequestParam('et_fb', false); |
|
| 145 | + } |
|
| 146 | 146 | } |
@@ -31,200 +31,200 @@ |
||
| 31 | 31 | class CoreAssetManager extends AssetManager |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - // WordPress core / Third party JS asset handles |
|
| 35 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 36 | - |
|
| 37 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
| 38 | - |
|
| 39 | - const JS_HANDLE_I18N = 'eei18n'; |
|
| 40 | - |
|
| 41 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 42 | - |
|
| 43 | - // EE CSS assets handles |
|
| 44 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 45 | - |
|
| 46 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var EE_Currency_Config $currency_config |
|
| 50 | - */ |
|
| 51 | - protected $currency_config; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var EE_Template_Config $template_config |
|
| 55 | - */ |
|
| 56 | - protected $template_config; |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * CoreAssetRegister constructor. |
|
| 61 | - * |
|
| 62 | - * @param AssetCollection $assets |
|
| 63 | - * @param EE_Currency_Config $currency_config |
|
| 64 | - * @param EE_Template_Config $template_config |
|
| 65 | - * @param DomainInterface $domain |
|
| 66 | - * @param Registry $registry |
|
| 67 | - */ |
|
| 68 | - public function __construct( |
|
| 69 | - AssetCollection $assets, |
|
| 70 | - EE_Currency_Config $currency_config, |
|
| 71 | - EE_Template_Config $template_config, |
|
| 72 | - DomainInterface $domain, |
|
| 73 | - Registry $registry |
|
| 74 | - ) { |
|
| 75 | - $this->currency_config = $currency_config; |
|
| 76 | - $this->template_config = $template_config; |
|
| 77 | - parent::__construct($domain, $assets, $registry); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @throws DomainException |
|
| 83 | - * @throws DuplicateCollectionIdentifierException |
|
| 84 | - * @throws InvalidArgumentException |
|
| 85 | - * @throws InvalidDataTypeException |
|
| 86 | - * @throws InvalidEntityException |
|
| 87 | - * @throws InvalidInterfaceException |
|
| 88 | - * @since 4.9.62.p |
|
| 89 | - */ |
|
| 90 | - public function addAssets() |
|
| 91 | - { |
|
| 92 | - $this->addJavascriptFiles(); |
|
| 93 | - $this->addStylesheetFiles(); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @throws DomainException |
|
| 99 | - * @throws DuplicateCollectionIdentifierException |
|
| 100 | - * @throws InvalidArgumentException |
|
| 101 | - * @throws InvalidDataTypeException |
|
| 102 | - * @throws InvalidEntityException |
|
| 103 | - * @throws InvalidInterfaceException |
|
| 104 | - * @since 4.9.62.p |
|
| 105 | - */ |
|
| 106 | - public function addJavascriptFiles() |
|
| 107 | - { |
|
| 108 | - $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
| 109 | - $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
| 110 | - // todo verify that the following data is no longer being used anywhere and remove |
|
| 111 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 112 | - $this->registry->addData( |
|
| 113 | - 'paths', |
|
| 114 | - [ |
|
| 115 | - 'base_rest_route' => rest_url(), |
|
| 116 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 117 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 118 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 119 | - 'site_url' => site_url('/'), |
|
| 120 | - 'admin_url' => admin_url('/'), |
|
| 121 | - ] |
|
| 122 | - ); |
|
| 123 | - // Event Espresso brand name |
|
| 124 | - $this->registry->addData('brandName', Domain::brandName()); |
|
| 125 | - /** site formatting values **/ |
|
| 126 | - $this->registry->addData( |
|
| 127 | - 'site_formats', |
|
| 128 | - [ |
|
| 129 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(), |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - /** currency data **/ |
|
| 133 | - $this->registry->addData( |
|
| 134 | - 'currency_config', |
|
| 135 | - $this->getCurrencySettings() |
|
| 136 | - ); |
|
| 137 | - /** site timezone */ |
|
| 138 | - $this->registry->addData( |
|
| 139 | - 'default_timezone', |
|
| 140 | - [ |
|
| 141 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 142 | - 'string' => get_option('timezone_string'), |
|
| 143 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 144 | - ] |
|
| 145 | - ); |
|
| 146 | - /** site locale (user locale if user logged in) */ |
|
| 147 | - $this->registry->addData( |
|
| 148 | - 'locale', |
|
| 149 | - [ |
|
| 150 | - 'user' => get_user_locale(), |
|
| 151 | - 'site' => get_locale(), |
|
| 152 | - ] |
|
| 153 | - ); |
|
| 154 | - |
|
| 155 | - $this->addJavascript( |
|
| 156 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 157 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 158 | - [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
| 159 | - )->setInlineDataCallback( |
|
| 160 | - function() { |
|
| 161 | - wp_localize_script( |
|
| 162 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 163 | - CoreAssetManager::JS_HANDLE_I18N, |
|
| 164 | - EE_Registry::$i18n_js_strings |
|
| 165 | - ); |
|
| 166 | - } |
|
| 167 | - ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @throws DuplicateCollectionIdentifierException |
|
| 173 | - * @throws InvalidDataTypeException |
|
| 174 | - * @throws InvalidEntityException |
|
| 175 | - * @throws DomainException |
|
| 176 | - * @since 4.9.62.p |
|
| 177 | - */ |
|
| 178 | - public function addStylesheetFiles() |
|
| 179 | - { |
|
| 180 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 181 | - $this->addStylesheet( |
|
| 182 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 183 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
| 184 | - ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
| 185 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 186 | - ['dashicons'] |
|
| 187 | - ); |
|
| 188 | - //Load custom style sheet if available |
|
| 189 | - if ($this->template_config->custom_style_sheet !== null) { |
|
| 190 | - $this->addStylesheet( |
|
| 191 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 192 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 193 | - [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
| 194 | - ); |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Returns configuration data for the js Currency VO. |
|
| 202 | - * |
|
| 203 | - * @return array |
|
| 204 | - * @since 4.9.71.p |
|
| 205 | - */ |
|
| 206 | - private function getCurrencySettings() |
|
| 207 | - { |
|
| 208 | - return [ |
|
| 209 | - 'code' => $this->currency_config->code, |
|
| 210 | - 'singularLabel' => $this->currency_config->name, |
|
| 211 | - 'pluralLabel' => $this->currency_config->plural, |
|
| 212 | - 'sign' => $this->currency_config->sign, |
|
| 213 | - 'signB4' => $this->currency_config->sign_b4, |
|
| 214 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 215 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 216 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 217 | - ]; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @param JavascriptAsset $script |
|
| 223 | - * @deprecated $VID:$ |
|
| 224 | - */ |
|
| 225 | - public function loadQtipJs(JavascriptAsset $script) |
|
| 226 | - { |
|
| 227 | - // replacement: |
|
| 228 | - // EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
| 229 | - } |
|
| 34 | + // WordPress core / Third party JS asset handles |
|
| 35 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 36 | + |
|
| 37 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
| 38 | + |
|
| 39 | + const JS_HANDLE_I18N = 'eei18n'; |
|
| 40 | + |
|
| 41 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 42 | + |
|
| 43 | + // EE CSS assets handles |
|
| 44 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 45 | + |
|
| 46 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var EE_Currency_Config $currency_config |
|
| 50 | + */ |
|
| 51 | + protected $currency_config; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var EE_Template_Config $template_config |
|
| 55 | + */ |
|
| 56 | + protected $template_config; |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * CoreAssetRegister constructor. |
|
| 61 | + * |
|
| 62 | + * @param AssetCollection $assets |
|
| 63 | + * @param EE_Currency_Config $currency_config |
|
| 64 | + * @param EE_Template_Config $template_config |
|
| 65 | + * @param DomainInterface $domain |
|
| 66 | + * @param Registry $registry |
|
| 67 | + */ |
|
| 68 | + public function __construct( |
|
| 69 | + AssetCollection $assets, |
|
| 70 | + EE_Currency_Config $currency_config, |
|
| 71 | + EE_Template_Config $template_config, |
|
| 72 | + DomainInterface $domain, |
|
| 73 | + Registry $registry |
|
| 74 | + ) { |
|
| 75 | + $this->currency_config = $currency_config; |
|
| 76 | + $this->template_config = $template_config; |
|
| 77 | + parent::__construct($domain, $assets, $registry); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @throws DomainException |
|
| 83 | + * @throws DuplicateCollectionIdentifierException |
|
| 84 | + * @throws InvalidArgumentException |
|
| 85 | + * @throws InvalidDataTypeException |
|
| 86 | + * @throws InvalidEntityException |
|
| 87 | + * @throws InvalidInterfaceException |
|
| 88 | + * @since 4.9.62.p |
|
| 89 | + */ |
|
| 90 | + public function addAssets() |
|
| 91 | + { |
|
| 92 | + $this->addJavascriptFiles(); |
|
| 93 | + $this->addStylesheetFiles(); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @throws DomainException |
|
| 99 | + * @throws DuplicateCollectionIdentifierException |
|
| 100 | + * @throws InvalidArgumentException |
|
| 101 | + * @throws InvalidDataTypeException |
|
| 102 | + * @throws InvalidEntityException |
|
| 103 | + * @throws InvalidInterfaceException |
|
| 104 | + * @since 4.9.62.p |
|
| 105 | + */ |
|
| 106 | + public function addJavascriptFiles() |
|
| 107 | + { |
|
| 108 | + $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
| 109 | + $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
| 110 | + // todo verify that the following data is no longer being used anywhere and remove |
|
| 111 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 112 | + $this->registry->addData( |
|
| 113 | + 'paths', |
|
| 114 | + [ |
|
| 115 | + 'base_rest_route' => rest_url(), |
|
| 116 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 117 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 118 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 119 | + 'site_url' => site_url('/'), |
|
| 120 | + 'admin_url' => admin_url('/'), |
|
| 121 | + ] |
|
| 122 | + ); |
|
| 123 | + // Event Espresso brand name |
|
| 124 | + $this->registry->addData('brandName', Domain::brandName()); |
|
| 125 | + /** site formatting values **/ |
|
| 126 | + $this->registry->addData( |
|
| 127 | + 'site_formats', |
|
| 128 | + [ |
|
| 129 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(), |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + /** currency data **/ |
|
| 133 | + $this->registry->addData( |
|
| 134 | + 'currency_config', |
|
| 135 | + $this->getCurrencySettings() |
|
| 136 | + ); |
|
| 137 | + /** site timezone */ |
|
| 138 | + $this->registry->addData( |
|
| 139 | + 'default_timezone', |
|
| 140 | + [ |
|
| 141 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 142 | + 'string' => get_option('timezone_string'), |
|
| 143 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 144 | + ] |
|
| 145 | + ); |
|
| 146 | + /** site locale (user locale if user logged in) */ |
|
| 147 | + $this->registry->addData( |
|
| 148 | + 'locale', |
|
| 149 | + [ |
|
| 150 | + 'user' => get_user_locale(), |
|
| 151 | + 'site' => get_locale(), |
|
| 152 | + ] |
|
| 153 | + ); |
|
| 154 | + |
|
| 155 | + $this->addJavascript( |
|
| 156 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 157 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 158 | + [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
| 159 | + )->setInlineDataCallback( |
|
| 160 | + function() { |
|
| 161 | + wp_localize_script( |
|
| 162 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 163 | + CoreAssetManager::JS_HANDLE_I18N, |
|
| 164 | + EE_Registry::$i18n_js_strings |
|
| 165 | + ); |
|
| 166 | + } |
|
| 167 | + ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @throws DuplicateCollectionIdentifierException |
|
| 173 | + * @throws InvalidDataTypeException |
|
| 174 | + * @throws InvalidEntityException |
|
| 175 | + * @throws DomainException |
|
| 176 | + * @since 4.9.62.p |
|
| 177 | + */ |
|
| 178 | + public function addStylesheetFiles() |
|
| 179 | + { |
|
| 180 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 181 | + $this->addStylesheet( |
|
| 182 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 183 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
| 184 | + ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
| 185 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 186 | + ['dashicons'] |
|
| 187 | + ); |
|
| 188 | + //Load custom style sheet if available |
|
| 189 | + if ($this->template_config->custom_style_sheet !== null) { |
|
| 190 | + $this->addStylesheet( |
|
| 191 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 192 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 193 | + [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
| 194 | + ); |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Returns configuration data for the js Currency VO. |
|
| 202 | + * |
|
| 203 | + * @return array |
|
| 204 | + * @since 4.9.71.p |
|
| 205 | + */ |
|
| 206 | + private function getCurrencySettings() |
|
| 207 | + { |
|
| 208 | + return [ |
|
| 209 | + 'code' => $this->currency_config->code, |
|
| 210 | + 'singularLabel' => $this->currency_config->name, |
|
| 211 | + 'pluralLabel' => $this->currency_config->plural, |
|
| 212 | + 'sign' => $this->currency_config->sign, |
|
| 213 | + 'signB4' => $this->currency_config->sign_b4, |
|
| 214 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 215 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 216 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 217 | + ]; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @param JavascriptAsset $script |
|
| 223 | + * @deprecated $VID:$ |
|
| 224 | + */ |
|
| 225 | + public function loadQtipJs(JavascriptAsset $script) |
|
| 226 | + { |
|
| 227 | + // replacement: |
|
| 228 | + // EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
| 229 | + } |
|
| 230 | 230 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $this->addJavascript( |
| 156 | 156 | CoreAssetManager::JS_HANDLE_CORE, |
| 157 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 157 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
| 158 | 158 | [JqueryAssetManager::JS_HANDLE_JQUERY] |
| 159 | 159 | )->setInlineDataCallback( |
| 160 | 160 | function() { |
@@ -180,16 +180,16 @@ discard block |
||
| 180 | 180 | if ($this->template_config->enable_default_style && ! is_admin()) { |
| 181 | 181 | $this->addStylesheet( |
| 182 | 182 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
| 183 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
| 183 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css') |
|
| 184 | 184 | ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
| 185 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 185 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
| 186 | 186 | ['dashicons'] |
| 187 | 187 | ); |
| 188 | 188 | //Load custom style sheet if available |
| 189 | 189 | if ($this->template_config->custom_style_sheet !== null) { |
| 190 | 190 | $this->addStylesheet( |
| 191 | 191 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
| 192 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 192 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
| 193 | 193 | [CoreAssetManager::CSS_HANDLE_DEFAULT] |
| 194 | 194 | ); |
| 195 | 195 | } |