@@ -16,66 +16,66 @@ |
||
| 16 | 16 | class Domain extends DomainBase implements CaffeinatedInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * URL path component used to denote an API request |
|
| 21 | - */ |
|
| 22 | - const API_NAMESPACE = 'ee/v'; |
|
| 19 | + /** |
|
| 20 | + * URL path component used to denote an API request |
|
| 21 | + */ |
|
| 22 | + const API_NAMESPACE = 'ee/v'; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
| 26 | - * Page ui. |
|
| 27 | - */ |
|
| 28 | - const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN |
|
| 29 | - = 'manual_registration_status_change_from_registration_admin'; |
|
| 24 | + /** |
|
| 25 | + * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin |
|
| 26 | + * Page ui. |
|
| 27 | + */ |
|
| 28 | + const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN |
|
| 29 | + = 'manual_registration_status_change_from_registration_admin'; |
|
| 30 | 30 | |
| 31 | - const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
| 32 | - = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
| 31 | + const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY |
|
| 32 | + = 'manual_registration_status_change_from_registration_admin_and_notify'; |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Whether or not EE core is the full premium version. |
|
| 37 | - * @since 4.9.59.p |
|
| 38 | - * @var bool |
|
| 39 | - */ |
|
| 40 | - private $caffeinated; |
|
| 35 | + /** |
|
| 36 | + * Whether or not EE core is the full premium version. |
|
| 37 | + * @since 4.9.59.p |
|
| 38 | + * @var bool |
|
| 39 | + */ |
|
| 40 | + private $caffeinated; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - public function __construct(FilePath $plugin_file, Version $version) |
|
| 44 | - { |
|
| 45 | - parent::__construct($plugin_file, $version); |
|
| 46 | - $this->setCaffeinated(); |
|
| 47 | - } |
|
| 43 | + public function __construct(FilePath $plugin_file, Version $version) |
|
| 44 | + { |
|
| 45 | + parent::__construct($plugin_file, $version); |
|
| 46 | + $this->setCaffeinated(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Whether or not EE core is the full premium version. |
|
| 51 | - * @since 4.9.59.p |
|
| 52 | - * @return bool |
|
| 53 | - */ |
|
| 54 | - public function isCaffeinated() |
|
| 55 | - { |
|
| 56 | - return $this->caffeinated; |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * Whether or not EE core is the full premium version. |
|
| 51 | + * @since 4.9.59.p |
|
| 52 | + * @return bool |
|
| 53 | + */ |
|
| 54 | + public function isCaffeinated() |
|
| 55 | + { |
|
| 56 | + return $this->caffeinated; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Setter for $is_caffeinated property. |
|
| 62 | - * @since 4.9.59.p |
|
| 63 | - */ |
|
| 64 | - private function setCaffeinated() |
|
| 65 | - { |
|
| 66 | - $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 67 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
| 68 | - } |
|
| 60 | + /** |
|
| 61 | + * Setter for $is_caffeinated property. |
|
| 62 | + * @since 4.9.59.p |
|
| 63 | + */ |
|
| 64 | + private function setCaffeinated() |
|
| 65 | + { |
|
| 66 | + $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 67 | + && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
| 73 | - * to allow for filtering the brand. |
|
| 74 | - * |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - public static function brandName() |
|
| 78 | - { |
|
| 79 | - return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
| 80 | - } |
|
| 71 | + /** |
|
| 72 | + * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces |
|
| 73 | + * to allow for filtering the brand. |
|
| 74 | + * |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + public static function brandName() |
|
| 78 | + { |
|
| 79 | + return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso'); |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -63,8 +63,8 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | private function setCaffeinated() |
| 65 | 65 | { |
| 66 | - $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 67 | - && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php'); |
|
| 66 | + $this->caffeinated = ( ! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 67 | + && is_readable($this->pluginPath().'caffeinated/brewing_regular.php'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -32,559 +32,559 @@ |
||
| 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 | - // EE JS assets handles |
|
| 62 | - const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
| 61 | + // EE JS assets handles |
|
| 62 | + const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
| 63 | 63 | |
| 64 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 64 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
| 65 | 65 | |
| 66 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 66 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
| 67 | 67 | |
| 68 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
| 68 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
| 69 | 69 | |
| 70 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
| 70 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
| 71 | 71 | |
| 72 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
| 72 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
| 73 | 73 | |
| 74 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
| 74 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
| 75 | 75 | |
| 76 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 76 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
| 77 | 77 | |
| 78 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 79 | - |
|
| 80 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 78 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 79 | + |
|
| 80 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
| 81 | 81 | |
| 82 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
| 82 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
| 83 | 83 | |
| 84 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
| 84 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
| 85 | 85 | |
| 86 | - const JS_HANDLE_I18N = 'eei18n'; |
|
| 87 | - |
|
| 88 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
| 89 | - |
|
| 90 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
| 91 | - |
|
| 92 | - // EE CSS assets handles |
|
| 93 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 94 | - |
|
| 95 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 96 | - |
|
| 97 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @var EE_Currency_Config $currency_config |
|
| 101 | - */ |
|
| 102 | - protected $currency_config; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @var EE_Template_Config $template_config |
|
| 106 | - */ |
|
| 107 | - protected $template_config; |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * CoreAssetRegister constructor. |
|
| 112 | - * |
|
| 113 | - * @param AssetCollection $assets |
|
| 114 | - * @param EE_Currency_Config $currency_config |
|
| 115 | - * @param EE_Template_Config $template_config |
|
| 116 | - * @param DomainInterface $domain |
|
| 117 | - * @param Registry $registry |
|
| 118 | - */ |
|
| 119 | - public function __construct( |
|
| 120 | - AssetCollection $assets, |
|
| 121 | - EE_Currency_Config $currency_config, |
|
| 122 | - EE_Template_Config $template_config, |
|
| 123 | - DomainInterface $domain, |
|
| 124 | - Registry $registry |
|
| 125 | - ) { |
|
| 126 | - $this->currency_config = $currency_config; |
|
| 127 | - $this->template_config = $template_config; |
|
| 128 | - parent::__construct($domain, $assets, $registry); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @since 4.9.62.p |
|
| 134 | - * @throws DomainException |
|
| 135 | - * @throws DuplicateCollectionIdentifierException |
|
| 136 | - * @throws InvalidArgumentException |
|
| 137 | - * @throws InvalidDataTypeException |
|
| 138 | - * @throws InvalidEntityException |
|
| 139 | - * @throws InvalidInterfaceException |
|
| 140 | - */ |
|
| 141 | - public function addAssets() |
|
| 142 | - { |
|
| 143 | - $this->addJavascriptFiles(); |
|
| 144 | - $this->addStylesheetFiles(); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @since 4.9.62.p |
|
| 150 | - * @throws DomainException |
|
| 151 | - * @throws DuplicateCollectionIdentifierException |
|
| 152 | - * @throws InvalidArgumentException |
|
| 153 | - * @throws InvalidDataTypeException |
|
| 154 | - * @throws InvalidEntityException |
|
| 155 | - * @throws InvalidInterfaceException |
|
| 156 | - */ |
|
| 157 | - public function addJavascriptFiles() |
|
| 158 | - { |
|
| 159 | - $this->loadCoreJs(); |
|
| 160 | - $this->loadJqueryValidate(); |
|
| 161 | - $this->loadAccountingJs(); |
|
| 162 | - add_action( |
|
| 163 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
| 164 | - array($this, 'loadQtipJs') |
|
| 165 | - ); |
|
| 166 | - $this->registerAdminAssets(); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * @since 4.9.62.p |
|
| 172 | - * @throws DuplicateCollectionIdentifierException |
|
| 173 | - * @throws InvalidDataTypeException |
|
| 174 | - * @throws InvalidEntityException |
|
| 175 | - */ |
|
| 176 | - public function addStylesheetFiles() |
|
| 177 | - { |
|
| 178 | - $this->loadCoreCss(); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * core default javascript |
|
| 184 | - * |
|
| 185 | - * @since 4.9.62.p |
|
| 186 | - * @throws DomainException |
|
| 187 | - * @throws DuplicateCollectionIdentifierException |
|
| 188 | - * @throws InvalidArgumentException |
|
| 189 | - * @throws InvalidDataTypeException |
|
| 190 | - * @throws InvalidEntityException |
|
| 191 | - * @throws InvalidInterfaceException |
|
| 192 | - */ |
|
| 193 | - private function loadCoreJs() |
|
| 194 | - { |
|
| 195 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
| 196 | - $this->registerWpAssets(); |
|
| 197 | - |
|
| 198 | - $this->addJavascript( |
|
| 199 | - CoreAssetManager::JS_HANDLE_MANIFEST, |
|
| 200 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
| 201 | - ); |
|
| 202 | - |
|
| 203 | - $this->addJavascript( |
|
| 204 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 205 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
| 206 | - array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
| 207 | - ) |
|
| 208 | - ->setHasInlineData(); |
|
| 209 | - |
|
| 210 | - $this->addJavascript( |
|
| 211 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 212 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
| 213 | - array( |
|
| 214 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 215 | - CoreAssetManager::JS_HANDLE_REACT, |
|
| 216 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 217 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
| 218 | - ) |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $this->addJavascript( |
|
| 222 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
| 223 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
| 224 | - )->setRequiresTranslation(); |
|
| 225 | - |
|
| 226 | - $this->addJavascript( |
|
| 227 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 228 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
| 229 | - array( |
|
| 230 | - CoreAssetManager::JS_HANDLE_VALIDATORS |
|
| 231 | - ) |
|
| 232 | - )->setRequiresTranslation(); |
|
| 233 | - |
|
| 234 | - $this->addJavascript( |
|
| 235 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
| 236 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
| 237 | - array( |
|
| 238 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 239 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 240 | - ) |
|
| 241 | - )->setRequiresTranslation(); |
|
| 242 | - |
|
| 243 | - $this->addJavascript( |
|
| 244 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 245 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
| 246 | - array( |
|
| 247 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
| 248 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 249 | - ) |
|
| 250 | - )->setRequiresTranslation(); |
|
| 251 | - |
|
| 252 | - $this->addJavascript( |
|
| 253 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 254 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
| 255 | - array( |
|
| 256 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 257 | - 'wp-data', |
|
| 258 | - 'wp-api-fetch', |
|
| 259 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 260 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
| 261 | - ) |
|
| 262 | - ) |
|
| 263 | - ->setRequiresTranslation() |
|
| 264 | - ->setInlineDataCallback( |
|
| 265 | - function() { |
|
| 266 | - wp_add_inline_script( |
|
| 267 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 268 | - is_admin() |
|
| 269 | - ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
| 270 | - : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
| 271 | - ); |
|
| 272 | - } |
|
| 273 | - ); |
|
| 274 | - |
|
| 275 | - $this->addJavascript( |
|
| 276 | - CoreAssetManager::JS_HANDLE_HOCS, |
|
| 277 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
| 278 | - array( |
|
| 279 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 280 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 281 | - 'wp-components', |
|
| 282 | - ) |
|
| 283 | - )->setRequiresTranslation(); |
|
| 284 | - |
|
| 285 | - $this->addJavascript( |
|
| 286 | - CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
| 287 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
| 288 | - array( |
|
| 289 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 290 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 291 | - 'wp-components', |
|
| 292 | - ) |
|
| 293 | - ) |
|
| 294 | - ->setRequiresTranslation(); |
|
| 295 | - |
|
| 296 | - $this->addJavascript( |
|
| 297 | - CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
| 298 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
| 299 | - array( |
|
| 300 | - CoreAssetManager::JS_HANDLE_COMPONENTS |
|
| 301 | - ) |
|
| 302 | - )->setRequiresTranslation(); |
|
| 303 | - |
|
| 304 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 305 | - $this->registry->addData( |
|
| 306 | - 'paths', |
|
| 307 | - array( |
|
| 308 | - 'base_rest_route' => rest_url(), |
|
| 309 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 310 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 311 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 312 | - 'site_url' => site_url('/'), |
|
| 313 | - 'admin_url' => admin_url('/'), |
|
| 314 | - ) |
|
| 315 | - ); |
|
| 316 | - // Event Espresso brand name |
|
| 317 | - $this->registry->addData('brandName', Domain::brandName()); |
|
| 318 | - /** site formatting values **/ |
|
| 319 | - $this->registry->addData( |
|
| 320 | - 'site_formats', |
|
| 321 | - array( |
|
| 322 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
| 323 | - ) |
|
| 324 | - ); |
|
| 325 | - /** currency data **/ |
|
| 326 | - $this->registry->addData( |
|
| 327 | - 'currency_config', |
|
| 328 | - $this->getCurrencySettings() |
|
| 329 | - ); |
|
| 330 | - /** site timezone */ |
|
| 331 | - $this->registry->addData( |
|
| 332 | - 'default_timezone', |
|
| 333 | - array( |
|
| 334 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 335 | - 'string' => get_option('timezone_string'), |
|
| 336 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 337 | - ) |
|
| 338 | - ); |
|
| 339 | - /** site locale (user locale if user logged in) */ |
|
| 340 | - $this->registry->addData( |
|
| 341 | - 'locale', |
|
| 342 | - array( |
|
| 343 | - 'user' => get_user_locale(), |
|
| 344 | - 'site' => get_locale() |
|
| 345 | - ) |
|
| 346 | - ); |
|
| 347 | - |
|
| 348 | - $this->addJavascript( |
|
| 349 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 350 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 351 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 352 | - ) |
|
| 353 | - ->setInlineDataCallback( |
|
| 354 | - function () { |
|
| 355 | - wp_localize_script( |
|
| 356 | - CoreAssetManager::JS_HANDLE_CORE, |
|
| 357 | - CoreAssetManager::JS_HANDLE_I18N, |
|
| 358 | - EE_Registry::$i18n_js_strings |
|
| 359 | - ); |
|
| 360 | - } |
|
| 361 | - ); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
| 367 | - * WordPress in the running environment. |
|
| 368 | - * |
|
| 369 | - * @throws DuplicateCollectionIdentifierException |
|
| 370 | - * @throws InvalidDataTypeException |
|
| 371 | - * @throws InvalidEntityException |
|
| 372 | - * @throws DomainException |
|
| 373 | - * @since 4.9.71.p |
|
| 374 | - */ |
|
| 375 | - private function registerWpAssets() |
|
| 376 | - { |
|
| 377 | - global $wp_version; |
|
| 378 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
| 379 | - return; |
|
| 380 | - } |
|
| 381 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
| 382 | - ->setVersion('16.6.0'); |
|
| 383 | - $this->addVendorJavascript( |
|
| 384 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 385 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
| 386 | - )->setVersion('16.6.0'); |
|
| 387 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
| 388 | - ->setInlineDataCallback( |
|
| 389 | - function() { |
|
| 390 | - wp_add_inline_script( |
|
| 391 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
| 392 | - 'window.lodash = _.noConflict();' |
|
| 393 | - ); |
|
| 394 | - } |
|
| 395 | - ) |
|
| 396 | - ->setVersion('4.17.11'); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /** |
|
| 401 | - * Returns configuration data for the accounting-js library. |
|
| 402 | - * @since 4.9.71.p |
|
| 403 | - * @return array |
|
| 404 | - */ |
|
| 405 | - private function getAccountingSettings() { |
|
| 406 | - return array( |
|
| 407 | - 'currency' => array( |
|
| 408 | - 'symbol' => $this->currency_config->sign, |
|
| 409 | - 'format' => array( |
|
| 410 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
| 411 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
| 412 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
| 413 | - ), |
|
| 414 | - 'decimal' => $this->currency_config->dec_mrk, |
|
| 415 | - 'thousand' => $this->currency_config->thsnds, |
|
| 416 | - 'precision' => $this->currency_config->dec_plc, |
|
| 417 | - ), |
|
| 418 | - 'number' => array( |
|
| 419 | - 'precision' => $this->currency_config->dec_plc, |
|
| 420 | - 'thousand' => $this->currency_config->thsnds, |
|
| 421 | - 'decimal' => $this->currency_config->dec_mrk, |
|
| 422 | - ), |
|
| 423 | - ); |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * Returns configuration data for the js Currency VO. |
|
| 429 | - * @since 4.9.71.p |
|
| 430 | - * @return array |
|
| 431 | - */ |
|
| 432 | - private function getCurrencySettings() |
|
| 433 | - { |
|
| 434 | - return array( |
|
| 435 | - 'code' => $this->currency_config->code, |
|
| 436 | - 'singularLabel' => $this->currency_config->name, |
|
| 437 | - 'pluralLabel' => $this->currency_config->plural, |
|
| 438 | - 'sign' => $this->currency_config->sign, |
|
| 439 | - 'signB4' => $this->currency_config->sign_b4, |
|
| 440 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 441 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 442 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 443 | - ); |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - |
|
| 447 | - /** |
|
| 448 | - * @since 4.9.62.p |
|
| 449 | - * @throws DuplicateCollectionIdentifierException |
|
| 450 | - * @throws InvalidDataTypeException |
|
| 451 | - * @throws InvalidEntityException |
|
| 452 | - */ |
|
| 453 | - private function loadCoreCss() |
|
| 454 | - { |
|
| 455 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 456 | - $this->addStylesheet( |
|
| 457 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 458 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
| 459 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
| 460 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 461 | - array('dashicons') |
|
| 462 | - ); |
|
| 463 | - //Load custom style sheet if available |
|
| 464 | - if ($this->template_config->custom_style_sheet !== null) { |
|
| 465 | - $this->addStylesheet( |
|
| 466 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 467 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 468 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
| 469 | - ); |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - $this->addStylesheet( |
|
| 473 | - CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
| 474 | - $this->registry->getCssUrl( |
|
| 475 | - $this->domain->assetNamespace(), |
|
| 476 | - 'components' |
|
| 477 | - ) |
|
| 478 | - ); |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * jQuery Validate for form validation |
|
| 484 | - * |
|
| 485 | - * @since 4.9.62.p |
|
| 486 | - * @throws DomainException |
|
| 487 | - * @throws DuplicateCollectionIdentifierException |
|
| 488 | - * @throws InvalidDataTypeException |
|
| 489 | - * @throws InvalidEntityException |
|
| 490 | - */ |
|
| 491 | - private function loadJqueryValidate() |
|
| 492 | - { |
|
| 493 | - $this->addJavascript( |
|
| 494 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
| 495 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 496 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 497 | - ) |
|
| 498 | - ->setVersion('1.15.0'); |
|
| 499 | - |
|
| 500 | - $this->addJavascript( |
|
| 501 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
| 502 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 503 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
| 504 | - ) |
|
| 505 | - ->setVersion('1.15.0'); |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * accounting.js for performing client-side calculations |
|
| 511 | - * |
|
| 512 | - * @since 4.9.62.p |
|
| 513 | - * @throws DomainException |
|
| 514 | - * @throws DuplicateCollectionIdentifierException |
|
| 515 | - * @throws InvalidDataTypeException |
|
| 516 | - * @throws InvalidEntityException |
|
| 517 | - */ |
|
| 518 | - private function loadAccountingJs() |
|
| 519 | - { |
|
| 520 | - //accounting.js library |
|
| 521 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
| 522 | - $this->addJavascript( |
|
| 523 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
| 524 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
| 525 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
| 526 | - ) |
|
| 527 | - ->setVersion('0.3.2'); |
|
| 528 | - |
|
| 529 | - $this->addJavascript( |
|
| 530 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 531 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
| 532 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
| 533 | - ) |
|
| 534 | - ->setInlineDataCallback( |
|
| 535 | - function () { |
|
| 536 | - wp_localize_script( |
|
| 537 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 538 | - 'EE_ACCOUNTING_CFG', |
|
| 539 | - $this->getAccountingSettings() |
|
| 540 | - ); |
|
| 541 | - } |
|
| 542 | - ) |
|
| 543 | - ->setVersion(); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * registers assets for cleaning your ears |
|
| 549 | - * |
|
| 550 | - * @param JavascriptAsset $script |
|
| 551 | - */ |
|
| 552 | - public function loadQtipJs(JavascriptAsset $script) |
|
| 553 | - { |
|
| 554 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
| 555 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
| 556 | - if ( |
|
| 557 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
| 558 | - && apply_filters('FHEE_load_qtip', false) |
|
| 559 | - ) { |
|
| 560 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * assets that are used in the WordPress admin |
|
| 567 | - * |
|
| 568 | - * @since 4.9.62.p |
|
| 569 | - * @throws DuplicateCollectionIdentifierException |
|
| 570 | - * @throws InvalidDataTypeException |
|
| 571 | - * @throws InvalidEntityException |
|
| 572 | - */ |
|
| 573 | - private function registerAdminAssets() |
|
| 574 | - { |
|
| 575 | - $this->addJavascript( |
|
| 576 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 577 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
| 578 | - array( |
|
| 579 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
| 580 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 581 | - ) |
|
| 582 | - ) |
|
| 583 | - ->setRequiresTranslation(); |
|
| 584 | - |
|
| 585 | - $this->addStylesheet( |
|
| 586 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 587 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
| 588 | - ); |
|
| 589 | - } |
|
| 86 | + const JS_HANDLE_I18N = 'eei18n'; |
|
| 87 | + |
|
| 88 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
| 89 | + |
|
| 90 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
| 91 | + |
|
| 92 | + // EE CSS assets handles |
|
| 93 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
| 94 | + |
|
| 95 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
| 96 | + |
|
| 97 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @var EE_Currency_Config $currency_config |
|
| 101 | + */ |
|
| 102 | + protected $currency_config; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @var EE_Template_Config $template_config |
|
| 106 | + */ |
|
| 107 | + protected $template_config; |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * CoreAssetRegister constructor. |
|
| 112 | + * |
|
| 113 | + * @param AssetCollection $assets |
|
| 114 | + * @param EE_Currency_Config $currency_config |
|
| 115 | + * @param EE_Template_Config $template_config |
|
| 116 | + * @param DomainInterface $domain |
|
| 117 | + * @param Registry $registry |
|
| 118 | + */ |
|
| 119 | + public function __construct( |
|
| 120 | + AssetCollection $assets, |
|
| 121 | + EE_Currency_Config $currency_config, |
|
| 122 | + EE_Template_Config $template_config, |
|
| 123 | + DomainInterface $domain, |
|
| 124 | + Registry $registry |
|
| 125 | + ) { |
|
| 126 | + $this->currency_config = $currency_config; |
|
| 127 | + $this->template_config = $template_config; |
|
| 128 | + parent::__construct($domain, $assets, $registry); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @since 4.9.62.p |
|
| 134 | + * @throws DomainException |
|
| 135 | + * @throws DuplicateCollectionIdentifierException |
|
| 136 | + * @throws InvalidArgumentException |
|
| 137 | + * @throws InvalidDataTypeException |
|
| 138 | + * @throws InvalidEntityException |
|
| 139 | + * @throws InvalidInterfaceException |
|
| 140 | + */ |
|
| 141 | + public function addAssets() |
|
| 142 | + { |
|
| 143 | + $this->addJavascriptFiles(); |
|
| 144 | + $this->addStylesheetFiles(); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @since 4.9.62.p |
|
| 150 | + * @throws DomainException |
|
| 151 | + * @throws DuplicateCollectionIdentifierException |
|
| 152 | + * @throws InvalidArgumentException |
|
| 153 | + * @throws InvalidDataTypeException |
|
| 154 | + * @throws InvalidEntityException |
|
| 155 | + * @throws InvalidInterfaceException |
|
| 156 | + */ |
|
| 157 | + public function addJavascriptFiles() |
|
| 158 | + { |
|
| 159 | + $this->loadCoreJs(); |
|
| 160 | + $this->loadJqueryValidate(); |
|
| 161 | + $this->loadAccountingJs(); |
|
| 162 | + add_action( |
|
| 163 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
| 164 | + array($this, 'loadQtipJs') |
|
| 165 | + ); |
|
| 166 | + $this->registerAdminAssets(); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * @since 4.9.62.p |
|
| 172 | + * @throws DuplicateCollectionIdentifierException |
|
| 173 | + * @throws InvalidDataTypeException |
|
| 174 | + * @throws InvalidEntityException |
|
| 175 | + */ |
|
| 176 | + public function addStylesheetFiles() |
|
| 177 | + { |
|
| 178 | + $this->loadCoreCss(); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * core default javascript |
|
| 184 | + * |
|
| 185 | + * @since 4.9.62.p |
|
| 186 | + * @throws DomainException |
|
| 187 | + * @throws DuplicateCollectionIdentifierException |
|
| 188 | + * @throws InvalidArgumentException |
|
| 189 | + * @throws InvalidDataTypeException |
|
| 190 | + * @throws InvalidEntityException |
|
| 191 | + * @throws InvalidInterfaceException |
|
| 192 | + */ |
|
| 193 | + private function loadCoreJs() |
|
| 194 | + { |
|
| 195 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
| 196 | + $this->registerWpAssets(); |
|
| 197 | + |
|
| 198 | + $this->addJavascript( |
|
| 199 | + CoreAssetManager::JS_HANDLE_MANIFEST, |
|
| 200 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
| 201 | + ); |
|
| 202 | + |
|
| 203 | + $this->addJavascript( |
|
| 204 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 205 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
| 206 | + array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
| 207 | + ) |
|
| 208 | + ->setHasInlineData(); |
|
| 209 | + |
|
| 210 | + $this->addJavascript( |
|
| 211 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 212 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
| 213 | + array( |
|
| 214 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 215 | + CoreAssetManager::JS_HANDLE_REACT, |
|
| 216 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 217 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
| 218 | + ) |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $this->addJavascript( |
|
| 222 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
| 223 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
| 224 | + )->setRequiresTranslation(); |
|
| 225 | + |
|
| 226 | + $this->addJavascript( |
|
| 227 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 228 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
| 229 | + array( |
|
| 230 | + CoreAssetManager::JS_HANDLE_VALIDATORS |
|
| 231 | + ) |
|
| 232 | + )->setRequiresTranslation(); |
|
| 233 | + |
|
| 234 | + $this->addJavascript( |
|
| 235 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
| 236 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
| 237 | + array( |
|
| 238 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 239 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 240 | + ) |
|
| 241 | + )->setRequiresTranslation(); |
|
| 242 | + |
|
| 243 | + $this->addJavascript( |
|
| 244 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 245 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
| 246 | + array( |
|
| 247 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
| 248 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
| 249 | + ) |
|
| 250 | + )->setRequiresTranslation(); |
|
| 251 | + |
|
| 252 | + $this->addJavascript( |
|
| 253 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 254 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
| 255 | + array( |
|
| 256 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 257 | + 'wp-data', |
|
| 258 | + 'wp-api-fetch', |
|
| 259 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 260 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
| 261 | + ) |
|
| 262 | + ) |
|
| 263 | + ->setRequiresTranslation() |
|
| 264 | + ->setInlineDataCallback( |
|
| 265 | + function() { |
|
| 266 | + wp_add_inline_script( |
|
| 267 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 268 | + is_admin() |
|
| 269 | + ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
| 270 | + : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
| 271 | + ); |
|
| 272 | + } |
|
| 273 | + ); |
|
| 274 | + |
|
| 275 | + $this->addJavascript( |
|
| 276 | + CoreAssetManager::JS_HANDLE_HOCS, |
|
| 277 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
| 278 | + array( |
|
| 279 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 280 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 281 | + 'wp-components', |
|
| 282 | + ) |
|
| 283 | + )->setRequiresTranslation(); |
|
| 284 | + |
|
| 285 | + $this->addJavascript( |
|
| 286 | + CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
| 287 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
| 288 | + array( |
|
| 289 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
| 290 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
| 291 | + 'wp-components', |
|
| 292 | + ) |
|
| 293 | + ) |
|
| 294 | + ->setRequiresTranslation(); |
|
| 295 | + |
|
| 296 | + $this->addJavascript( |
|
| 297 | + CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
| 298 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
| 299 | + array( |
|
| 300 | + CoreAssetManager::JS_HANDLE_COMPONENTS |
|
| 301 | + ) |
|
| 302 | + )->setRequiresTranslation(); |
|
| 303 | + |
|
| 304 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
| 305 | + $this->registry->addData( |
|
| 306 | + 'paths', |
|
| 307 | + array( |
|
| 308 | + 'base_rest_route' => rest_url(), |
|
| 309 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
| 310 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
| 311 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
| 312 | + 'site_url' => site_url('/'), |
|
| 313 | + 'admin_url' => admin_url('/'), |
|
| 314 | + ) |
|
| 315 | + ); |
|
| 316 | + // Event Espresso brand name |
|
| 317 | + $this->registry->addData('brandName', Domain::brandName()); |
|
| 318 | + /** site formatting values **/ |
|
| 319 | + $this->registry->addData( |
|
| 320 | + 'site_formats', |
|
| 321 | + array( |
|
| 322 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
| 323 | + ) |
|
| 324 | + ); |
|
| 325 | + /** currency data **/ |
|
| 326 | + $this->registry->addData( |
|
| 327 | + 'currency_config', |
|
| 328 | + $this->getCurrencySettings() |
|
| 329 | + ); |
|
| 330 | + /** site timezone */ |
|
| 331 | + $this->registry->addData( |
|
| 332 | + 'default_timezone', |
|
| 333 | + array( |
|
| 334 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
| 335 | + 'string' => get_option('timezone_string'), |
|
| 336 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
| 337 | + ) |
|
| 338 | + ); |
|
| 339 | + /** site locale (user locale if user logged in) */ |
|
| 340 | + $this->registry->addData( |
|
| 341 | + 'locale', |
|
| 342 | + array( |
|
| 343 | + 'user' => get_user_locale(), |
|
| 344 | + 'site' => get_locale() |
|
| 345 | + ) |
|
| 346 | + ); |
|
| 347 | + |
|
| 348 | + $this->addJavascript( |
|
| 349 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 350 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
| 351 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 352 | + ) |
|
| 353 | + ->setInlineDataCallback( |
|
| 354 | + function () { |
|
| 355 | + wp_localize_script( |
|
| 356 | + CoreAssetManager::JS_HANDLE_CORE, |
|
| 357 | + CoreAssetManager::JS_HANDLE_I18N, |
|
| 358 | + EE_Registry::$i18n_js_strings |
|
| 359 | + ); |
|
| 360 | + } |
|
| 361 | + ); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
| 367 | + * WordPress in the running environment. |
|
| 368 | + * |
|
| 369 | + * @throws DuplicateCollectionIdentifierException |
|
| 370 | + * @throws InvalidDataTypeException |
|
| 371 | + * @throws InvalidEntityException |
|
| 372 | + * @throws DomainException |
|
| 373 | + * @since 4.9.71.p |
|
| 374 | + */ |
|
| 375 | + private function registerWpAssets() |
|
| 376 | + { |
|
| 377 | + global $wp_version; |
|
| 378 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
| 379 | + return; |
|
| 380 | + } |
|
| 381 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
| 382 | + ->setVersion('16.6.0'); |
|
| 383 | + $this->addVendorJavascript( |
|
| 384 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
| 385 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
| 386 | + )->setVersion('16.6.0'); |
|
| 387 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
| 388 | + ->setInlineDataCallback( |
|
| 389 | + function() { |
|
| 390 | + wp_add_inline_script( |
|
| 391 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
| 392 | + 'window.lodash = _.noConflict();' |
|
| 393 | + ); |
|
| 394 | + } |
|
| 395 | + ) |
|
| 396 | + ->setVersion('4.17.11'); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /** |
|
| 401 | + * Returns configuration data for the accounting-js library. |
|
| 402 | + * @since 4.9.71.p |
|
| 403 | + * @return array |
|
| 404 | + */ |
|
| 405 | + private function getAccountingSettings() { |
|
| 406 | + return array( |
|
| 407 | + 'currency' => array( |
|
| 408 | + 'symbol' => $this->currency_config->sign, |
|
| 409 | + 'format' => array( |
|
| 410 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
| 411 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
| 412 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
| 413 | + ), |
|
| 414 | + 'decimal' => $this->currency_config->dec_mrk, |
|
| 415 | + 'thousand' => $this->currency_config->thsnds, |
|
| 416 | + 'precision' => $this->currency_config->dec_plc, |
|
| 417 | + ), |
|
| 418 | + 'number' => array( |
|
| 419 | + 'precision' => $this->currency_config->dec_plc, |
|
| 420 | + 'thousand' => $this->currency_config->thsnds, |
|
| 421 | + 'decimal' => $this->currency_config->dec_mrk, |
|
| 422 | + ), |
|
| 423 | + ); |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * Returns configuration data for the js Currency VO. |
|
| 429 | + * @since 4.9.71.p |
|
| 430 | + * @return array |
|
| 431 | + */ |
|
| 432 | + private function getCurrencySettings() |
|
| 433 | + { |
|
| 434 | + return array( |
|
| 435 | + 'code' => $this->currency_config->code, |
|
| 436 | + 'singularLabel' => $this->currency_config->name, |
|
| 437 | + 'pluralLabel' => $this->currency_config->plural, |
|
| 438 | + 'sign' => $this->currency_config->sign, |
|
| 439 | + 'signB4' => $this->currency_config->sign_b4, |
|
| 440 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
| 441 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
| 442 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
| 443 | + ); |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + |
|
| 447 | + /** |
|
| 448 | + * @since 4.9.62.p |
|
| 449 | + * @throws DuplicateCollectionIdentifierException |
|
| 450 | + * @throws InvalidDataTypeException |
|
| 451 | + * @throws InvalidEntityException |
|
| 452 | + */ |
|
| 453 | + private function loadCoreCss() |
|
| 454 | + { |
|
| 455 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
| 456 | + $this->addStylesheet( |
|
| 457 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
| 458 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
| 459 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
| 460 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
| 461 | + array('dashicons') |
|
| 462 | + ); |
|
| 463 | + //Load custom style sheet if available |
|
| 464 | + if ($this->template_config->custom_style_sheet !== null) { |
|
| 465 | + $this->addStylesheet( |
|
| 466 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
| 467 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
| 468 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
| 469 | + ); |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + $this->addStylesheet( |
|
| 473 | + CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
| 474 | + $this->registry->getCssUrl( |
|
| 475 | + $this->domain->assetNamespace(), |
|
| 476 | + 'components' |
|
| 477 | + ) |
|
| 478 | + ); |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * jQuery Validate for form validation |
|
| 484 | + * |
|
| 485 | + * @since 4.9.62.p |
|
| 486 | + * @throws DomainException |
|
| 487 | + * @throws DuplicateCollectionIdentifierException |
|
| 488 | + * @throws InvalidDataTypeException |
|
| 489 | + * @throws InvalidEntityException |
|
| 490 | + */ |
|
| 491 | + private function loadJqueryValidate() |
|
| 492 | + { |
|
| 493 | + $this->addJavascript( |
|
| 494 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
| 495 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 496 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
| 497 | + ) |
|
| 498 | + ->setVersion('1.15.0'); |
|
| 499 | + |
|
| 500 | + $this->addJavascript( |
|
| 501 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
| 502 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 503 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
| 504 | + ) |
|
| 505 | + ->setVersion('1.15.0'); |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * accounting.js for performing client-side calculations |
|
| 511 | + * |
|
| 512 | + * @since 4.9.62.p |
|
| 513 | + * @throws DomainException |
|
| 514 | + * @throws DuplicateCollectionIdentifierException |
|
| 515 | + * @throws InvalidDataTypeException |
|
| 516 | + * @throws InvalidEntityException |
|
| 517 | + */ |
|
| 518 | + private function loadAccountingJs() |
|
| 519 | + { |
|
| 520 | + //accounting.js library |
|
| 521 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
| 522 | + $this->addJavascript( |
|
| 523 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
| 524 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
| 525 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
| 526 | + ) |
|
| 527 | + ->setVersion('0.3.2'); |
|
| 528 | + |
|
| 529 | + $this->addJavascript( |
|
| 530 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 531 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
| 532 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
| 533 | + ) |
|
| 534 | + ->setInlineDataCallback( |
|
| 535 | + function () { |
|
| 536 | + wp_localize_script( |
|
| 537 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
| 538 | + 'EE_ACCOUNTING_CFG', |
|
| 539 | + $this->getAccountingSettings() |
|
| 540 | + ); |
|
| 541 | + } |
|
| 542 | + ) |
|
| 543 | + ->setVersion(); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * registers assets for cleaning your ears |
|
| 549 | + * |
|
| 550 | + * @param JavascriptAsset $script |
|
| 551 | + */ |
|
| 552 | + public function loadQtipJs(JavascriptAsset $script) |
|
| 553 | + { |
|
| 554 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
| 555 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
| 556 | + if ( |
|
| 557 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
| 558 | + && apply_filters('FHEE_load_qtip', false) |
|
| 559 | + ) { |
|
| 560 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * assets that are used in the WordPress admin |
|
| 567 | + * |
|
| 568 | + * @since 4.9.62.p |
|
| 569 | + * @throws DuplicateCollectionIdentifierException |
|
| 570 | + * @throws InvalidDataTypeException |
|
| 571 | + * @throws InvalidEntityException |
|
| 572 | + */ |
|
| 573 | + private function registerAdminAssets() |
|
| 574 | + { |
|
| 575 | + $this->addJavascript( |
|
| 576 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 577 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
| 578 | + array( |
|
| 579 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
| 580 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
| 581 | + ) |
|
| 582 | + ) |
|
| 583 | + ->setRequiresTranslation(); |
|
| 584 | + |
|
| 585 | + $this->addStylesheet( |
|
| 586 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 587 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
| 588 | + ); |
|
| 589 | + } |
|
| 590 | 590 | } |
@@ -15,239 +15,239 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class I18nRegistry |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var DomainInterface |
|
| 20 | - */ |
|
| 21 | - private $domain; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
| 25 | - * |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 28 | - private $registered_i18n = array(); |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Used to hold queued translations for the chunks loading in a view. |
|
| 33 | - * |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - private $queued_handle_translations = array(); |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
| 40 | - * |
|
| 41 | - * @var array |
|
| 42 | - */ |
|
| 43 | - private $queued_scripts = array(); |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
| 48 | - * translation strings. |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - private $i18n_map; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * I18nRegistry constructor. |
|
| 57 | - * |
|
| 58 | - * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
| 59 | - * provided, the class will look for map in root of plugin with filename of |
|
| 60 | - * 'translation-map.json'. |
|
| 61 | - * @param DomainInterface $domain |
|
| 62 | - */ |
|
| 63 | - public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
| 64 | - { |
|
| 65 | - $this->domain = $domain; |
|
| 66 | - $this->setI18nMap($i18n_map); |
|
| 67 | - add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Used to register a script that has i18n strings for its $handle |
|
| 73 | - * |
|
| 74 | - * @param string $handle The script handle reference. |
|
| 75 | - * @param string $domain The i18n domain for the strings. |
|
| 76 | - */ |
|
| 77 | - public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
| 78 | - { |
|
| 79 | - if(! isset($this->registered_i18n[$handle])) { |
|
| 80 | - $this->registered_i18n[ $handle ] = 1; |
|
| 81 | - $this->queued_scripts[ $handle ] = $domain; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
| 89 | - * |
|
| 90 | - * @param array $handles Array of registered script handles. |
|
| 91 | - * @return array |
|
| 92 | - */ |
|
| 93 | - public function queueI18n(array $handles) |
|
| 94 | - { |
|
| 95 | - if (empty($this->queued_scripts)) { |
|
| 96 | - return $handles; |
|
| 97 | - } |
|
| 98 | - foreach ($handles as $handle) { |
|
| 99 | - $this->queueI18nTranslationsForHandle($handle); |
|
| 100 | - } |
|
| 101 | - if ($this->queued_handle_translations) { |
|
| 102 | - foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
| 103 | - $this->registerInlineScript( |
|
| 104 | - $handle, |
|
| 105 | - $translations_for_domain['translations'], |
|
| 106 | - $translations_for_domain['domain'] |
|
| 107 | - ); |
|
| 108 | - unset($this->queued_handle_translations[$handle]); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - return $handles; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Registers inline script with translations for given handle and domain. |
|
| 117 | - * |
|
| 118 | - * @param string $handle Handle used to register javascript file containing translations. |
|
| 119 | - * @param array $translations Array of string translations. |
|
| 120 | - * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
| 121 | - * domain for the javascript. |
|
| 122 | - */ |
|
| 123 | - protected function registerInlineScript($handle, array $translations, $domain) |
|
| 124 | - { |
|
| 125 | - $script = $domain ? |
|
| 126 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
| 127 | - 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
| 128 | - wp_add_inline_script($handle, $script, 'before'); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Queues up the translation strings for the given handle. |
|
| 134 | - * |
|
| 135 | - * @param string $handle The script handle being queued up. |
|
| 136 | - */ |
|
| 137 | - private function queueI18nTranslationsForHandle($handle) |
|
| 138 | - { |
|
| 139 | - if (isset($this->queued_scripts[$handle])) { |
|
| 140 | - $domain = $this->queued_scripts[$handle]; |
|
| 141 | - $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
| 142 | - if (count($translations) > 0) { |
|
| 143 | - $this->queued_handle_translations[$handle] = array( |
|
| 144 | - 'domain' => $domain, |
|
| 145 | - 'translations' => $translations, |
|
| 146 | - ); |
|
| 147 | - } |
|
| 148 | - unset($this->queued_scripts[$handle]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Sets the internal i18n_map property. |
|
| 155 | - * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
| 156 | - * |
|
| 157 | - * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
| 158 | - * correspond to. |
|
| 159 | - */ |
|
| 160 | - private function setI18nMap(array $i18n_map) |
|
| 161 | - { |
|
| 162 | - if (empty($i18n_map)) { |
|
| 163 | - $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
| 164 | - ? json_decode( |
|
| 165 | - file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
| 166 | - true |
|
| 167 | - ) |
|
| 168 | - : array(); |
|
| 169 | - } |
|
| 170 | - $this->i18n_map = $i18n_map; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Get the jed locale data for a given $handle and domain |
|
| 176 | - * |
|
| 177 | - * @param string $handle The name for the script handle we want strings returned for. |
|
| 178 | - * @param string $domain The i18n domain. |
|
| 179 | - * @return array |
|
| 180 | - */ |
|
| 181 | - protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
| 182 | - { |
|
| 183 | - $translations = $this->getJedLocaleData($domain); |
|
| 184 | - // get index for adding back after extracting strings for this $chunk. |
|
| 185 | - $index = $translations['']; |
|
| 186 | - $translations = $this->getLocaleDataMatchingMap( |
|
| 187 | - $this->getOriginalStringsForHandleFromMap($handle), |
|
| 188 | - $translations |
|
| 189 | - ); |
|
| 190 | - $translations[''] = $index; |
|
| 191 | - return $translations; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Get locale data for given strings from given translations |
|
| 197 | - * |
|
| 198 | - * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
| 199 | - * @param array $translations Translation data to extra strings from. |
|
| 200 | - * @return array |
|
| 201 | - */ |
|
| 202 | - protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
| 203 | - { |
|
| 204 | - if (empty($string_set)) { |
|
| 205 | - return array(); |
|
| 206 | - } |
|
| 207 | - // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
| 208 | - // slashed also filter falsey values. |
|
| 209 | - $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
| 210 | - return array_intersect_key($translations, array_flip($string_set)); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Get original strings to translate for the given chunk from the map |
|
| 216 | - * |
|
| 217 | - * @param string $handle The script handle name to get strings from the map for. |
|
| 218 | - * @return array |
|
| 219 | - */ |
|
| 220 | - protected function getOriginalStringsForHandleFromMap($handle) |
|
| 221 | - { |
|
| 222 | - return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Returns Jed-formatted localization data. |
|
| 228 | - * |
|
| 229 | - * @param string $domain Translation domain. |
|
| 230 | - * @return array |
|
| 231 | - */ |
|
| 232 | - private function getJedLocaleData($domain) |
|
| 233 | - { |
|
| 234 | - $translations = get_translations_for_domain($domain); |
|
| 235 | - |
|
| 236 | - $locale = array( |
|
| 237 | - '' => array( |
|
| 238 | - 'domain' => $domain, |
|
| 239 | - 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
| 240 | - ), |
|
| 241 | - ); |
|
| 242 | - |
|
| 243 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
| 244 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - foreach ($translations->entries as $msgid => $entry) { |
|
| 248 | - $locale[$msgid] = $entry->translations; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - return $locale; |
|
| 252 | - } |
|
| 18 | + /** |
|
| 19 | + * @var DomainInterface |
|
| 20 | + */ |
|
| 21 | + private $domain; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Will hold all registered i18n scripts. Prevents script handles from being registered more than once. |
|
| 25 | + * |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | + private $registered_i18n = array(); |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Used to hold queued translations for the chunks loading in a view. |
|
| 33 | + * |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + private $queued_handle_translations = array(); |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Used to track script handles queued for adding translation strings as inline data in the dom. |
|
| 40 | + * |
|
| 41 | + * @var array |
|
| 42 | + */ |
|
| 43 | + private $queued_scripts = array(); |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Obtained from the generated json file from the all javascript using wp.i18n with a map of script handle names to |
|
| 48 | + * translation strings. |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + private $i18n_map; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * I18nRegistry constructor. |
|
| 57 | + * |
|
| 58 | + * @param array() $i18n_map An array of script handle names and the strings translated for those handles. If not |
|
| 59 | + * provided, the class will look for map in root of plugin with filename of |
|
| 60 | + * 'translation-map.json'. |
|
| 61 | + * @param DomainInterface $domain |
|
| 62 | + */ |
|
| 63 | + public function __construct(array $i18n_map = array(), DomainInterface $domain) |
|
| 64 | + { |
|
| 65 | + $this->domain = $domain; |
|
| 66 | + $this->setI18nMap($i18n_map); |
|
| 67 | + add_filter('print_scripts_array', array($this, 'queueI18n')); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Used to register a script that has i18n strings for its $handle |
|
| 73 | + * |
|
| 74 | + * @param string $handle The script handle reference. |
|
| 75 | + * @param string $domain The i18n domain for the strings. |
|
| 76 | + */ |
|
| 77 | + public function registerScriptI18n($handle, $domain = 'event_espresso') |
|
| 78 | + { |
|
| 79 | + if(! isset($this->registered_i18n[$handle])) { |
|
| 80 | + $this->registered_i18n[ $handle ] = 1; |
|
| 81 | + $this->queued_scripts[ $handle ] = $domain; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Callback on print_scripts_array to listen for scripts enqueued and handle setting up the localized data. |
|
| 89 | + * |
|
| 90 | + * @param array $handles Array of registered script handles. |
|
| 91 | + * @return array |
|
| 92 | + */ |
|
| 93 | + public function queueI18n(array $handles) |
|
| 94 | + { |
|
| 95 | + if (empty($this->queued_scripts)) { |
|
| 96 | + return $handles; |
|
| 97 | + } |
|
| 98 | + foreach ($handles as $handle) { |
|
| 99 | + $this->queueI18nTranslationsForHandle($handle); |
|
| 100 | + } |
|
| 101 | + if ($this->queued_handle_translations) { |
|
| 102 | + foreach ($this->queued_handle_translations as $handle => $translations_for_domain) { |
|
| 103 | + $this->registerInlineScript( |
|
| 104 | + $handle, |
|
| 105 | + $translations_for_domain['translations'], |
|
| 106 | + $translations_for_domain['domain'] |
|
| 107 | + ); |
|
| 108 | + unset($this->queued_handle_translations[$handle]); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + return $handles; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Registers inline script with translations for given handle and domain. |
|
| 117 | + * |
|
| 118 | + * @param string $handle Handle used to register javascript file containing translations. |
|
| 119 | + * @param array $translations Array of string translations. |
|
| 120 | + * @param string $domain Domain for translations. If left empty then strings are registered with the default |
|
| 121 | + * domain for the javascript. |
|
| 122 | + */ |
|
| 123 | + protected function registerInlineScript($handle, array $translations, $domain) |
|
| 124 | + { |
|
| 125 | + $script = $domain ? |
|
| 126 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ', "' . $domain . '" );' : |
|
| 127 | + 'eejs.i18n.setLocaleData( ' . wp_json_encode($translations) . ' );'; |
|
| 128 | + wp_add_inline_script($handle, $script, 'before'); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Queues up the translation strings for the given handle. |
|
| 134 | + * |
|
| 135 | + * @param string $handle The script handle being queued up. |
|
| 136 | + */ |
|
| 137 | + private function queueI18nTranslationsForHandle($handle) |
|
| 138 | + { |
|
| 139 | + if (isset($this->queued_scripts[$handle])) { |
|
| 140 | + $domain = $this->queued_scripts[$handle]; |
|
| 141 | + $translations = $this->getJedLocaleDataForDomainAndChunk($handle, $domain); |
|
| 142 | + if (count($translations) > 0) { |
|
| 143 | + $this->queued_handle_translations[$handle] = array( |
|
| 144 | + 'domain' => $domain, |
|
| 145 | + 'translations' => $translations, |
|
| 146 | + ); |
|
| 147 | + } |
|
| 148 | + unset($this->queued_scripts[$handle]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Sets the internal i18n_map property. |
|
| 155 | + * If $chunk_map is empty or not an array, will attempt to load a chunk map from a default named map. |
|
| 156 | + * |
|
| 157 | + * @param array $i18n_map If provided, an array of translation strings indexed by script handle names they |
|
| 158 | + * correspond to. |
|
| 159 | + */ |
|
| 160 | + private function setI18nMap(array $i18n_map) |
|
| 161 | + { |
|
| 162 | + if (empty($i18n_map)) { |
|
| 163 | + $i18n_map = file_exists($this->domain->pluginPath() . 'translation-map.json') |
|
| 164 | + ? json_decode( |
|
| 165 | + file_get_contents($this->domain->pluginPath() . 'translation-map.json'), |
|
| 166 | + true |
|
| 167 | + ) |
|
| 168 | + : array(); |
|
| 169 | + } |
|
| 170 | + $this->i18n_map = $i18n_map; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Get the jed locale data for a given $handle and domain |
|
| 176 | + * |
|
| 177 | + * @param string $handle The name for the script handle we want strings returned for. |
|
| 178 | + * @param string $domain The i18n domain. |
|
| 179 | + * @return array |
|
| 180 | + */ |
|
| 181 | + protected function getJedLocaleDataForDomainAndChunk($handle, $domain) |
|
| 182 | + { |
|
| 183 | + $translations = $this->getJedLocaleData($domain); |
|
| 184 | + // get index for adding back after extracting strings for this $chunk. |
|
| 185 | + $index = $translations['']; |
|
| 186 | + $translations = $this->getLocaleDataMatchingMap( |
|
| 187 | + $this->getOriginalStringsForHandleFromMap($handle), |
|
| 188 | + $translations |
|
| 189 | + ); |
|
| 190 | + $translations[''] = $index; |
|
| 191 | + return $translations; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Get locale data for given strings from given translations |
|
| 197 | + * |
|
| 198 | + * @param array $string_set This is the subset of strings (msgIds) we want to extract from the translations array. |
|
| 199 | + * @param array $translations Translation data to extra strings from. |
|
| 200 | + * @return array |
|
| 201 | + */ |
|
| 202 | + protected function getLocaleDataMatchingMap(array $string_set, array $translations) |
|
| 203 | + { |
|
| 204 | + if (empty($string_set)) { |
|
| 205 | + return array(); |
|
| 206 | + } |
|
| 207 | + // some strings with quotes in them will break on the array_flip, so making sure quotes in the string are |
|
| 208 | + // slashed also filter falsey values. |
|
| 209 | + $string_set = array_unique(array_filter(wp_slash($string_set))); |
|
| 210 | + return array_intersect_key($translations, array_flip($string_set)); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Get original strings to translate for the given chunk from the map |
|
| 216 | + * |
|
| 217 | + * @param string $handle The script handle name to get strings from the map for. |
|
| 218 | + * @return array |
|
| 219 | + */ |
|
| 220 | + protected function getOriginalStringsForHandleFromMap($handle) |
|
| 221 | + { |
|
| 222 | + return isset($this->i18n_map[$handle]) ? $this->i18n_map[$handle] : array(); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Returns Jed-formatted localization data. |
|
| 228 | + * |
|
| 229 | + * @param string $domain Translation domain. |
|
| 230 | + * @return array |
|
| 231 | + */ |
|
| 232 | + private function getJedLocaleData($domain) |
|
| 233 | + { |
|
| 234 | + $translations = get_translations_for_domain($domain); |
|
| 235 | + |
|
| 236 | + $locale = array( |
|
| 237 | + '' => array( |
|
| 238 | + 'domain' => $domain, |
|
| 239 | + 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
| 240 | + ), |
|
| 241 | + ); |
|
| 242 | + |
|
| 243 | + if (! empty($translations->headers['Plural-Forms'])) { |
|
| 244 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + foreach ($translations->entries as $msgid => $entry) { |
|
| 248 | + $locale[$msgid] = $entry->translations; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + return $locale; |
|
| 252 | + } |
|
| 253 | 253 | } |
| 254 | 254 | \ No newline at end of file |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.81.rc.011'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.81.rc.011'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |
@@ -103,289 +103,289 @@ |
||
| 103 | 103 | class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage |
| 104 | 104 | { |
| 105 | 105 | |
| 106 | - public function _migration_step($num_items = 50) |
|
| 107 | - { |
|
| 106 | + public function _migration_step($num_items = 50) |
|
| 107 | + { |
|
| 108 | 108 | |
| 109 | - $items_actually_migrated = 0; |
|
| 110 | - $old_org_options = get_option('events_organization_settings'); |
|
| 111 | - foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
| 112 | - // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
| 113 | - if (isset($old_org_options[ $option_name ])) { |
|
| 114 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
| 115 | - } |
|
| 116 | - if ($option_name=='surcharge') { |
|
| 117 | - $this->_insert_new_global_surcharge_price($old_org_options); |
|
| 118 | - } |
|
| 119 | - $items_actually_migrated++; |
|
| 120 | - } |
|
| 109 | + $items_actually_migrated = 0; |
|
| 110 | + $old_org_options = get_option('events_organization_settings'); |
|
| 111 | + foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
| 112 | + // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
| 113 | + if (isset($old_org_options[ $option_name ])) { |
|
| 114 | + $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
| 115 | + } |
|
| 116 | + if ($option_name=='surcharge') { |
|
| 117 | + $this->_insert_new_global_surcharge_price($old_org_options); |
|
| 118 | + } |
|
| 119 | + $items_actually_migrated++; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - $success = EE_Config::instance()->update_espresso_config(false, true); |
|
| 123 | - if (! $success) { |
|
| 124 | - $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
| 125 | - EE_Error::overwrite_errors(); |
|
| 126 | - } |
|
| 127 | - EE_Network_Config::instance()->update_config(false, false); |
|
| 128 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 129 | - // we may have added new pages and this might be necessary |
|
| 130 | - flush_rewrite_rules(); |
|
| 131 | - $this->set_completed(); |
|
| 132 | - } |
|
| 133 | - return $items_actually_migrated; |
|
| 134 | - } |
|
| 135 | - public function _count_records_to_migrate() |
|
| 136 | - { |
|
| 137 | - $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
| 138 | - return $count_of_options_to_migrate; |
|
| 139 | - } |
|
| 140 | - public function __construct() |
|
| 141 | - { |
|
| 142 | - $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
| 143 | - $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
| 144 | - parent::__construct(); |
|
| 145 | - } |
|
| 122 | + $success = EE_Config::instance()->update_espresso_config(false, true); |
|
| 123 | + if (! $success) { |
|
| 124 | + $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
| 125 | + EE_Error::overwrite_errors(); |
|
| 126 | + } |
|
| 127 | + EE_Network_Config::instance()->update_config(false, false); |
|
| 128 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 129 | + // we may have added new pages and this might be necessary |
|
| 130 | + flush_rewrite_rules(); |
|
| 131 | + $this->set_completed(); |
|
| 132 | + } |
|
| 133 | + return $items_actually_migrated; |
|
| 134 | + } |
|
| 135 | + public function _count_records_to_migrate() |
|
| 136 | + { |
|
| 137 | + $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
| 138 | + return $count_of_options_to_migrate; |
|
| 139 | + } |
|
| 140 | + public function __construct() |
|
| 141 | + { |
|
| 142 | + $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
| 143 | + $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
| 144 | + parent::__construct(); |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - private function _handle_org_option($option_name, $value) |
|
| 148 | - { |
|
| 149 | - $c = EE_Config::instance(); |
|
| 150 | - $cn = EE_Network_Config::instance(); |
|
| 151 | - switch ($option_name) { |
|
| 152 | - case 'organization': |
|
| 153 | - $c->organization->name = $value; |
|
| 154 | - break; |
|
| 155 | - case 'organization_street1': |
|
| 156 | - $c->organization->address_1 = $value; |
|
| 157 | - break; |
|
| 158 | - case 'organization_street2': |
|
| 159 | - $c->organization->address_2 = $value; |
|
| 160 | - break; |
|
| 161 | - case 'organization_city': |
|
| 162 | - $c->organization->city = $value; |
|
| 163 | - break; |
|
| 164 | - case 'organization_state': |
|
| 165 | - try { |
|
| 166 | - $state = $this->get_migration_script()->get_or_create_state($value); |
|
| 167 | - $state_id = $state['STA_ID']; |
|
| 168 | - $c->organization->STA_ID = $state_id; |
|
| 169 | - } catch (EE_Error $e) { |
|
| 170 | - } |
|
| 171 | - break; |
|
| 172 | - case 'organization_zip': |
|
| 173 | - $c->organization->zip = $value; |
|
| 174 | - break; |
|
| 175 | - case 'contact_email': |
|
| 176 | - $c->organization->email = $value; |
|
| 177 | - break; |
|
| 178 | - case 'default_payment_status': |
|
| 179 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
| 180 | - break; |
|
| 181 | - case 'organization_country': |
|
| 182 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 183 | - $c->organization->CNT_ISO = $iso; |
|
| 184 | - $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
| 185 | - if (! $country_row) { |
|
| 186 | - $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
| 187 | - } |
|
| 188 | - // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
| 189 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 190 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 191 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 192 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 193 | - $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
| 194 | - $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 195 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 196 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 147 | + private function _handle_org_option($option_name, $value) |
|
| 148 | + { |
|
| 149 | + $c = EE_Config::instance(); |
|
| 150 | + $cn = EE_Network_Config::instance(); |
|
| 151 | + switch ($option_name) { |
|
| 152 | + case 'organization': |
|
| 153 | + $c->organization->name = $value; |
|
| 154 | + break; |
|
| 155 | + case 'organization_street1': |
|
| 156 | + $c->organization->address_1 = $value; |
|
| 157 | + break; |
|
| 158 | + case 'organization_street2': |
|
| 159 | + $c->organization->address_2 = $value; |
|
| 160 | + break; |
|
| 161 | + case 'organization_city': |
|
| 162 | + $c->organization->city = $value; |
|
| 163 | + break; |
|
| 164 | + case 'organization_state': |
|
| 165 | + try { |
|
| 166 | + $state = $this->get_migration_script()->get_or_create_state($value); |
|
| 167 | + $state_id = $state['STA_ID']; |
|
| 168 | + $c->organization->STA_ID = $state_id; |
|
| 169 | + } catch (EE_Error $e) { |
|
| 170 | + } |
|
| 171 | + break; |
|
| 172 | + case 'organization_zip': |
|
| 173 | + $c->organization->zip = $value; |
|
| 174 | + break; |
|
| 175 | + case 'contact_email': |
|
| 176 | + $c->organization->email = $value; |
|
| 177 | + break; |
|
| 178 | + case 'default_payment_status': |
|
| 179 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
| 180 | + break; |
|
| 181 | + case 'organization_country': |
|
| 182 | + $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 183 | + $c->organization->CNT_ISO = $iso; |
|
| 184 | + $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
| 185 | + if (! $country_row) { |
|
| 186 | + $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
| 187 | + } |
|
| 188 | + // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
| 189 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 190 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 191 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 192 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 193 | + $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
| 194 | + $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 195 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 196 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 197 | 197 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
| 198 | 198 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
| 199 | 199 | // $c->currency->sign = $value;break; |
| 200 | - case 'show_pending_payment_options': |
|
| 201 | - $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
| 202 | - break; |
|
| 203 | - case 'display_address_in_regform': |
|
| 204 | - $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
| 205 | - break; |
|
| 206 | - case 'default_logo_url': |
|
| 207 | - $c->organization->logo_url = $value; |
|
| 208 | - break; |
|
| 209 | - case 'event_page_id': |
|
| 210 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 211 | - // to ESPRESSO_THANK_YOU |
|
| 212 | - $reg_page_post = get_post($value); |
|
| 213 | - $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
| 214 | - wp_update_post($reg_page_post); |
|
| 215 | - $c->core->reg_page_id = $value; |
|
| 216 | - break; |
|
| 217 | - case 'return_url': |
|
| 218 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 219 | - // to ESPRESSO_THANK_YOU |
|
| 220 | - $thank_you_page_post = get_post($value); |
|
| 221 | - $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
| 222 | - wp_update_post($thank_you_page_post); |
|
| 223 | - $c->core->thank_you_page_id = $value; |
|
| 224 | - break; |
|
| 225 | - case 'cancel_return': |
|
| 226 | - $c->core->cancel_page_id = $value; |
|
| 200 | + case 'show_pending_payment_options': |
|
| 201 | + $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
| 202 | + break; |
|
| 203 | + case 'display_address_in_regform': |
|
| 204 | + $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
| 205 | + break; |
|
| 206 | + case 'default_logo_url': |
|
| 207 | + $c->organization->logo_url = $value; |
|
| 208 | + break; |
|
| 209 | + case 'event_page_id': |
|
| 210 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 211 | + // to ESPRESSO_THANK_YOU |
|
| 212 | + $reg_page_post = get_post($value); |
|
| 213 | + $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
| 214 | + wp_update_post($reg_page_post); |
|
| 215 | + $c->core->reg_page_id = $value; |
|
| 216 | + break; |
|
| 217 | + case 'return_url': |
|
| 218 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 219 | + // to ESPRESSO_THANK_YOU |
|
| 220 | + $thank_you_page_post = get_post($value); |
|
| 221 | + $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
| 222 | + wp_update_post($thank_you_page_post); |
|
| 223 | + $c->core->thank_you_page_id = $value; |
|
| 224 | + break; |
|
| 225 | + case 'cancel_return': |
|
| 226 | + $c->core->cancel_page_id = $value; |
|
| 227 | 227 | |
| 228 | - break; |
|
| 229 | - case 'notify_url': |
|
| 230 | - $c->core->txn_page_id = $value; |
|
| 231 | - break; |
|
| 232 | - case 'use_captcha': |
|
| 233 | - $c->registration->use_captcha = ($value == 'Y'); |
|
| 234 | - break; |
|
| 235 | - case 'recaptcha_publickey': |
|
| 236 | - $c->registration->recaptcha_publickey = $value; |
|
| 237 | - break; |
|
| 238 | - case 'recaptcha_privatekey': |
|
| 239 | - $c->registration->recaptcha_privatekey = $value; |
|
| 240 | - break; |
|
| 241 | - case 'recaptcha_theme': |
|
| 242 | - $c->registration->recaptcha_theme = $value; |
|
| 243 | - break; |
|
| 244 | - case 'recaptcha_width': |
|
| 245 | - $c->registration->recaptcha_width = $value; |
|
| 246 | - break; |
|
| 247 | - case 'recaptcha_language': |
|
| 248 | - $c->registration->recaptcha_language = $value; |
|
| 249 | - break; |
|
| 250 | - case 'espresso_dashboard_widget': |
|
| 251 | - $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
| 252 | - break; |
|
| 253 | - case 'use_personnel_manager': |
|
| 254 | - $c->admin->use_personnel_manager = ($value == 'Y'); |
|
| 255 | - break; |
|
| 256 | - case 'use_event_timezones': |
|
| 257 | - $c->admin->use_event_timezones = ($value == 'Y'); |
|
| 258 | - break; |
|
| 259 | - case 'full_logging': |
|
| 260 | - $c->admin->use_full_logging = ($value == 'Y'); |
|
| 261 | - break; |
|
| 262 | - case 'affiliate_id': |
|
| 263 | - $c->admin->affiliate_id = $value; |
|
| 264 | - break; |
|
| 265 | - case 'site_license_key': |
|
| 266 | - $cn->core->site_license_key = $value; |
|
| 267 | - break; |
|
| 268 | - default: |
|
| 269 | - do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
| 270 | - } |
|
| 271 | - } |
|
| 228 | + break; |
|
| 229 | + case 'notify_url': |
|
| 230 | + $c->core->txn_page_id = $value; |
|
| 231 | + break; |
|
| 232 | + case 'use_captcha': |
|
| 233 | + $c->registration->use_captcha = ($value == 'Y'); |
|
| 234 | + break; |
|
| 235 | + case 'recaptcha_publickey': |
|
| 236 | + $c->registration->recaptcha_publickey = $value; |
|
| 237 | + break; |
|
| 238 | + case 'recaptcha_privatekey': |
|
| 239 | + $c->registration->recaptcha_privatekey = $value; |
|
| 240 | + break; |
|
| 241 | + case 'recaptcha_theme': |
|
| 242 | + $c->registration->recaptcha_theme = $value; |
|
| 243 | + break; |
|
| 244 | + case 'recaptcha_width': |
|
| 245 | + $c->registration->recaptcha_width = $value; |
|
| 246 | + break; |
|
| 247 | + case 'recaptcha_language': |
|
| 248 | + $c->registration->recaptcha_language = $value; |
|
| 249 | + break; |
|
| 250 | + case 'espresso_dashboard_widget': |
|
| 251 | + $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
| 252 | + break; |
|
| 253 | + case 'use_personnel_manager': |
|
| 254 | + $c->admin->use_personnel_manager = ($value == 'Y'); |
|
| 255 | + break; |
|
| 256 | + case 'use_event_timezones': |
|
| 257 | + $c->admin->use_event_timezones = ($value == 'Y'); |
|
| 258 | + break; |
|
| 259 | + case 'full_logging': |
|
| 260 | + $c->admin->use_full_logging = ($value == 'Y'); |
|
| 261 | + break; |
|
| 262 | + case 'affiliate_id': |
|
| 263 | + $c->admin->affiliate_id = $value; |
|
| 264 | + break; |
|
| 265 | + case 'site_license_key': |
|
| 266 | + $cn->core->site_license_key = $value; |
|
| 267 | + break; |
|
| 268 | + default: |
|
| 269 | + do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * Creates a 4.1 member price discount |
|
| 275 | - * @global type $wpdb |
|
| 276 | - * @param type $old_price |
|
| 277 | - * @return int |
|
| 278 | - */ |
|
| 279 | - private function _insert_new_global_surcharge_price($org_options) |
|
| 280 | - { |
|
| 281 | - $amount = floatval($org_options['surcharge']); |
|
| 282 | - // dont createa a price if the surcharge is 0 |
|
| 283 | - if ($amount <=.01) { |
|
| 284 | - return 0; |
|
| 285 | - } |
|
| 286 | - if ($org_options['surcharge_type'] == 'flat_rate') { |
|
| 287 | - $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
| 288 | - } else { |
|
| 289 | - $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
| 290 | - } |
|
| 291 | - global $wpdb; |
|
| 292 | - $cols_n_values = array( |
|
| 293 | - 'PRT_ID'=>$price_type, |
|
| 294 | - 'PRC_amount'=>$amount, |
|
| 295 | - 'PRC_name'=> $org_options['surcharge_text'], |
|
| 296 | - 'PRC_is_default'=>true, |
|
| 297 | - 'PRC_overrides'=>false, |
|
| 298 | - 'PRC_order'=>100, |
|
| 299 | - 'PRC_deleted'=>false, |
|
| 300 | - 'PRC_parent'=>null |
|
| 273 | + /** |
|
| 274 | + * Creates a 4.1 member price discount |
|
| 275 | + * @global type $wpdb |
|
| 276 | + * @param type $old_price |
|
| 277 | + * @return int |
|
| 278 | + */ |
|
| 279 | + private function _insert_new_global_surcharge_price($org_options) |
|
| 280 | + { |
|
| 281 | + $amount = floatval($org_options['surcharge']); |
|
| 282 | + // dont createa a price if the surcharge is 0 |
|
| 283 | + if ($amount <=.01) { |
|
| 284 | + return 0; |
|
| 285 | + } |
|
| 286 | + if ($org_options['surcharge_type'] == 'flat_rate') { |
|
| 287 | + $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
| 288 | + } else { |
|
| 289 | + $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
| 290 | + } |
|
| 291 | + global $wpdb; |
|
| 292 | + $cols_n_values = array( |
|
| 293 | + 'PRT_ID'=>$price_type, |
|
| 294 | + 'PRC_amount'=>$amount, |
|
| 295 | + 'PRC_name'=> $org_options['surcharge_text'], |
|
| 296 | + 'PRC_is_default'=>true, |
|
| 297 | + 'PRC_overrides'=>false, |
|
| 298 | + 'PRC_order'=>100, |
|
| 299 | + 'PRC_deleted'=>false, |
|
| 300 | + 'PRC_parent'=>null |
|
| 301 | 301 | |
| 302 | - ); |
|
| 303 | - $datatypes = array( |
|
| 304 | - '%d',// PRT_ID |
|
| 305 | - '%f',// PRT_amount |
|
| 306 | - '%s',// PRC_name |
|
| 307 | - '%d',// PRC_is_default |
|
| 308 | - '%d',// PRC_overrides |
|
| 309 | - '%d',// PRC_order |
|
| 310 | - '%d',// PRC_deleted |
|
| 311 | - '%d',// PRC_parent |
|
| 312 | - ); |
|
| 313 | - $price_table = $wpdb->prefix."esp_price"; |
|
| 314 | - $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
| 315 | - if (! $success) { |
|
| 316 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
| 317 | - 'org_options', |
|
| 318 | - array( |
|
| 319 | - 'surcharge'=>$org_options['surcharge'], |
|
| 320 | - 'surcharge_type'=>$org_options['surcharge_type'], |
|
| 321 | - 'surcharge_text'=>$org_options['surcharge_text']), |
|
| 322 | - $price_table, |
|
| 323 | - $cols_n_values, |
|
| 324 | - $datatypes |
|
| 325 | - )); |
|
| 326 | - return 0; |
|
| 327 | - } |
|
| 328 | - $new_id = $wpdb->insert_id; |
|
| 329 | - return $new_id; |
|
| 330 | - } |
|
| 302 | + ); |
|
| 303 | + $datatypes = array( |
|
| 304 | + '%d',// PRT_ID |
|
| 305 | + '%f',// PRT_amount |
|
| 306 | + '%s',// PRC_name |
|
| 307 | + '%d',// PRC_is_default |
|
| 308 | + '%d',// PRC_overrides |
|
| 309 | + '%d',// PRC_order |
|
| 310 | + '%d',// PRC_deleted |
|
| 311 | + '%d',// PRC_parent |
|
| 312 | + ); |
|
| 313 | + $price_table = $wpdb->prefix."esp_price"; |
|
| 314 | + $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
| 315 | + if (! $success) { |
|
| 316 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
| 317 | + 'org_options', |
|
| 318 | + array( |
|
| 319 | + 'surcharge'=>$org_options['surcharge'], |
|
| 320 | + 'surcharge_type'=>$org_options['surcharge_type'], |
|
| 321 | + 'surcharge_text'=>$org_options['surcharge_text']), |
|
| 322 | + $price_table, |
|
| 323 | + $cols_n_values, |
|
| 324 | + $datatypes |
|
| 325 | + )); |
|
| 326 | + return 0; |
|
| 327 | + } |
|
| 328 | + $new_id = $wpdb->insert_id; |
|
| 329 | + return $new_id; |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - protected $_org_options_we_know_how_to_migrate = array( |
|
| 333 | - 'organization', |
|
| 334 | - 'organization_street1', |
|
| 335 | - 'organization_street2', |
|
| 336 | - 'organization_city', |
|
| 337 | - 'organization_state', |
|
| 338 | - 'organization_zip', |
|
| 339 | - 'contact_email', |
|
| 340 | - 'default_mail', |
|
| 341 | - 'payment_subject', |
|
| 342 | - 'payment_message', |
|
| 343 | - 'message', |
|
| 344 | - 'default_payment_status', |
|
| 345 | - 'surcharge',// unused? |
|
| 346 | - 'country_id',// unused? |
|
| 347 | - 'organization_country', |
|
| 332 | + protected $_org_options_we_know_how_to_migrate = array( |
|
| 333 | + 'organization', |
|
| 334 | + 'organization_street1', |
|
| 335 | + 'organization_street2', |
|
| 336 | + 'organization_city', |
|
| 337 | + 'organization_state', |
|
| 338 | + 'organization_zip', |
|
| 339 | + 'contact_email', |
|
| 340 | + 'default_mail', |
|
| 341 | + 'payment_subject', |
|
| 342 | + 'payment_message', |
|
| 343 | + 'message', |
|
| 344 | + 'default_payment_status', |
|
| 345 | + 'surcharge',// unused? |
|
| 346 | + 'country_id',// unused? |
|
| 347 | + 'organization_country', |
|
| 348 | 348 | // 'currency_symbol', |
| 349 | - 'expire_on_registration_end', |
|
| 350 | - 'email_before_payment', |
|
| 351 | - 'email_fancy_headers', |
|
| 352 | - 'enable_default_style', |
|
| 353 | - 'event_ssl_active', |
|
| 354 | - 'selected_style', |
|
| 355 | - 'show_pending_payment_options', |
|
| 356 | - 'show_reg_footer', |
|
| 357 | - 'skip_confirmation_page', |
|
| 358 | - 'allow_mer_discounts',// no equiv |
|
| 359 | - 'allow_mer_vouchers',// no equiv |
|
| 360 | - 'display_short_description_in_event_list', |
|
| 361 | - 'display_description_on_multi_reg_page', |
|
| 362 | - 'display_address_in_event_list', |
|
| 363 | - 'display_address_in_regform', |
|
| 364 | - 'use_custom_post_types',// no equiv |
|
| 365 | - 'display_ical_download', |
|
| 366 | - 'display_featured_image', |
|
| 367 | - 'themeroller', |
|
| 368 | - 'default_logo_url', |
|
| 369 | - 'event_page_id', |
|
| 370 | - 'return_url', |
|
| 371 | - 'cancel_return', |
|
| 372 | - 'notify_url', |
|
| 373 | - 'events_in_dashboard', |
|
| 374 | - 'use_captcha', |
|
| 375 | - 'recaptcha_publickey', |
|
| 376 | - 'recaptcha_privatekey', |
|
| 377 | - 'recaptcha_theme', |
|
| 378 | - 'recaptcha_width', |
|
| 379 | - 'recaptcha_language', |
|
| 380 | - 'espresso_dashboard_widget', |
|
| 381 | - 'time_reg_limit', |
|
| 349 | + 'expire_on_registration_end', |
|
| 350 | + 'email_before_payment', |
|
| 351 | + 'email_fancy_headers', |
|
| 352 | + 'enable_default_style', |
|
| 353 | + 'event_ssl_active', |
|
| 354 | + 'selected_style', |
|
| 355 | + 'show_pending_payment_options', |
|
| 356 | + 'show_reg_footer', |
|
| 357 | + 'skip_confirmation_page', |
|
| 358 | + 'allow_mer_discounts',// no equiv |
|
| 359 | + 'allow_mer_vouchers',// no equiv |
|
| 360 | + 'display_short_description_in_event_list', |
|
| 361 | + 'display_description_on_multi_reg_page', |
|
| 362 | + 'display_address_in_event_list', |
|
| 363 | + 'display_address_in_regform', |
|
| 364 | + 'use_custom_post_types',// no equiv |
|
| 365 | + 'display_ical_download', |
|
| 366 | + 'display_featured_image', |
|
| 367 | + 'themeroller', |
|
| 368 | + 'default_logo_url', |
|
| 369 | + 'event_page_id', |
|
| 370 | + 'return_url', |
|
| 371 | + 'cancel_return', |
|
| 372 | + 'notify_url', |
|
| 373 | + 'events_in_dashboard', |
|
| 374 | + 'use_captcha', |
|
| 375 | + 'recaptcha_publickey', |
|
| 376 | + 'recaptcha_privatekey', |
|
| 377 | + 'recaptcha_theme', |
|
| 378 | + 'recaptcha_width', |
|
| 379 | + 'recaptcha_language', |
|
| 380 | + 'espresso_dashboard_widget', |
|
| 381 | + 'time_reg_limit', |
|
| 382 | 382 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
| 383 | - 'use_personnel_manager',// no equiv |
|
| 384 | - 'use_event_timezones', |
|
| 385 | - 'full_logging', |
|
| 386 | - 'surcharge_type',// unused |
|
| 387 | - 'surcharge_text',// unused |
|
| 388 | - 'affiliate_id', |
|
| 389 | - 'site_license_key', |
|
| 390 | - ); |
|
| 383 | + 'use_personnel_manager',// no equiv |
|
| 384 | + 'use_event_timezones', |
|
| 385 | + 'full_logging', |
|
| 386 | + 'surcharge_type',// unused |
|
| 387 | + 'surcharge_text',// unused |
|
| 388 | + 'affiliate_id', |
|
| 389 | + 'site_license_key', |
|
| 390 | + ); |
|
| 391 | 391 | } |
@@ -110,17 +110,17 @@ discard block |
||
| 110 | 110 | $old_org_options = get_option('events_organization_settings'); |
| 111 | 111 | foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
| 112 | 112 | // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
| 113 | - if (isset($old_org_options[ $option_name ])) { |
|
| 114 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
| 113 | + if (isset($old_org_options[$option_name])) { |
|
| 114 | + $this->_handle_org_option($option_name, $old_org_options[$option_name]); |
|
| 115 | 115 | } |
| 116 | - if ($option_name=='surcharge') { |
|
| 116 | + if ($option_name == 'surcharge') { |
|
| 117 | 117 | $this->_insert_new_global_surcharge_price($old_org_options); |
| 118 | 118 | } |
| 119 | 119 | $items_actually_migrated++; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $success = EE_Config::instance()->update_espresso_config(false, true); |
| 123 | - if (! $success) { |
|
| 123 | + if ( ! $success) { |
|
| 124 | 124 | $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
| 125 | 125 | EE_Error::overwrite_errors(); |
| 126 | 126 | } |
@@ -176,24 +176,24 @@ discard block |
||
| 176 | 176 | $c->organization->email = $value; |
| 177 | 177 | break; |
| 178 | 178 | case 'default_payment_status': |
| 179 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
| 179 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
| 180 | 180 | break; |
| 181 | 181 | case 'organization_country': |
| 182 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 182 | + $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 183 | 183 | $c->organization->CNT_ISO = $iso; |
| 184 | 184 | $country_row = $this->get_migration_script()->get_or_create_country($iso); |
| 185 | - if (! $country_row) { |
|
| 185 | + if ( ! $country_row) { |
|
| 186 | 186 | $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
| 187 | 187 | } |
| 188 | 188 | // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
| 189 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 190 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 191 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 192 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 193 | - $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
| 194 | - $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 195 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 196 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 189 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 190 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 191 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 192 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 193 | + $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE or FALSE$ |
|
| 194 | + $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 195 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 196 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 197 | 197 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
| 198 | 198 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
| 199 | 199 | // $c->currency->sign = $value;break; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | { |
| 281 | 281 | $amount = floatval($org_options['surcharge']); |
| 282 | 282 | // dont createa a price if the surcharge is 0 |
| 283 | - if ($amount <=.01) { |
|
| 283 | + if ($amount <= .01) { |
|
| 284 | 284 | return 0; |
| 285 | 285 | } |
| 286 | 286 | if ($org_options['surcharge_type'] == 'flat_rate') { |
@@ -301,18 +301,18 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | ); |
| 303 | 303 | $datatypes = array( |
| 304 | - '%d',// PRT_ID |
|
| 305 | - '%f',// PRT_amount |
|
| 306 | - '%s',// PRC_name |
|
| 307 | - '%d',// PRC_is_default |
|
| 308 | - '%d',// PRC_overrides |
|
| 309 | - '%d',// PRC_order |
|
| 310 | - '%d',// PRC_deleted |
|
| 311 | - '%d',// PRC_parent |
|
| 304 | + '%d', // PRT_ID |
|
| 305 | + '%f', // PRT_amount |
|
| 306 | + '%s', // PRC_name |
|
| 307 | + '%d', // PRC_is_default |
|
| 308 | + '%d', // PRC_overrides |
|
| 309 | + '%d', // PRC_order |
|
| 310 | + '%d', // PRC_deleted |
|
| 311 | + '%d', // PRC_parent |
|
| 312 | 312 | ); |
| 313 | 313 | $price_table = $wpdb->prefix."esp_price"; |
| 314 | 314 | $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
| 315 | - if (! $success) { |
|
| 315 | + if ( ! $success) { |
|
| 316 | 316 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
| 317 | 317 | 'org_options', |
| 318 | 318 | array( |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | 'payment_message', |
| 343 | 343 | 'message', |
| 344 | 344 | 'default_payment_status', |
| 345 | - 'surcharge',// unused? |
|
| 346 | - 'country_id',// unused? |
|
| 345 | + 'surcharge', // unused? |
|
| 346 | + 'country_id', // unused? |
|
| 347 | 347 | 'organization_country', |
| 348 | 348 | // 'currency_symbol', |
| 349 | 349 | 'expire_on_registration_end', |
@@ -355,13 +355,13 @@ discard block |
||
| 355 | 355 | 'show_pending_payment_options', |
| 356 | 356 | 'show_reg_footer', |
| 357 | 357 | 'skip_confirmation_page', |
| 358 | - 'allow_mer_discounts',// no equiv |
|
| 359 | - 'allow_mer_vouchers',// no equiv |
|
| 358 | + 'allow_mer_discounts', // no equiv |
|
| 359 | + 'allow_mer_vouchers', // no equiv |
|
| 360 | 360 | 'display_short_description_in_event_list', |
| 361 | 361 | 'display_description_on_multi_reg_page', |
| 362 | 362 | 'display_address_in_event_list', |
| 363 | 363 | 'display_address_in_regform', |
| 364 | - 'use_custom_post_types',// no equiv |
|
| 364 | + 'use_custom_post_types', // no equiv |
|
| 365 | 365 | 'display_ical_download', |
| 366 | 366 | 'display_featured_image', |
| 367 | 367 | 'themeroller', |
@@ -380,11 +380,11 @@ discard block |
||
| 380 | 380 | 'espresso_dashboard_widget', |
| 381 | 381 | 'time_reg_limit', |
| 382 | 382 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
| 383 | - 'use_personnel_manager',// no equiv |
|
| 383 | + 'use_personnel_manager', // no equiv |
|
| 384 | 384 | 'use_event_timezones', |
| 385 | 385 | 'full_logging', |
| 386 | - 'surcharge_type',// unused |
|
| 387 | - 'surcharge_text',// unused |
|
| 386 | + 'surcharge_type', // unused |
|
| 387 | + 'surcharge_text', // unused |
|
| 388 | 388 | 'affiliate_id', |
| 389 | 389 | 'site_license_key', |
| 390 | 390 | ); |