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