Completed
Pull Request — Gutenberg/master (#543)
by Darren
25:54 queued 10:43
created
core/domain/services/assets/CoreAssetManager.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             //js.api
174 174
             $this->addJavascript(
175 175
                 CoreAssetManager::JS_HANDLE_EE_JS_API,
176
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
176
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
177 177
                 array(
178 178
                     CoreAssetManager::JS_HANDLE_UNDERSCORE,
179 179
                     CoreAssetManager::JS_HANDLE_EE_JS_CORE
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 
186 186
         $this->addJavascript(
187 187
             CoreAssetManager::JS_HANDLE_EE_CORE,
188
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
188
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
189 189
             array(CoreAssetManager::JS_HANDLE_JQUERY)
190 190
         )
191 191
         ->setInlineDataCallback(
192
-            function () {
192
+            function() {
193 193
                 wp_localize_script(
194 194
                     CoreAssetManager::JS_HANDLE_EE_CORE,
195 195
                     CoreAssetManager::JS_HANDLE_EE_I18N,
@@ -211,16 +211,16 @@  discard block
 block discarded – undo
211 211
         if ($this->template_config->enable_default_style && ! is_admin()) {
212 212
             $this->addStylesheet(
213 213
                 CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
214
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
214
+                is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
215 215
                     ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
216
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
216
+                    : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
217 217
                 array('dashicons')
218 218
             );
219 219
             //Load custom style sheet if available
220 220
             if ($this->template_config->custom_style_sheet !== null) {
221 221
                 $this->addStylesheet(
222 222
                     CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
223
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
223
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
224 224
                     array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
225 225
                 );
226 226
             }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $this->addJavascript(
242 242
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
243
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
243
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
244 244
             array(CoreAssetManager::JS_HANDLE_JQUERY)
245 245
         )
246 246
         ->setVersion('1.15.0');
247 247
 
248 248
         $this->addJavascript(
249 249
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
250
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
250
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
251 251
             array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
252 252
         )
253 253
         ->setVersion('1.15.0');
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         // @link http://josscrowcroft.github.io/accounting.js/
269 269
         $this->addJavascript(
270 270
             CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
271
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
271
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
272 272
             array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
273 273
         )
274 274
         ->setVersion('0.3.2');
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
         $currency_config = $this->currency_config;
277 277
         $this->addJavascript(
278 278
             CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
279
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
279
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
280 280
             array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
281 281
         )
282 282
         ->setInlineDataCallback(
283
-            function () use ($currency_config) {
283
+            function() use ($currency_config) {
284 284
                  wp_localize_script(
285 285
                      CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
286 286
                      'EE_ACCOUNTING_CFG',
Please login to merge, or discard this patch.
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -29,368 +29,368 @@
 block discarded – undo
29 29
 class CoreAssetManager extends AssetManager
30 30
 {
31 31
 
32
-    // WordPress core / Third party JS asset handles
33
-    const JS_HANDLE_JQUERY = 'jquery';
32
+	// WordPress core / Third party JS asset handles
33
+	const JS_HANDLE_JQUERY = 'jquery';
34 34
 
35
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
35
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
36 36
 
37
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
37
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
38 38
 
39
-    const JS_HANDLE_UNDERSCORE = 'underscore';
39
+	const JS_HANDLE_UNDERSCORE = 'underscore';
40 40
 
41
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
41
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
42 42
 
43
-    // EE JS assets handles
44
-    const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
45
-
46
-    const JS_HANDLE_EE_JS_CORE = 'eejs-core';
47
-
48
-    const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
43
+	// EE JS assets handles
44
+	const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
45
+
46
+	const JS_HANDLE_EE_JS_CORE = 'eejs-core';
47
+
48
+	const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
49 49
 
50
-    const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
51
-
52
-    const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
53
-
54
-    const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
55
-
56
-    const JS_HANDLE_EE_JS_API = 'eejs-api';
57
-
58
-    const JS_HANDLE_EE_CORE = 'espresso_core';
59
-
60
-    const JS_HANDLE_EE_I18N = 'eei18n';
61
-
62
-    const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
63
-
64
-    const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
65
-
66
-    // EE CSS assets handles
67
-    const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
68
-
69
-    const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
70
-
71
-    /**
72
-     * @var EE_Currency_Config $currency_config
73
-     */
74
-    protected $currency_config;
75
-
76
-    /**
77
-     * @var EE_Template_Config $template_config
78
-     */
79
-    protected $template_config;
80
-
81
-
82
-    /**
83
-     * CoreAssetRegister constructor.
84
-     *
85
-     * @param AssetCollection    $assets
86
-     * @param EE_Currency_Config $currency_config
87
-     * @param EE_Template_Config $template_config
88
-     * @param DomainInterface    $domain
89
-     * @param Registry           $registry
90
-     */
91
-    public function __construct(
92
-        AssetCollection $assets,
93
-        EE_Currency_Config $currency_config,
94
-        EE_Template_Config $template_config,
95
-        DomainInterface $domain,
96
-        Registry $registry
97
-    ) {
98
-        $this->currency_config = $currency_config;
99
-        $this->template_config = $template_config;
100
-        parent::__construct($domain, $assets, $registry);
101
-    }
102
-
103
-
104
-    /**
105
-     * @since 4.9.62.p
106
-     * @throws DuplicateCollectionIdentifierException
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidEntityException
110
-     */
111
-    public function addAssets()
112
-    {
113
-        $this->addJavascriptFiles();
114
-        $this->addStylesheetFiles();
115
-    }
116
-
117
-
118
-    /**
119
-     * @since 4.9.62.p
120
-     * @throws DuplicateCollectionIdentifierException
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidEntityException
124
-     */
125
-    public function addJavascriptFiles()
126
-    {
127
-        $this->loadCoreJs();
128
-        $this->loadJqueryValidate();
129
-        $this->loadAccountingJs();
130
-        add_action(
131
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
132
-            array($this, 'loadQtipJs')
133
-        );
134
-        $this->registerAdminAssets();
135
-    }
136
-
137
-
138
-    /**
139
-     * @since 4.9.62.p
140
-     * @throws DuplicateCollectionIdentifierException
141
-     * @throws InvalidDataTypeException
142
-     * @throws InvalidEntityException
143
-     */
144
-    public function addStylesheetFiles()
145
-    {
146
-        $this->loadCoreCss();
147
-    }
148
-
149
-
150
-    /**
151
-     * core default javascript
152
-     *
153
-     * @since 4.9.62.p
154
-     * @throws DuplicateCollectionIdentifierException
155
-     * @throws InvalidArgumentException
156
-     * @throws InvalidDataTypeException
157
-     * @throws InvalidEntityException
158
-     */
159
-    private function loadCoreJs()
160
-    {
161
-        $this->addJavascript(
162
-            CoreAssetManager::JS_HANDLE_EE_MANIFEST,
163
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
164
-        );
165
-
166
-        $this->addJavascript(
167
-            CoreAssetManager::JS_HANDLE_EE_JS_CORE,
168
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
169
-            array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
170
-        )
171
-        ->setHasInlineData();
172
-
173
-        $this->addJavascript(
174
-            CoreAssetManager::JS_HANDLE_EE_VENDOR,
175
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
176
-            array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
177
-        );
178
-
179
-        $this->addJavascript(
180
-            CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
181
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
182
-            array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
183
-        )
184
-        ->setRequiresTranslation();
185
-
186
-        $this->addJavascript(
187
-            CoreAssetManager::JS_HANDLE_EE_HELPERS,
188
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
189
-        )->setRequiresTranslation();
190
-
191
-        $this->addJavascript(
192
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
193
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
194
-            array(CoreAssetManager::JS_HANDLE_EE_DATA_STORES, CoreAssetManager::JS_HANDLE_EE_HELPERS)
195
-        )
196
-        ->setRequiresTranslation();
197
-
198
-        global $wp_version;
199
-        if (version_compare($wp_version, '4.4.0', '>')) {
200
-            //js.api
201
-            $this->addJavascript(
202
-                CoreAssetManager::JS_HANDLE_EE_JS_API,
203
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
204
-                array(
205
-                    CoreAssetManager::JS_HANDLE_UNDERSCORE,
206
-                    CoreAssetManager::JS_HANDLE_EE_JS_CORE
207
-                )
208
-            );
209
-            $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
210
-            $this->registry->addData(
211
-                'paths',
212
-                array(
213
-                    'rest_route' => rest_url('ee/v4.8.36/'),
214
-                    'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
215
-                    'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()
216
-                )
217
-            );
218
-            /** site formatting values **/
219
-            $this->registry->addData(
220
-                'site_formats',
221
-                array(
222
-                    'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
223
-                )
224
-            );
225
-        }
226
-
227
-        $this->addJavascript(
228
-            CoreAssetManager::JS_HANDLE_EE_CORE,
229
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
230
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
231
-        )
232
-        ->setInlineDataCallback(
233
-            function () {
234
-                wp_localize_script(
235
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
236
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
237
-                    EE_Registry::$i18n_js_strings
238
-                );
239
-            }
240
-        );
241
-    }
242
-
243
-
244
-    /**
245
-     * @since 4.9.62.p
246
-     * @throws DuplicateCollectionIdentifierException
247
-     * @throws InvalidDataTypeException
248
-     * @throws InvalidEntityException
249
-     */
250
-    private function loadCoreCss()
251
-    {
252
-        if ($this->template_config->enable_default_style && ! is_admin()) {
253
-            $this->addStylesheet(
254
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
255
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
256
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
257
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
258
-                array('dashicons')
259
-            );
260
-            //Load custom style sheet if available
261
-            if ($this->template_config->custom_style_sheet !== null) {
262
-                $this->addStylesheet(
263
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
264
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
265
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
266
-                );
267
-            }
268
-        }
269
-    }
270
-
271
-
272
-    /**
273
-     * jQuery Validate for form validation
274
-     *
275
-     * @since 4.9.62.p
276
-     * @throws DuplicateCollectionIdentifierException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidEntityException
279
-     */
280
-    private function loadJqueryValidate()
281
-    {
282
-        $this->addJavascript(
283
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
284
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
285
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
286
-        )
287
-        ->setVersion('1.15.0');
288
-
289
-        $this->addJavascript(
290
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
291
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
292
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
293
-        )
294
-        ->setVersion('1.15.0');
295
-    }
296
-
297
-
298
-    /**
299
-     * accounting.js for performing client-side calculations
300
-     *
301
-     * @since 4.9.62.p
302
-     * @throws DuplicateCollectionIdentifierException
303
-     * @throws InvalidDataTypeException
304
-     * @throws InvalidEntityException
305
-     */
306
-    private function loadAccountingJs()
307
-    {
308
-        //accounting.js library
309
-        // @link http://josscrowcroft.github.io/accounting.js/
310
-        $this->addJavascript(
311
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
312
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
313
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
314
-        )
315
-        ->setVersion('0.3.2');
316
-
317
-        $currency_config = $this->currency_config;
318
-        $this->addJavascript(
319
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
320
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
321
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
322
-        )
323
-        ->setInlineDataCallback(
324
-            function () use ($currency_config) {
325
-                 wp_localize_script(
326
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
327
-                     'EE_ACCOUNTING_CFG',
328
-                     array(
329
-                         'currency' => array(
330
-                             'symbol'    => $currency_config->sign,
331
-                             'format'    => array(
332
-                                 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
333
-                                 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
334
-                                 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
335
-                             ),
336
-                             'decimal'   => $currency_config->dec_mrk,
337
-                             'thousand'  => $currency_config->thsnds,
338
-                             'precision' => $currency_config->dec_plc,
339
-                         ),
340
-                         'number'   => array(
341
-                             'precision' => $currency_config->dec_plc,
342
-                             'thousand'  => $currency_config->thsnds,
343
-                             'decimal'   => $currency_config->dec_mrk,
344
-                         ),
345
-                     )
346
-                 );
347
-            }
348
-        )
349
-        ->setVersion();
350
-    }
351
-
352
-
353
-    /**
354
-     * registers assets for cleaning your ears
355
-     *
356
-     * @param JavascriptAsset $script
357
-     */
358
-    public function loadQtipJs(JavascriptAsset $script)
359
-    {
360
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
361
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
362
-        if (
363
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
364
-            && apply_filters('FHEE_load_qtip', false)
365
-        ) {
366
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
367
-        }
368
-    }
369
-
370
-
371
-    /**
372
-     * assets that are used in the WordPress admin
373
-     *
374
-     * @since 4.9.62.p
375
-     * @throws DuplicateCollectionIdentifierException
376
-     * @throws InvalidDataTypeException
377
-     * @throws InvalidEntityException
378
-     */
379
-    private function registerAdminAssets()
380
-    {
381
-        $this->addJavascript(
382
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
383
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
384
-            array(
385
-                CoreAssetManager::JS_HANDLE_JQUERY,
386
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
387
-            )
388
-        )
389
-        ->setRequiresTranslation();
390
-
391
-        $this->addStylesheet(
392
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
393
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
394
-        );
395
-    }
50
+	const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
51
+
52
+	const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
53
+
54
+	const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
55
+
56
+	const JS_HANDLE_EE_JS_API = 'eejs-api';
57
+
58
+	const JS_HANDLE_EE_CORE = 'espresso_core';
59
+
60
+	const JS_HANDLE_EE_I18N = 'eei18n';
61
+
62
+	const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
63
+
64
+	const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
65
+
66
+	// EE CSS assets handles
67
+	const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
68
+
69
+	const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
70
+
71
+	/**
72
+	 * @var EE_Currency_Config $currency_config
73
+	 */
74
+	protected $currency_config;
75
+
76
+	/**
77
+	 * @var EE_Template_Config $template_config
78
+	 */
79
+	protected $template_config;
80
+
81
+
82
+	/**
83
+	 * CoreAssetRegister constructor.
84
+	 *
85
+	 * @param AssetCollection    $assets
86
+	 * @param EE_Currency_Config $currency_config
87
+	 * @param EE_Template_Config $template_config
88
+	 * @param DomainInterface    $domain
89
+	 * @param Registry           $registry
90
+	 */
91
+	public function __construct(
92
+		AssetCollection $assets,
93
+		EE_Currency_Config $currency_config,
94
+		EE_Template_Config $template_config,
95
+		DomainInterface $domain,
96
+		Registry $registry
97
+	) {
98
+		$this->currency_config = $currency_config;
99
+		$this->template_config = $template_config;
100
+		parent::__construct($domain, $assets, $registry);
101
+	}
102
+
103
+
104
+	/**
105
+	 * @since 4.9.62.p
106
+	 * @throws DuplicateCollectionIdentifierException
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidEntityException
110
+	 */
111
+	public function addAssets()
112
+	{
113
+		$this->addJavascriptFiles();
114
+		$this->addStylesheetFiles();
115
+	}
116
+
117
+
118
+	/**
119
+	 * @since 4.9.62.p
120
+	 * @throws DuplicateCollectionIdentifierException
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidEntityException
124
+	 */
125
+	public function addJavascriptFiles()
126
+	{
127
+		$this->loadCoreJs();
128
+		$this->loadJqueryValidate();
129
+		$this->loadAccountingJs();
130
+		add_action(
131
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
132
+			array($this, 'loadQtipJs')
133
+		);
134
+		$this->registerAdminAssets();
135
+	}
136
+
137
+
138
+	/**
139
+	 * @since 4.9.62.p
140
+	 * @throws DuplicateCollectionIdentifierException
141
+	 * @throws InvalidDataTypeException
142
+	 * @throws InvalidEntityException
143
+	 */
144
+	public function addStylesheetFiles()
145
+	{
146
+		$this->loadCoreCss();
147
+	}
148
+
149
+
150
+	/**
151
+	 * core default javascript
152
+	 *
153
+	 * @since 4.9.62.p
154
+	 * @throws DuplicateCollectionIdentifierException
155
+	 * @throws InvalidArgumentException
156
+	 * @throws InvalidDataTypeException
157
+	 * @throws InvalidEntityException
158
+	 */
159
+	private function loadCoreJs()
160
+	{
161
+		$this->addJavascript(
162
+			CoreAssetManager::JS_HANDLE_EE_MANIFEST,
163
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
164
+		);
165
+
166
+		$this->addJavascript(
167
+			CoreAssetManager::JS_HANDLE_EE_JS_CORE,
168
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
169
+			array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
170
+		)
171
+		->setHasInlineData();
172
+
173
+		$this->addJavascript(
174
+			CoreAssetManager::JS_HANDLE_EE_VENDOR,
175
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
176
+			array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
177
+		);
178
+
179
+		$this->addJavascript(
180
+			CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
181
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
182
+			array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
183
+		)
184
+		->setRequiresTranslation();
185
+
186
+		$this->addJavascript(
187
+			CoreAssetManager::JS_HANDLE_EE_HELPERS,
188
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
189
+		)->setRequiresTranslation();
190
+
191
+		$this->addJavascript(
192
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
193
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
194
+			array(CoreAssetManager::JS_HANDLE_EE_DATA_STORES, CoreAssetManager::JS_HANDLE_EE_HELPERS)
195
+		)
196
+		->setRequiresTranslation();
197
+
198
+		global $wp_version;
199
+		if (version_compare($wp_version, '4.4.0', '>')) {
200
+			//js.api
201
+			$this->addJavascript(
202
+				CoreAssetManager::JS_HANDLE_EE_JS_API,
203
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
204
+				array(
205
+					CoreAssetManager::JS_HANDLE_UNDERSCORE,
206
+					CoreAssetManager::JS_HANDLE_EE_JS_CORE
207
+				)
208
+			);
209
+			$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
210
+			$this->registry->addData(
211
+				'paths',
212
+				array(
213
+					'rest_route' => rest_url('ee/v4.8.36/'),
214
+					'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
215
+					'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()
216
+				)
217
+			);
218
+			/** site formatting values **/
219
+			$this->registry->addData(
220
+				'site_formats',
221
+				array(
222
+					'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
223
+				)
224
+			);
225
+		}
226
+
227
+		$this->addJavascript(
228
+			CoreAssetManager::JS_HANDLE_EE_CORE,
229
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
230
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
231
+		)
232
+		->setInlineDataCallback(
233
+			function () {
234
+				wp_localize_script(
235
+					CoreAssetManager::JS_HANDLE_EE_CORE,
236
+					CoreAssetManager::JS_HANDLE_EE_I18N,
237
+					EE_Registry::$i18n_js_strings
238
+				);
239
+			}
240
+		);
241
+	}
242
+
243
+
244
+	/**
245
+	 * @since 4.9.62.p
246
+	 * @throws DuplicateCollectionIdentifierException
247
+	 * @throws InvalidDataTypeException
248
+	 * @throws InvalidEntityException
249
+	 */
250
+	private function loadCoreCss()
251
+	{
252
+		if ($this->template_config->enable_default_style && ! is_admin()) {
253
+			$this->addStylesheet(
254
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
255
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
256
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
257
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
258
+				array('dashicons')
259
+			);
260
+			//Load custom style sheet if available
261
+			if ($this->template_config->custom_style_sheet !== null) {
262
+				$this->addStylesheet(
263
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
264
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
265
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
266
+				);
267
+			}
268
+		}
269
+	}
270
+
271
+
272
+	/**
273
+	 * jQuery Validate for form validation
274
+	 *
275
+	 * @since 4.9.62.p
276
+	 * @throws DuplicateCollectionIdentifierException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidEntityException
279
+	 */
280
+	private function loadJqueryValidate()
281
+	{
282
+		$this->addJavascript(
283
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
284
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
285
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
286
+		)
287
+		->setVersion('1.15.0');
288
+
289
+		$this->addJavascript(
290
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
291
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
292
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
293
+		)
294
+		->setVersion('1.15.0');
295
+	}
296
+
297
+
298
+	/**
299
+	 * accounting.js for performing client-side calculations
300
+	 *
301
+	 * @since 4.9.62.p
302
+	 * @throws DuplicateCollectionIdentifierException
303
+	 * @throws InvalidDataTypeException
304
+	 * @throws InvalidEntityException
305
+	 */
306
+	private function loadAccountingJs()
307
+	{
308
+		//accounting.js library
309
+		// @link http://josscrowcroft.github.io/accounting.js/
310
+		$this->addJavascript(
311
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
312
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
313
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
314
+		)
315
+		->setVersion('0.3.2');
316
+
317
+		$currency_config = $this->currency_config;
318
+		$this->addJavascript(
319
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
320
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
321
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
322
+		)
323
+		->setInlineDataCallback(
324
+			function () use ($currency_config) {
325
+				 wp_localize_script(
326
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
327
+					 'EE_ACCOUNTING_CFG',
328
+					 array(
329
+						 'currency' => array(
330
+							 'symbol'    => $currency_config->sign,
331
+							 'format'    => array(
332
+								 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
333
+								 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
334
+								 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
335
+							 ),
336
+							 'decimal'   => $currency_config->dec_mrk,
337
+							 'thousand'  => $currency_config->thsnds,
338
+							 'precision' => $currency_config->dec_plc,
339
+						 ),
340
+						 'number'   => array(
341
+							 'precision' => $currency_config->dec_plc,
342
+							 'thousand'  => $currency_config->thsnds,
343
+							 'decimal'   => $currency_config->dec_mrk,
344
+						 ),
345
+					 )
346
+				 );
347
+			}
348
+		)
349
+		->setVersion();
350
+	}
351
+
352
+
353
+	/**
354
+	 * registers assets for cleaning your ears
355
+	 *
356
+	 * @param JavascriptAsset $script
357
+	 */
358
+	public function loadQtipJs(JavascriptAsset $script)
359
+	{
360
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
361
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
362
+		if (
363
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
364
+			&& apply_filters('FHEE_load_qtip', false)
365
+		) {
366
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
367
+		}
368
+	}
369
+
370
+
371
+	/**
372
+	 * assets that are used in the WordPress admin
373
+	 *
374
+	 * @since 4.9.62.p
375
+	 * @throws DuplicateCollectionIdentifierException
376
+	 * @throws InvalidDataTypeException
377
+	 * @throws InvalidEntityException
378
+	 */
379
+	private function registerAdminAssets()
380
+	{
381
+		$this->addJavascript(
382
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
383
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
384
+			array(
385
+				CoreAssetManager::JS_HANDLE_JQUERY,
386
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
387
+			)
388
+		)
389
+		->setRequiresTranslation();
390
+
391
+		$this->addStylesheet(
392
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
393
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
394
+		);
395
+	}
396 396
 }
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 2 patches
Indentation   +981 added lines, -981 removed lines patch added patch discarded remove patch
@@ -17,1043 +17,1043 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * return the timezone set for the WP install
22
-     *
23
-     * @return string valid timezone string for PHP DateTimeZone() class
24
-     * @throws InvalidArgumentException
25
-     * @throws InvalidDataTypeException
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public static function get_timezone()
29
-    {
30
-        return EEH_DTT_Helper::get_valid_timezone_string();
31
-    }
20
+	/**
21
+	 * return the timezone set for the WP install
22
+	 *
23
+	 * @return string valid timezone string for PHP DateTimeZone() class
24
+	 * @throws InvalidArgumentException
25
+	 * @throws InvalidDataTypeException
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public static function get_timezone()
29
+	{
30
+		return EEH_DTT_Helper::get_valid_timezone_string();
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * get_valid_timezone_string
36
-     *    ensures that a valid timezone string is returned
37
-     *
38
-     * @param string $timezone_string
39
-     * @return string
40
-     * @throws InvalidArgumentException
41
-     * @throws InvalidDataTypeException
42
-     * @throws InvalidInterfaceException
43
-     */
44
-    public static function get_valid_timezone_string($timezone_string = '')
45
-    {
46
-        return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
-    }
34
+	/**
35
+	 * get_valid_timezone_string
36
+	 *    ensures that a valid timezone string is returned
37
+	 *
38
+	 * @param string $timezone_string
39
+	 * @return string
40
+	 * @throws InvalidArgumentException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws InvalidInterfaceException
43
+	 */
44
+	public static function get_valid_timezone_string($timezone_string = '')
45
+	{
46
+		return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
-     *
53
-     * @static
54
-     * @param  string $timezone_string Timezone string to check
55
-     * @param bool    $throw_error
56
-     * @return bool
57
-     * @throws InvalidArgumentException
58
-     * @throws InvalidDataTypeException
59
-     * @throws InvalidInterfaceException
60
-     */
61
-    public static function validate_timezone($timezone_string, $throw_error = true)
62
-    {
63
-        return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
-    }
50
+	/**
51
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
+	 *
53
+	 * @static
54
+	 * @param  string $timezone_string Timezone string to check
55
+	 * @param bool    $throw_error
56
+	 * @return bool
57
+	 * @throws InvalidArgumentException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws InvalidInterfaceException
60
+	 */
61
+	public static function validate_timezone($timezone_string, $throw_error = true)
62
+	{
63
+		return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * This returns a string that can represent the provided gmt offset in format that can be passed into
69
-     * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
-     *
71
-     * @param float|string $gmt_offset
72
-     * @return string
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
-    {
79
-        return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
-    }
67
+	/**
68
+	 * This returns a string that can represent the provided gmt offset in format that can be passed into
69
+	 * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
+	 *
71
+	 * @param float|string $gmt_offset
72
+	 * @return string
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
+	{
79
+		return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Gets the site's GMT offset based on either the timezone string
85
-     * (in which case teh gmt offset will vary depending on the location's
86
-     * observance of daylight savings time) or the gmt_offset wp option
87
-     *
88
-     * @return int seconds offset
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     */
93
-    public static function get_site_timezone_gmt_offset()
94
-    {
95
-        return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
-    }
83
+	/**
84
+	 * Gets the site's GMT offset based on either the timezone string
85
+	 * (in which case teh gmt offset will vary depending on the location's
86
+	 * observance of daylight savings time) or the gmt_offset wp option
87
+	 *
88
+	 * @return int seconds offset
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 */
93
+	public static function get_site_timezone_gmt_offset()
94
+	{
95
+		return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * Depending on PHP version,
101
-     * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
103
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
-     *
105
-     * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
-     *                          removed in a future version of EE.
107
-     * @param int $gmt_offset
108
-     * @return int
109
-     * @throws InvalidArgumentException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     */
113
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
-    {
115
-        return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
-    }
99
+	/**
100
+	 * Depending on PHP version,
101
+	 * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
103
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
+	 *
105
+	 * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
+	 *                          removed in a future version of EE.
107
+	 * @param int $gmt_offset
108
+	 * @return int
109
+	 * @throws InvalidArgumentException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 */
113
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
+	{
115
+		return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
+	}
117 117
 
118 118
 
119
-    /**
120
-     * get_timezone_string_from_abbreviations_list
121
-     *
122
-     * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
-     *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
-     * @param int  $gmt_offset
125
-     * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
-     * @return string
127
-     * @throws EE_Error
128
-     * @throws InvalidArgumentException
129
-     * @throws InvalidDataTypeException
130
-     * @throws InvalidInterfaceException
131
-     */
132
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
-    {
134
-        $gmt_offset =  (int) $gmt_offset;
135
-        /** @var array[] $abbreviations */
136
-        $abbreviations = DateTimeZone::listAbbreviations();
137
-        foreach ($abbreviations as $abbreviation) {
138
-            foreach ($abbreviation as $timezone) {
139
-                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
-                    try {
141
-                        $offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
-                        if ($offset !== $gmt_offset) {
143
-                            continue;
144
-                        }
145
-                        return $timezone['timezone_id'];
146
-                    } catch (Exception $e) {
147
-                        continue;
148
-                    }
149
-                }
150
-            }
151
-        }
152
-        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
-        if ($coerce === true) {
154
-            $timezone_string = self::get_timezone_string_from_abbreviations_list(
155
-                self::adjust_invalid_gmt_offsets($gmt_offset),
156
-                false
157
-            );
158
-            if ($timezone_string) {
159
-                return $timezone_string;
160
-            }
161
-        }
162
-        throw new EE_Error(
163
-            sprintf(
164
-                esc_html__(
165
-                    'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
-                    'event_espresso'
167
-                ),
168
-                $gmt_offset / HOUR_IN_SECONDS,
169
-                '<a href="http://www.php.net/manual/en/timezones.php">',
170
-                '</a>'
171
-            )
172
-        );
173
-    }
119
+	/**
120
+	 * get_timezone_string_from_abbreviations_list
121
+	 *
122
+	 * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
+	 *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
+	 * @param int  $gmt_offset
125
+	 * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 * @throws InvalidArgumentException
129
+	 * @throws InvalidDataTypeException
130
+	 * @throws InvalidInterfaceException
131
+	 */
132
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
+	{
134
+		$gmt_offset =  (int) $gmt_offset;
135
+		/** @var array[] $abbreviations */
136
+		$abbreviations = DateTimeZone::listAbbreviations();
137
+		foreach ($abbreviations as $abbreviation) {
138
+			foreach ($abbreviation as $timezone) {
139
+				if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
+					try {
141
+						$offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
+						if ($offset !== $gmt_offset) {
143
+							continue;
144
+						}
145
+						return $timezone['timezone_id'];
146
+					} catch (Exception $e) {
147
+						continue;
148
+					}
149
+				}
150
+			}
151
+		}
152
+		// if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
+		if ($coerce === true) {
154
+			$timezone_string = self::get_timezone_string_from_abbreviations_list(
155
+				self::adjust_invalid_gmt_offsets($gmt_offset),
156
+				false
157
+			);
158
+			if ($timezone_string) {
159
+				return $timezone_string;
160
+			}
161
+		}
162
+		throw new EE_Error(
163
+			sprintf(
164
+				esc_html__(
165
+					'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
+					'event_espresso'
167
+				),
168
+				$gmt_offset / HOUR_IN_SECONDS,
169
+				'<a href="http://www.php.net/manual/en/timezones.php">',
170
+				'</a>'
171
+			)
172
+		);
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * Get Timezone Transitions
178
-     *
179
-     * @param DateTimeZone $date_time_zone
180
-     * @param int|null     $time
181
-     * @param bool         $first_only
182
-     * @return array
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     */
187
-    public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
-    {
189
-        return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
-    }
176
+	/**
177
+	 * Get Timezone Transitions
178
+	 *
179
+	 * @param DateTimeZone $date_time_zone
180
+	 * @param int|null     $time
181
+	 * @param bool         $first_only
182
+	 * @return array
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 */
187
+	public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
+	{
189
+		return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * Get Timezone Offset for given timezone object.
195
-     *
196
-     * @param DateTimeZone $date_time_zone
197
-     * @param null         $time
198
-     * @return mixed
199
-     * @throws InvalidArgumentException
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidInterfaceException
202
-     */
203
-    public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
-    {
205
-        return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
-    }
193
+	/**
194
+	 * Get Timezone Offset for given timezone object.
195
+	 *
196
+	 * @param DateTimeZone $date_time_zone
197
+	 * @param null         $time
198
+	 * @return mixed
199
+	 * @throws InvalidArgumentException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidInterfaceException
202
+	 */
203
+	public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
+	{
205
+		return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * Prints a select input for the given timezone string.
211
-     * @param string $timezone_string
212
-     * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
-     * @throws InvalidArgumentException
214
-     * @throws InvalidDataTypeException
215
-     * @throws InvalidInterfaceException
216
-     */
217
-    public static function timezone_select_input($timezone_string = '')
218
-    {
219
-        self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
-    }
209
+	/**
210
+	 * Prints a select input for the given timezone string.
211
+	 * @param string $timezone_string
212
+	 * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
+	 * @throws InvalidArgumentException
214
+	 * @throws InvalidDataTypeException
215
+	 * @throws InvalidInterfaceException
216
+	 */
217
+	public static function timezone_select_input($timezone_string = '')
218
+	{
219
+		self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
-     * the site is used.
227
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
-     * computed timestamp (i.e. date_i18n() )
229
-     *
230
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
231
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
-     *                                                site will be used.
233
-     * @return int $unix_timestamp with the offset applied for the given timezone.
234
-     * @throws InvalidArgumentException
235
-     * @throws InvalidDataTypeException
236
-     * @throws InvalidInterfaceException
237
-     */
238
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
-    {
240
-        return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
-    }
223
+	/**
224
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
+	 * the site is used.
227
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
+	 * computed timestamp (i.e. date_i18n() )
229
+	 *
230
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
231
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
+	 *                                                site will be used.
233
+	 * @return int $unix_timestamp with the offset applied for the given timezone.
234
+	 * @throws InvalidArgumentException
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws InvalidInterfaceException
237
+	 */
238
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
+	{
240
+		return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     *    _set_date_time_field
246
-     *    modifies EE_Base_Class EE_Datetime_Field objects
247
-     *
248
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
249
-     * @param    DateTime    $DateTime            PHP DateTime object
250
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
-     * @return EE_Base_Class
252
-     * @throws EE_Error
253
-     */
254
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
-    {
256
-        // grab current datetime format
257
-        $current_format = $obj->get_format();
258
-        // set new full timestamp format
259
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
-        // set the new date value using a full timestamp format so that no data is lost
262
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
-        // reset datetime formats
264
-        $obj->set_date_format($current_format[0]);
265
-        $obj->set_time_format($current_format[1]);
266
-        return $obj;
267
-    }
244
+	/**
245
+	 *    _set_date_time_field
246
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
247
+	 *
248
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
249
+	 * @param    DateTime    $DateTime            PHP DateTime object
250
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
+	 * @return EE_Base_Class
252
+	 * @throws EE_Error
253
+	 */
254
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
+	{
256
+		// grab current datetime format
257
+		$current_format = $obj->get_format();
258
+		// set new full timestamp format
259
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
+		// set the new date value using a full timestamp format so that no data is lost
262
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
+		// reset datetime formats
264
+		$obj->set_date_format($current_format[0]);
265
+		$obj->set_time_format($current_format[1]);
266
+		return $obj;
267
+	}
268 268
 
269 269
 
270
-    /**
271
-     *    date_time_add
272
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
-     *
275
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
276
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
-     *                                            minutes, seconds) defaults to years
279
-     * @param  integer       $value               what you want to increment the time by
280
-     * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
-     *                                            (chaining)
282
-     * @throws EE_Error
283
-     * @throws Exception
284
-     */
285
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
-    {
287
-        // get the raw UTC date.
288
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
289
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
-    }
270
+	/**
271
+	 *    date_time_add
272
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
+	 *
275
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
276
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
+	 *                                            minutes, seconds) defaults to years
279
+	 * @param  integer       $value               what you want to increment the time by
280
+	 * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
+	 *                                            (chaining)
282
+	 * @throws EE_Error
283
+	 * @throws Exception
284
+	 */
285
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
+	{
287
+		// get the raw UTC date.
288
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
289
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
+	}
292 292
 
293 293
 
294
-    /**
295
-     *    date_time_subtract
296
-     *    same as date_time_add except subtracting value instead of adding.
297
-     *
298
-     * @param EE_Base_Class $obj
299
-     * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
-     * @param string        $period
301
-     * @param int           $value
302
-     * @return EE_Base_Class
303
-     * @throws EE_Error
304
-     * @throws Exception
305
-     */
306
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
-    {
308
-        // get the raw UTC date
309
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
310
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
-    }
294
+	/**
295
+	 *    date_time_subtract
296
+	 *    same as date_time_add except subtracting value instead of adding.
297
+	 *
298
+	 * @param EE_Base_Class $obj
299
+	 * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
+	 * @param string        $period
301
+	 * @param int           $value
302
+	 * @return EE_Base_Class
303
+	 * @throws EE_Error
304
+	 * @throws Exception
305
+	 */
306
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
+	{
308
+		// get the raw UTC date
309
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
310
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
+	}
313 313
 
314 314
 
315
-    /**
316
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
-     *
318
-     * @param  DateTime   $DateTime DateTime object
319
-     * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
-     *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
-     * @param  int|string $value    What you want to increment the date by
322
-     * @param  string     $operand  What operand you wish to use for the calculation
323
-     * @return DateTime return whatever type came in.
324
-     * @throws Exception
325
-     * @throws EE_Error
326
-     */
327
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
-    {
329
-        if (! $DateTime instanceof DateTime) {
330
-            throw new EE_Error(
331
-                sprintf(
332
-                    esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
-                    print_r($DateTime, true)
334
-                )
335
-            );
336
-        }
337
-        switch ($period) {
338
-            case 'years':
339
-                $value = 'P' . $value . 'Y';
340
-                break;
341
-            case 'months':
342
-                $value = 'P' . $value . 'M';
343
-                break;
344
-            case 'weeks':
345
-                $value = 'P' . $value . 'W';
346
-                break;
347
-            case 'days':
348
-                $value = 'P' . $value . 'D';
349
-                break;
350
-            case 'hours':
351
-                $value = 'PT' . $value . 'H';
352
-                break;
353
-            case 'minutes':
354
-                $value = 'PT' . $value . 'M';
355
-                break;
356
-            case 'seconds':
357
-                $value = 'PT' . $value . 'S';
358
-                break;
359
-        }
360
-        switch ($operand) {
361
-            case '+':
362
-                $DateTime->add(new DateInterval($value));
363
-                break;
364
-            case '-':
365
-                $DateTime->sub(new DateInterval($value));
366
-                break;
367
-        }
368
-        return $DateTime;
369
-    }
315
+	/**
316
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
+	 *
318
+	 * @param  DateTime   $DateTime DateTime object
319
+	 * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
+	 *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
+	 * @param  int|string $value    What you want to increment the date by
322
+	 * @param  string     $operand  What operand you wish to use for the calculation
323
+	 * @return DateTime return whatever type came in.
324
+	 * @throws Exception
325
+	 * @throws EE_Error
326
+	 */
327
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
+	{
329
+		if (! $DateTime instanceof DateTime) {
330
+			throw new EE_Error(
331
+				sprintf(
332
+					esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
+					print_r($DateTime, true)
334
+				)
335
+			);
336
+		}
337
+		switch ($period) {
338
+			case 'years':
339
+				$value = 'P' . $value . 'Y';
340
+				break;
341
+			case 'months':
342
+				$value = 'P' . $value . 'M';
343
+				break;
344
+			case 'weeks':
345
+				$value = 'P' . $value . 'W';
346
+				break;
347
+			case 'days':
348
+				$value = 'P' . $value . 'D';
349
+				break;
350
+			case 'hours':
351
+				$value = 'PT' . $value . 'H';
352
+				break;
353
+			case 'minutes':
354
+				$value = 'PT' . $value . 'M';
355
+				break;
356
+			case 'seconds':
357
+				$value = 'PT' . $value . 'S';
358
+				break;
359
+		}
360
+		switch ($operand) {
361
+			case '+':
362
+				$DateTime->add(new DateInterval($value));
363
+				break;
364
+			case '-':
365
+				$DateTime->sub(new DateInterval($value));
366
+				break;
367
+		}
368
+		return $DateTime;
369
+	}
370 370
 
371 371
 
372
-    /**
373
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
-     *
375
-     * @param  int     $timestamp Unix timestamp
376
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
-     * @param  integer $value     What you want to increment the date by
379
-     * @param  string  $operand   What operand you wish to use for the calculation
380
-     * @return int
381
-     * @throws EE_Error
382
-     */
383
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
-    {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
-            throw new EE_Error(
387
-                sprintf(
388
-                    esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
-                    print_r($timestamp, true)
390
-                )
391
-            );
392
-        }
393
-        switch ($period) {
394
-            case 'years':
395
-                $value = YEAR_IN_SECONDS * $value;
396
-                break;
397
-            case 'months':
398
-                $value = YEAR_IN_SECONDS / 12 * $value;
399
-                break;
400
-            case 'weeks':
401
-                $value = WEEK_IN_SECONDS * $value;
402
-                break;
403
-            case 'days':
404
-                $value = DAY_IN_SECONDS * $value;
405
-                break;
406
-            case 'hours':
407
-                $value = HOUR_IN_SECONDS * $value;
408
-                break;
409
-            case 'minutes':
410
-                $value = MINUTE_IN_SECONDS * $value;
411
-                break;
412
-        }
413
-        switch ($operand) {
414
-            case '+':
415
-                $timestamp += $value;
416
-                break;
417
-            case '-':
418
-                $timestamp -= $value;
419
-                break;
420
-        }
421
-        return $timestamp;
422
-    }
372
+	/**
373
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
+	 *
375
+	 * @param  int     $timestamp Unix timestamp
376
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
+	 * @param  integer $value     What you want to increment the date by
379
+	 * @param  string  $operand   What operand you wish to use for the calculation
380
+	 * @return int
381
+	 * @throws EE_Error
382
+	 */
383
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
+	{
385
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
+			throw new EE_Error(
387
+				sprintf(
388
+					esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
+					print_r($timestamp, true)
390
+				)
391
+			);
392
+		}
393
+		switch ($period) {
394
+			case 'years':
395
+				$value = YEAR_IN_SECONDS * $value;
396
+				break;
397
+			case 'months':
398
+				$value = YEAR_IN_SECONDS / 12 * $value;
399
+				break;
400
+			case 'weeks':
401
+				$value = WEEK_IN_SECONDS * $value;
402
+				break;
403
+			case 'days':
404
+				$value = DAY_IN_SECONDS * $value;
405
+				break;
406
+			case 'hours':
407
+				$value = HOUR_IN_SECONDS * $value;
408
+				break;
409
+			case 'minutes':
410
+				$value = MINUTE_IN_SECONDS * $value;
411
+				break;
412
+		}
413
+		switch ($operand) {
414
+			case '+':
415
+				$timestamp += $value;
416
+				break;
417
+			case '-':
418
+				$timestamp -= $value;
419
+				break;
420
+		}
421
+		return $timestamp;
422
+	}
423 423
 
424 424
 
425
-    /**
426
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
-     * parameters and returns the new timestamp or DateTime.
428
-     *
429
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
-     * @param  string         $period                a value to indicate what interval is being used in the
431
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
-     *                                               'minutes', 'seconds'. Defaults to years.
433
-     * @param  integer        $value                 What you want to increment the date by
434
-     * @param  string         $operand               What operand you wish to use for the calculation
435
-     * @return mixed string|DateTime          return whatever type came in.
436
-     * @throws Exception
437
-     * @throws EE_Error
438
-     */
439
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
-    {
441
-        if ($DateTime_or_timestamp instanceof DateTime) {
442
-            return EEH_DTT_Helper::_modify_datetime_object(
443
-                $DateTime_or_timestamp,
444
-                $period,
445
-                $value,
446
-                $operand
447
-            );
448
-        }
449
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
-            return EEH_DTT_Helper::_modify_timestamp(
451
-                $DateTime_or_timestamp,
452
-                $period,
453
-                $value,
454
-                $operand
455
-            );
456
-        }
457
-        // error
458
-        return $DateTime_or_timestamp;
459
-    }
425
+	/**
426
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
+	 * parameters and returns the new timestamp or DateTime.
428
+	 *
429
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
+	 * @param  string         $period                a value to indicate what interval is being used in the
431
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
+	 *                                               'minutes', 'seconds'. Defaults to years.
433
+	 * @param  integer        $value                 What you want to increment the date by
434
+	 * @param  string         $operand               What operand you wish to use for the calculation
435
+	 * @return mixed string|DateTime          return whatever type came in.
436
+	 * @throws Exception
437
+	 * @throws EE_Error
438
+	 */
439
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
+	{
441
+		if ($DateTime_or_timestamp instanceof DateTime) {
442
+			return EEH_DTT_Helper::_modify_datetime_object(
443
+				$DateTime_or_timestamp,
444
+				$period,
445
+				$value,
446
+				$operand
447
+			);
448
+		}
449
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
+			return EEH_DTT_Helper::_modify_timestamp(
451
+				$DateTime_or_timestamp,
452
+				$period,
453
+				$value,
454
+				$operand
455
+			);
456
+		}
457
+		// error
458
+		return $DateTime_or_timestamp;
459
+	}
460 460
 
461 461
 
462
-    /**
463
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
464
-     * and spit out the js and moment.js equivalent formats.
465
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
-     * time picker.
468
-     *
469
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
-     * @param string $date_format_string
471
-     * @param string $time_format_string
472
-     * @return array
473
-     *              array(
474
-     *              'js' => array (
475
-     *              'date' => //date format
476
-     *              'time' => //time format
477
-     *              ),
478
-     *              'moment' => //date and time format.
479
-     *              )
480
-     */
481
-    public static function convert_php_to_js_and_moment_date_formats(
482
-        $date_format_string = null,
483
-        $time_format_string = null
484
-    ) {
485
-        if ($date_format_string === null) {
486
-            $date_format_string = (string) get_option('date_format');
487
-        }
488
-        if ($time_format_string === null) {
489
-            $time_format_string = (string) get_option('time_format');
490
-        }
491
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
492
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
493
-        return array(
494
-            'js'     => array(
495
-                'date' => $date_format['js'],
496
-                'time' => $time_format['js'],
497
-            ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
-            'moment_split' => array(
500
-                'date' => $date_format['moment'],
501
-                'time' => $time_format['moment']
502
-            )
503
-        );
504
-    }
462
+	/**
463
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
464
+	 * and spit out the js and moment.js equivalent formats.
465
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
+	 * time picker.
468
+	 *
469
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
+	 * @param string $date_format_string
471
+	 * @param string $time_format_string
472
+	 * @return array
473
+	 *              array(
474
+	 *              'js' => array (
475
+	 *              'date' => //date format
476
+	 *              'time' => //time format
477
+	 *              ),
478
+	 *              'moment' => //date and time format.
479
+	 *              )
480
+	 */
481
+	public static function convert_php_to_js_and_moment_date_formats(
482
+		$date_format_string = null,
483
+		$time_format_string = null
484
+	) {
485
+		if ($date_format_string === null) {
486
+			$date_format_string = (string) get_option('date_format');
487
+		}
488
+		if ($time_format_string === null) {
489
+			$time_format_string = (string) get_option('time_format');
490
+		}
491
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
492
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
493
+		return array(
494
+			'js'     => array(
495
+				'date' => $date_format['js'],
496
+				'time' => $time_format['js'],
497
+			),
498
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
+			'moment_split' => array(
500
+				'date' => $date_format['moment'],
501
+				'time' => $time_format['moment']
502
+			)
503
+		);
504
+	}
505 505
 
506 506
 
507
-    /**
508
-     * This converts incoming format string into js and moment variations.
509
-     *
510
-     * @param string $format_string incoming php format string
511
-     * @return array js and moment formats.
512
-     */
513
-    protected static function _php_to_js_moment_converter($format_string)
514
-    {
515
-        /**
516
-         * This is a map of symbols for formats.
517
-         * The index is the php symbol, the equivalent values are in the array.
518
-         *
519
-         * @var array
520
-         */
521
-        $symbols_map          = array(
522
-            // Day
523
-            // 01
524
-            'd' => array(
525
-                'js'     => 'dd',
526
-                'moment' => 'DD',
527
-            ),
528
-            // Mon
529
-            'D' => array(
530
-                'js'     => 'D',
531
-                'moment' => 'ddd',
532
-            ),
533
-            // 1,2,...31
534
-            'j' => array(
535
-                'js'     => 'd',
536
-                'moment' => 'D',
537
-            ),
538
-            // Monday
539
-            'l' => array(
540
-                'js'     => 'DD',
541
-                'moment' => 'dddd',
542
-            ),
543
-            // ISO numeric representation of the day of the week (1-6)
544
-            'N' => array(
545
-                'js'     => '',
546
-                'moment' => 'E',
547
-            ),
548
-            // st,nd.rd
549
-            'S' => array(
550
-                'js'     => '',
551
-                'moment' => 'o',
552
-            ),
553
-            // numeric representation of day of week (0-6)
554
-            'w' => array(
555
-                'js'     => '',
556
-                'moment' => 'd',
557
-            ),
558
-            // day of year starting from 0 (0-365)
559
-            'z' => array(
560
-                'js'     => 'o',
561
-                'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
-            ),
563
-            // Week
564
-            // ISO-8601 week number of year (weeks starting on monday)
565
-            'W' => array(
566
-                'js'     => '',
567
-                'moment' => 'w',
568
-            ),
569
-            // Month
570
-            // January...December
571
-            'F' => array(
572
-                'js'     => 'MM',
573
-                'moment' => 'MMMM',
574
-            ),
575
-            // 01...12
576
-            'm' => array(
577
-                'js'     => 'mm',
578
-                'moment' => 'MM',
579
-            ),
580
-            // Jan...Dec
581
-            'M' => array(
582
-                'js'     => 'M',
583
-                'moment' => 'MMM',
584
-            ),
585
-            // 1-12
586
-            'n' => array(
587
-                'js'     => 'm',
588
-                'moment' => 'M',
589
-            ),
590
-            // number of days in given month
591
-            't' => array(
592
-                'js'     => '',
593
-                'moment' => '',
594
-            ),
595
-            // Year
596
-            // whether leap year or not 1/0
597
-            'L' => array(
598
-                'js'     => '',
599
-                'moment' => '',
600
-            ),
601
-            // ISO-8601 year number
602
-            'o' => array(
603
-                'js'     => '',
604
-                'moment' => 'GGGG',
605
-            ),
606
-            // 1999...2003
607
-            'Y' => array(
608
-                'js'     => 'yy',
609
-                'moment' => 'YYYY',
610
-            ),
611
-            // 99...03
612
-            'y' => array(
613
-                'js'     => 'y',
614
-                'moment' => 'YY',
615
-            ),
616
-            // Time
617
-            // am/pm
618
-            'a' => array(
619
-                'js'     => 'tt',
620
-                'moment' => 'a',
621
-            ),
622
-            // AM/PM
623
-            'A' => array(
624
-                'js'     => 'TT',
625
-                'moment' => 'A',
626
-            ),
627
-            // Swatch Internet Time?!?
628
-            'B' => array(
629
-                'js'     => '',
630
-                'moment' => '',
631
-            ),
632
-            // 1...12
633
-            'g' => array(
634
-                'js'     => 'h',
635
-                'moment' => 'h',
636
-            ),
637
-            // 0...23
638
-            'G' => array(
639
-                'js'     => 'H',
640
-                'moment' => 'H',
641
-            ),
642
-            // 01...12
643
-            'h' => array(
644
-                'js'     => 'hh',
645
-                'moment' => 'hh',
646
-            ),
647
-            // 00...23
648
-            'H' => array(
649
-                'js'     => 'HH',
650
-                'moment' => 'HH',
651
-            ),
652
-            // 00..59
653
-            'i' => array(
654
-                'js'     => 'mm',
655
-                'moment' => 'mm',
656
-            ),
657
-            // seconds... 00...59
658
-            's' => array(
659
-                'js'     => 'ss',
660
-                'moment' => 'ss',
661
-            ),
662
-            // microseconds
663
-            'u' => array(
664
-                'js'     => '',
665
-                'moment' => '',
666
-            ),
667
-        );
668
-        $jquery_ui_format     = '';
669
-        $moment_format        = '';
670
-        $escaping             = false;
671
-        $format_string_length = strlen($format_string);
672
-        for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
674
-            if ($char === '\\') { // PHP date format escaping character
675
-                $i++;
676
-                if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
679
-                } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
682
-                }
683
-                $escaping = true;
684
-            } else {
685
-                if ($escaping) {
686
-                    $jquery_ui_format .= "'";
687
-                    $moment_format    .= "'";
688
-                    $escaping         = false;
689
-                }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
693
-                } else {
694
-                    $jquery_ui_format .= $char;
695
-                    $moment_format    .= $char;
696
-                }
697
-            }
698
-        }
699
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
-    }
507
+	/**
508
+	 * This converts incoming format string into js and moment variations.
509
+	 *
510
+	 * @param string $format_string incoming php format string
511
+	 * @return array js and moment formats.
512
+	 */
513
+	protected static function _php_to_js_moment_converter($format_string)
514
+	{
515
+		/**
516
+		 * This is a map of symbols for formats.
517
+		 * The index is the php symbol, the equivalent values are in the array.
518
+		 *
519
+		 * @var array
520
+		 */
521
+		$symbols_map          = array(
522
+			// Day
523
+			// 01
524
+			'd' => array(
525
+				'js'     => 'dd',
526
+				'moment' => 'DD',
527
+			),
528
+			// Mon
529
+			'D' => array(
530
+				'js'     => 'D',
531
+				'moment' => 'ddd',
532
+			),
533
+			// 1,2,...31
534
+			'j' => array(
535
+				'js'     => 'd',
536
+				'moment' => 'D',
537
+			),
538
+			// Monday
539
+			'l' => array(
540
+				'js'     => 'DD',
541
+				'moment' => 'dddd',
542
+			),
543
+			// ISO numeric representation of the day of the week (1-6)
544
+			'N' => array(
545
+				'js'     => '',
546
+				'moment' => 'E',
547
+			),
548
+			// st,nd.rd
549
+			'S' => array(
550
+				'js'     => '',
551
+				'moment' => 'o',
552
+			),
553
+			// numeric representation of day of week (0-6)
554
+			'w' => array(
555
+				'js'     => '',
556
+				'moment' => 'd',
557
+			),
558
+			// day of year starting from 0 (0-365)
559
+			'z' => array(
560
+				'js'     => 'o',
561
+				'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
+			),
563
+			// Week
564
+			// ISO-8601 week number of year (weeks starting on monday)
565
+			'W' => array(
566
+				'js'     => '',
567
+				'moment' => 'w',
568
+			),
569
+			// Month
570
+			// January...December
571
+			'F' => array(
572
+				'js'     => 'MM',
573
+				'moment' => 'MMMM',
574
+			),
575
+			// 01...12
576
+			'm' => array(
577
+				'js'     => 'mm',
578
+				'moment' => 'MM',
579
+			),
580
+			// Jan...Dec
581
+			'M' => array(
582
+				'js'     => 'M',
583
+				'moment' => 'MMM',
584
+			),
585
+			// 1-12
586
+			'n' => array(
587
+				'js'     => 'm',
588
+				'moment' => 'M',
589
+			),
590
+			// number of days in given month
591
+			't' => array(
592
+				'js'     => '',
593
+				'moment' => '',
594
+			),
595
+			// Year
596
+			// whether leap year or not 1/0
597
+			'L' => array(
598
+				'js'     => '',
599
+				'moment' => '',
600
+			),
601
+			// ISO-8601 year number
602
+			'o' => array(
603
+				'js'     => '',
604
+				'moment' => 'GGGG',
605
+			),
606
+			// 1999...2003
607
+			'Y' => array(
608
+				'js'     => 'yy',
609
+				'moment' => 'YYYY',
610
+			),
611
+			// 99...03
612
+			'y' => array(
613
+				'js'     => 'y',
614
+				'moment' => 'YY',
615
+			),
616
+			// Time
617
+			// am/pm
618
+			'a' => array(
619
+				'js'     => 'tt',
620
+				'moment' => 'a',
621
+			),
622
+			// AM/PM
623
+			'A' => array(
624
+				'js'     => 'TT',
625
+				'moment' => 'A',
626
+			),
627
+			// Swatch Internet Time?!?
628
+			'B' => array(
629
+				'js'     => '',
630
+				'moment' => '',
631
+			),
632
+			// 1...12
633
+			'g' => array(
634
+				'js'     => 'h',
635
+				'moment' => 'h',
636
+			),
637
+			// 0...23
638
+			'G' => array(
639
+				'js'     => 'H',
640
+				'moment' => 'H',
641
+			),
642
+			// 01...12
643
+			'h' => array(
644
+				'js'     => 'hh',
645
+				'moment' => 'hh',
646
+			),
647
+			// 00...23
648
+			'H' => array(
649
+				'js'     => 'HH',
650
+				'moment' => 'HH',
651
+			),
652
+			// 00..59
653
+			'i' => array(
654
+				'js'     => 'mm',
655
+				'moment' => 'mm',
656
+			),
657
+			// seconds... 00...59
658
+			's' => array(
659
+				'js'     => 'ss',
660
+				'moment' => 'ss',
661
+			),
662
+			// microseconds
663
+			'u' => array(
664
+				'js'     => '',
665
+				'moment' => '',
666
+			),
667
+		);
668
+		$jquery_ui_format     = '';
669
+		$moment_format        = '';
670
+		$escaping             = false;
671
+		$format_string_length = strlen($format_string);
672
+		for ($i = 0; $i < $format_string_length; $i++) {
673
+			$char = $format_string[ $i ];
674
+			if ($char === '\\') { // PHP date format escaping character
675
+				$i++;
676
+				if ($escaping) {
677
+					$jquery_ui_format .= $format_string[ $i ];
678
+					$moment_format    .= $format_string[ $i ];
679
+				} else {
680
+					$jquery_ui_format .= '\'' . $format_string[ $i ];
681
+					$moment_format    .= $format_string[ $i ];
682
+				}
683
+				$escaping = true;
684
+			} else {
685
+				if ($escaping) {
686
+					$jquery_ui_format .= "'";
687
+					$moment_format    .= "'";
688
+					$escaping         = false;
689
+				}
690
+				if (isset($symbols_map[ $char ])) {
691
+					$jquery_ui_format .= $symbols_map[ $char ]['js'];
692
+					$moment_format    .= $symbols_map[ $char ]['moment'];
693
+				} else {
694
+					$jquery_ui_format .= $char;
695
+					$moment_format    .= $char;
696
+				}
697
+			}
698
+		}
699
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
+	}
701 701
 
702 702
 
703
-    /**
704
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
-     *
706
-     * @param string $format_string   Incoming format string for php date().
707
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
-     *                                errors is returned.  So for client code calling, check for is_array() to
709
-     *                                indicate failed validations.
710
-     */
711
-    public static function validate_format_string($format_string)
712
-    {
713
-        $error_msg = array();
714
-        // time format checks
715
-        switch (true) {
716
-            case strpos($format_string, 'h') !== false:
717
-            case strpos($format_string, 'g') !== false:
718
-                /**
719
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
-                 */
723
-                if (stripos($format_string, 'A') === false) {
724
-                    $error_msg[] = esc_html__(
725
-                        'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
-                        'event_espresso'
727
-                    );
728
-                }
729
-                break;
730
-        }
731
-        return empty($error_msg) ? true : $error_msg;
732
-    }
703
+	/**
704
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
+	 *
706
+	 * @param string $format_string   Incoming format string for php date().
707
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
+	 *                                errors is returned.  So for client code calling, check for is_array() to
709
+	 *                                indicate failed validations.
710
+	 */
711
+	public static function validate_format_string($format_string)
712
+	{
713
+		$error_msg = array();
714
+		// time format checks
715
+		switch (true) {
716
+			case strpos($format_string, 'h') !== false:
717
+			case strpos($format_string, 'g') !== false:
718
+				/**
719
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
+				 */
723
+				if (stripos($format_string, 'A') === false) {
724
+					$error_msg[] = esc_html__(
725
+						'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
+						'event_espresso'
727
+					);
728
+				}
729
+				break;
730
+		}
731
+		return empty($error_msg) ? true : $error_msg;
732
+	}
733 733
 
734 734
 
735
-    /**
736
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
-     *     very next day then this method will return true.
738
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
-     *
742
-     * @param mixed $date_1
743
-     * @param mixed $date_2
744
-     * @return bool
745
-     */
746
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
-    {
735
+	/**
736
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
+	 *     very next day then this method will return true.
738
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
+	 *
742
+	 * @param mixed $date_1
743
+	 * @param mixed $date_2
744
+	 * @return bool
745
+	 */
746
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
+	{
748 748
 
749
-        if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750
-            || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751
-                || $date_2->format(
752
-                    EE_Datetime_Field::mysql_time_format
753
-                ) !== '00:00:00')
754
-        ) {
755
-            return false;
756
-        }
757
-        return $date_2->format('U') - $date_1->format('U') === 86400;
758
-    }
749
+		if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750
+			|| ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751
+				|| $date_2->format(
752
+					EE_Datetime_Field::mysql_time_format
753
+				) !== '00:00:00')
754
+		) {
755
+			return false;
756
+		}
757
+		return $date_2->format('U') - $date_1->format('U') === 86400;
758
+	}
759 759
 
760 760
 
761
-    /**
762
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
763
-     * Functions.
764
-     *
765
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
766
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
767
-     * @return string
768
-     */
769
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
770
-    {
771
-        try {
772
-            /** need to account for timezone offset on the selects */
773
-            $DateTimeZone = new DateTimeZone($timezone_string);
774
-        } catch (Exception $e) {
775
-            $DateTimeZone = null;
776
-        }
777
-        /**
778
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
779
-         * Hence we do the calc for DateTimeZone::getOffset.
780
-         */
781
-        $offset         = $DateTimeZone instanceof DateTimeZone
782
-            ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783
-            : (float) get_option('gmt_offset');
784
-        $query_interval = $offset < 0
785
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
787
-        return $query_interval;
788
-    }
761
+	/**
762
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
763
+	 * Functions.
764
+	 *
765
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
766
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
767
+	 * @return string
768
+	 */
769
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
770
+	{
771
+		try {
772
+			/** need to account for timezone offset on the selects */
773
+			$DateTimeZone = new DateTimeZone($timezone_string);
774
+		} catch (Exception $e) {
775
+			$DateTimeZone = null;
776
+		}
777
+		/**
778
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
779
+		 * Hence we do the calc for DateTimeZone::getOffset.
780
+		 */
781
+		$offset         = $DateTimeZone instanceof DateTimeZone
782
+			? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783
+			: (float) get_option('gmt_offset');
784
+		$query_interval = $offset < 0
785
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
787
+		return $query_interval;
788
+	}
789 789
 
790 790
 
791
-    /**
792
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
793
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
794
-     * and 'gmt_offset' WordPress options directly; or use the filter
795
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
796
-     * (although note that we remove any HTML that may be added)
797
-     *
798
-     * @return string
799
-     */
800
-    public static function get_timezone_string_for_display()
801
-    {
802
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
-        if (! empty($pretty_timezone)) {
804
-            return esc_html($pretty_timezone);
805
-        }
806
-        $timezone_string = get_option('timezone_string');
807
-        if ($timezone_string) {
808
-            static $mo_loaded = false;
809
-            // Load translations for continents and cities just like wp_timezone_choice does
810
-            if (! $mo_loaded) {
811
-                $locale = get_locale();
812
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
813
-                load_textdomain('continents-cities', $mofile);
814
-                $mo_loaded = true;
815
-            }
816
-            // well that was easy.
817
-            $parts = explode('/', $timezone_string);
818
-            // remove the continent
819
-            unset($parts[0]);
820
-            $t_parts = array();
821
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
822
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
823
-            // disabled because this code is copied from WordPress and is a WordPress domain
824
-            foreach ($parts as $part) {
825
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
826
-            }
827
-            return implode(' - ', $t_parts);
828
-            // phpcs:enable
829
-        }
830
-        // they haven't set the timezone string, so let's return a string like "UTC+1"
831
-        $gmt_offset = get_option('gmt_offset');
832
-        $prefix     = (int) $gmt_offset >= 0 ? '+' : '';
833
-        $parts      = explode('.', (string) $gmt_offset);
834
-        if (count($parts) === 1) {
835
-            $parts[1] = '00';
836
-        } else {
837
-            // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838
-            // to minutes, eg 30 or 15, respectively
839
-            $hour_fraction = (float) ('0.' . $parts[1]);
840
-            $parts[1]      = (string) $hour_fraction * 60;
841
-        }
842
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
843
-    }
791
+	/**
792
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
793
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
794
+	 * and 'gmt_offset' WordPress options directly; or use the filter
795
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
796
+	 * (although note that we remove any HTML that may be added)
797
+	 *
798
+	 * @return string
799
+	 */
800
+	public static function get_timezone_string_for_display()
801
+	{
802
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
+		if (! empty($pretty_timezone)) {
804
+			return esc_html($pretty_timezone);
805
+		}
806
+		$timezone_string = get_option('timezone_string');
807
+		if ($timezone_string) {
808
+			static $mo_loaded = false;
809
+			// Load translations for continents and cities just like wp_timezone_choice does
810
+			if (! $mo_loaded) {
811
+				$locale = get_locale();
812
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
813
+				load_textdomain('continents-cities', $mofile);
814
+				$mo_loaded = true;
815
+			}
816
+			// well that was easy.
817
+			$parts = explode('/', $timezone_string);
818
+			// remove the continent
819
+			unset($parts[0]);
820
+			$t_parts = array();
821
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
822
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
823
+			// disabled because this code is copied from WordPress and is a WordPress domain
824
+			foreach ($parts as $part) {
825
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
826
+			}
827
+			return implode(' - ', $t_parts);
828
+			// phpcs:enable
829
+		}
830
+		// they haven't set the timezone string, so let's return a string like "UTC+1"
831
+		$gmt_offset = get_option('gmt_offset');
832
+		$prefix     = (int) $gmt_offset >= 0 ? '+' : '';
833
+		$parts      = explode('.', (string) $gmt_offset);
834
+		if (count($parts) === 1) {
835
+			$parts[1] = '00';
836
+		} else {
837
+			// convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838
+			// to minutes, eg 30 or 15, respectively
839
+			$hour_fraction = (float) ('0.' . $parts[1]);
840
+			$parts[1]      = (string) $hour_fraction * 60;
841
+		}
842
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
843
+	}
844 844
 
845 845
 
846 846
 
847
-    /**
848
-     * So PHP does this awesome thing where if you are trying to get a timestamp
849
-     * for a month using a string like "February" or "February 2017",
850
-     * and you don't specify a day as part of your string,
851
-     * then PHP will use whatever the current day of the month is.
852
-     * IF the current day of the month happens to be the 30th or 31st,
853
-     * then PHP gets really confused by a date like February 30,
854
-     * so instead of saying
855
-     *      "Hey February only has 28 days (this year)...
856
-     *      ...you must have meant the last day of the month!"
857
-     * PHP does the next most logical thing, and bumps the date up to March 2nd,
858
-     * because someone requesting February 30th obviously meant March 1st!
859
-     * The way around this is to always set the day to the first,
860
-     * so that the month will stay on the month you wanted.
861
-     * this method will add that "1" into your date regardless of the format.
862
-     *
863
-     * @param string $month
864
-     * @return string
865
-     */
866
-    public static function first_of_month_timestamp($month = '')
867
-    {
868
-        $month = (string) $month;
869
-        $year  = '';
870
-        // check if the incoming string has a year in it or not
871
-        if (preg_match('/\b\d{4}\b/', $month, $matches)) {
872
-            $year = $matches[0];
873
-            // ten remove that from the month string as well as any spaces
874
-            $month = trim(str_replace($year, '', $month));
875
-            // add a space before the year
876
-            $year = " {$year}";
877
-        }
878
-        // return timestamp for something like "February 1 2017"
879
-        return strtotime("{$month} 1{$year}");
880
-    }
847
+	/**
848
+	 * So PHP does this awesome thing where if you are trying to get a timestamp
849
+	 * for a month using a string like "February" or "February 2017",
850
+	 * and you don't specify a day as part of your string,
851
+	 * then PHP will use whatever the current day of the month is.
852
+	 * IF the current day of the month happens to be the 30th or 31st,
853
+	 * then PHP gets really confused by a date like February 30,
854
+	 * so instead of saying
855
+	 *      "Hey February only has 28 days (this year)...
856
+	 *      ...you must have meant the last day of the month!"
857
+	 * PHP does the next most logical thing, and bumps the date up to March 2nd,
858
+	 * because someone requesting February 30th obviously meant March 1st!
859
+	 * The way around this is to always set the day to the first,
860
+	 * so that the month will stay on the month you wanted.
861
+	 * this method will add that "1" into your date regardless of the format.
862
+	 *
863
+	 * @param string $month
864
+	 * @return string
865
+	 */
866
+	public static function first_of_month_timestamp($month = '')
867
+	{
868
+		$month = (string) $month;
869
+		$year  = '';
870
+		// check if the incoming string has a year in it or not
871
+		if (preg_match('/\b\d{4}\b/', $month, $matches)) {
872
+			$year = $matches[0];
873
+			// ten remove that from the month string as well as any spaces
874
+			$month = trim(str_replace($year, '', $month));
875
+			// add a space before the year
876
+			$year = " {$year}";
877
+		}
878
+		// return timestamp for something like "February 1 2017"
879
+		return strtotime("{$month} 1{$year}");
880
+	}
881 881
 
882 882
 
883
-    /**
884
-     * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
885
-     * for this sites timezone, but the timestamp could be some other time GMT.
886
-     */
887
-    public static function tomorrow()
888
-    {
889
-        // The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
890
-        // before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
891
-        // not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
892
-        // final timestamp is equivalent to midnight in this timezone as represented in GMT.
893
-        return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
894
-    }
883
+	/**
884
+	 * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
885
+	 * for this sites timezone, but the timestamp could be some other time GMT.
886
+	 */
887
+	public static function tomorrow()
888
+	{
889
+		// The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
890
+		// before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
891
+		// not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
892
+		// final timestamp is equivalent to midnight in this timezone as represented in GMT.
893
+		return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
894
+	}
895 895
 
896 896
 
897
-    /**
898
-     * **
899
-     * Gives a nicely-formatted list of timezone strings.
900
-     * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
901
-     *
902
-     * @since     4.9.40.rc.008
903
-     * @staticvar bool $mo_loaded
904
-     * @staticvar string $locale_loaded
905
-     * @param string $selected_zone Selected timezone.
906
-     * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
907
-     * @return string
908
-     */
909
-    public static function wp_timezone_choice($selected_zone, $locale = null)
910
-    {
911
-        static $mo_loaded = false, $locale_loaded = null;
912
-        $continents = array(
913
-            'Africa',
914
-            'America',
915
-            'Antarctica',
916
-            'Arctic',
917
-            'Asia',
918
-            'Atlantic',
919
-            'Australia',
920
-            'Europe',
921
-            'Indian',
922
-            'Pacific',
923
-        );
924
-        // Load translations for continents and cities.
925
-        if (! $mo_loaded || $locale !== $locale_loaded) {
926
-            $locale_loaded = $locale ? $locale : get_locale();
927
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
928
-            unload_textdomain('continents-cities');
929
-            load_textdomain('continents-cities', $mofile);
930
-            $mo_loaded = true;
931
-        }
932
-        $zone_data = array();
933
-        foreach (timezone_identifiers_list() as $zone) {
934
-            $zone = explode('/', $zone);
935
-            if (! in_array($zone[0], $continents, true)) {
936
-                continue;
937
-            }
938
-            // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
-            $exists      = array(
940
-                0 => isset($zone[0]) && $zone[0],
941
-                1 => isset($zone[1]) && $zone[1],
942
-                2 => isset($zone[2]) && $zone[2],
943
-            );
944
-            $exists[3]   = $exists[0] && $zone[0] !== 'Etc';
945
-            $exists[4]   = $exists[1] && $exists[3];
946
-            $exists[5]   = $exists[2] && $exists[3];
947
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
948
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
949
-            // disabled because this code is copied from WordPress and is a WordPress domain
950
-            $zone_data[] = array(
951
-                'continent'   => $exists[0] ? $zone[0] : '',
952
-                'city'        => $exists[1] ? $zone[1] : '',
953
-                'subcity'     => $exists[2] ? $zone[2] : '',
954
-                't_continent' => $exists[3]
955
-                    ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
956
-                    : '',
957
-                't_city'      => $exists[4]
958
-                    ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
959
-                    : '',
960
-                't_subcity'   => $exists[5]
961
-                    ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
962
-                    : '',
963
-            );
964
-            // phpcs:enable
965
-        }
966
-        usort($zone_data, '_wp_timezone_choice_usort_callback');
967
-        $structure = array();
968
-        if (empty($selected_zone)) {
969
-            $structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
970
-        }
971
-        foreach ($zone_data as $key => $zone) {
972
-            // Build value in an array to join later
973
-            $value = array($zone['continent']);
974
-            if (empty($zone['city'])) {
975
-                // It's at the continent level (generally won't happen)
976
-                $display = $zone['t_continent'];
977
-            } else {
978
-                // It's inside a continent group
979
-                // Continent optgroup
980
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
981
-                    $label       = $zone['t_continent'];
982
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
983
-                }
984
-                // Add the city to the value
985
-                $value[] = $zone['city'];
986
-                $display = $zone['t_city'];
987
-                if (! empty($zone['subcity'])) {
988
-                    // Add the subcity to the value
989
-                    $value[] = $zone['subcity'];
990
-                    $display .= ' - ' . $zone['t_subcity'];
991
-                }
992
-            }
993
-            // Build the value
994
-            $value       = implode('/', $value);
995
-            $selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
997
-                           . esc_html($display)
998
-                           . '</option>';
999
-            // Close continent optgroup
1000
-            if (! empty($zone['city'])
1001
-                && (
1002
-                    ! isset($zone_data[ $key + 1 ])
1003
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1004
-                )
1005
-            ) {
1006
-                $structure[] = '</optgroup>';
1007
-            }
1008
-        }
1009
-        return implode("\n", $structure);
1010
-    }
897
+	/**
898
+	 * **
899
+	 * Gives a nicely-formatted list of timezone strings.
900
+	 * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
901
+	 *
902
+	 * @since     4.9.40.rc.008
903
+	 * @staticvar bool $mo_loaded
904
+	 * @staticvar string $locale_loaded
905
+	 * @param string $selected_zone Selected timezone.
906
+	 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
907
+	 * @return string
908
+	 */
909
+	public static function wp_timezone_choice($selected_zone, $locale = null)
910
+	{
911
+		static $mo_loaded = false, $locale_loaded = null;
912
+		$continents = array(
913
+			'Africa',
914
+			'America',
915
+			'Antarctica',
916
+			'Arctic',
917
+			'Asia',
918
+			'Atlantic',
919
+			'Australia',
920
+			'Europe',
921
+			'Indian',
922
+			'Pacific',
923
+		);
924
+		// Load translations for continents and cities.
925
+		if (! $mo_loaded || $locale !== $locale_loaded) {
926
+			$locale_loaded = $locale ? $locale : get_locale();
927
+			$mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
928
+			unload_textdomain('continents-cities');
929
+			load_textdomain('continents-cities', $mofile);
930
+			$mo_loaded = true;
931
+		}
932
+		$zone_data = array();
933
+		foreach (timezone_identifiers_list() as $zone) {
934
+			$zone = explode('/', $zone);
935
+			if (! in_array($zone[0], $continents, true)) {
936
+				continue;
937
+			}
938
+			// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
+			$exists      = array(
940
+				0 => isset($zone[0]) && $zone[0],
941
+				1 => isset($zone[1]) && $zone[1],
942
+				2 => isset($zone[2]) && $zone[2],
943
+			);
944
+			$exists[3]   = $exists[0] && $zone[0] !== 'Etc';
945
+			$exists[4]   = $exists[1] && $exists[3];
946
+			$exists[5]   = $exists[2] && $exists[3];
947
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
948
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
949
+			// disabled because this code is copied from WordPress and is a WordPress domain
950
+			$zone_data[] = array(
951
+				'continent'   => $exists[0] ? $zone[0] : '',
952
+				'city'        => $exists[1] ? $zone[1] : '',
953
+				'subcity'     => $exists[2] ? $zone[2] : '',
954
+				't_continent' => $exists[3]
955
+					? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
956
+					: '',
957
+				't_city'      => $exists[4]
958
+					? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
959
+					: '',
960
+				't_subcity'   => $exists[5]
961
+					? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
962
+					: '',
963
+			);
964
+			// phpcs:enable
965
+		}
966
+		usort($zone_data, '_wp_timezone_choice_usort_callback');
967
+		$structure = array();
968
+		if (empty($selected_zone)) {
969
+			$structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
970
+		}
971
+		foreach ($zone_data as $key => $zone) {
972
+			// Build value in an array to join later
973
+			$value = array($zone['continent']);
974
+			if (empty($zone['city'])) {
975
+				// It's at the continent level (generally won't happen)
976
+				$display = $zone['t_continent'];
977
+			} else {
978
+				// It's inside a continent group
979
+				// Continent optgroup
980
+				if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
981
+					$label       = $zone['t_continent'];
982
+					$structure[] = '<optgroup label="' . esc_attr($label) . '">';
983
+				}
984
+				// Add the city to the value
985
+				$value[] = $zone['city'];
986
+				$display = $zone['t_city'];
987
+				if (! empty($zone['subcity'])) {
988
+					// Add the subcity to the value
989
+					$value[] = $zone['subcity'];
990
+					$display .= ' - ' . $zone['t_subcity'];
991
+				}
992
+			}
993
+			// Build the value
994
+			$value       = implode('/', $value);
995
+			$selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
+			$structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
997
+						   . esc_html($display)
998
+						   . '</option>';
999
+			// Close continent optgroup
1000
+			if (! empty($zone['city'])
1001
+				&& (
1002
+					! isset($zone_data[ $key + 1 ])
1003
+					|| (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1004
+				)
1005
+			) {
1006
+				$structure[] = '</optgroup>';
1007
+			}
1008
+		}
1009
+		return implode("\n", $structure);
1010
+	}
1011 1011
 
1012 1012
 
1013
-    /**
1014
-     * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1015
-     *
1016
-     * @param int|WP_User $user_id
1017
-     * @return string
1018
-     */
1019
-    public static function get_user_locale($user_id = 0)
1020
-    {
1021
-        if (function_exists('get_user_locale')) {
1022
-            return get_user_locale($user_id);
1023
-        }
1024
-        return get_locale();
1025
-    }
1013
+	/**
1014
+	 * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1015
+	 *
1016
+	 * @param int|WP_User $user_id
1017
+	 * @return string
1018
+	 */
1019
+	public static function get_user_locale($user_id = 0)
1020
+	{
1021
+		if (function_exists('get_user_locale')) {
1022
+			return get_user_locale($user_id);
1023
+		}
1024
+		return get_locale();
1025
+	}
1026 1026
 
1027 1027
 
1028
-    /**
1029
-     * Return the appropriate helper adapter for DTT related things.
1030
-     *
1031
-     * @return HelperInterface
1032
-     * @throws InvalidArgumentException
1033
-     * @throws InvalidDataTypeException
1034
-     * @throws InvalidInterfaceException
1035
-     */
1036
-    private static function getHelperAdapter()
1037
-    {
1038
-        $dtt_helper_fqcn = PHP_VERSION_ID < 50600
1039
-            ? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1040
-            : 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1041
-        return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1042
-    }
1028
+	/**
1029
+	 * Return the appropriate helper adapter for DTT related things.
1030
+	 *
1031
+	 * @return HelperInterface
1032
+	 * @throws InvalidArgumentException
1033
+	 * @throws InvalidDataTypeException
1034
+	 * @throws InvalidInterfaceException
1035
+	 */
1036
+	private static function getHelperAdapter()
1037
+	{
1038
+		$dtt_helper_fqcn = PHP_VERSION_ID < 50600
1039
+			? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1040
+			: 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1041
+		return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1042
+	}
1043 1043
 
1044 1044
 
1045
-    /**
1046
-     * Helper function for setting the timezone on a DateTime object.
1047
-     * This is implemented to standardize a workaround for a PHP bug outlined in
1048
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1049
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1050
-     *
1051
-     * @param DateTime     $datetime
1052
-     * @param DateTimeZone $timezone
1053
-     */
1054
-    public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1055
-    {
1056
-        $datetime->setTimezone($timezone);
1057
-        $datetime->getTimestamp();
1058
-    }
1045
+	/**
1046
+	 * Helper function for setting the timezone on a DateTime object.
1047
+	 * This is implemented to standardize a workaround for a PHP bug outlined in
1048
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1049
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1050
+	 *
1051
+	 * @param DateTime     $datetime
1052
+	 * @param DateTimeZone $timezone
1053
+	 */
1054
+	public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1055
+	{
1056
+		$datetime->setTimezone($timezone);
1057
+		$datetime->getTimestamp();
1058
+	}
1059 1059
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133 133
     {
134
-        $gmt_offset =  (int) $gmt_offset;
134
+        $gmt_offset = (int) $gmt_offset;
135 135
         /** @var array[] $abbreviations */
136 136
         $abbreviations = DateTimeZone::listAbbreviations();
137 137
         foreach ($abbreviations as $abbreviation) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      */
327 327
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328 328
     {
329
-        if (! $DateTime instanceof DateTime) {
329
+        if ( ! $DateTime instanceof DateTime) {
330 330
             throw new EE_Error(
331 331
                 sprintf(
332 332
                     esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -336,25 +336,25 @@  discard block
 block discarded – undo
336 336
         }
337 337
         switch ($period) {
338 338
             case 'years':
339
-                $value = 'P' . $value . 'Y';
339
+                $value = 'P'.$value.'Y';
340 340
                 break;
341 341
             case 'months':
342
-                $value = 'P' . $value . 'M';
342
+                $value = 'P'.$value.'M';
343 343
                 break;
344 344
             case 'weeks':
345
-                $value = 'P' . $value . 'W';
345
+                $value = 'P'.$value.'W';
346 346
                 break;
347 347
             case 'days':
348
-                $value = 'P' . $value . 'D';
348
+                $value = 'P'.$value.'D';
349 349
                 break;
350 350
             case 'hours':
351
-                $value = 'PT' . $value . 'H';
351
+                $value = 'PT'.$value.'H';
352 352
                 break;
353 353
             case 'minutes':
354
-                $value = 'PT' . $value . 'M';
354
+                $value = 'PT'.$value.'M';
355 355
                 break;
356 356
             case 'seconds':
357
-                $value = 'PT' . $value . 'S';
357
+                $value = 'PT'.$value.'S';
358 358
                 break;
359 359
         }
360 360
         switch ($operand) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384 384
     {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
385
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386 386
             throw new EE_Error(
387 387
                 sprintf(
388 388
                     esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                 'date' => $date_format['js'],
496 496
                 'time' => $time_format['js'],
497 497
             ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
498
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
499 499
             'moment_split' => array(
500 500
                 'date' => $date_format['moment'],
501 501
                 'time' => $time_format['moment']
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
          *
519 519
          * @var array
520 520
          */
521
-        $symbols_map          = array(
521
+        $symbols_map = array(
522 522
             // Day
523 523
             // 01
524 524
             'd' => array(
@@ -670,26 +670,26 @@  discard block
 block discarded – undo
670 670
         $escaping             = false;
671 671
         $format_string_length = strlen($format_string);
672 672
         for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
673
+            $char = $format_string[$i];
674 674
             if ($char === '\\') { // PHP date format escaping character
675 675
                 $i++;
676 676
                 if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
677
+                    $jquery_ui_format .= $format_string[$i];
678
+                    $moment_format    .= $format_string[$i];
679 679
                 } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
680
+                    $jquery_ui_format .= '\''.$format_string[$i];
681
+                    $moment_format    .= $format_string[$i];
682 682
                 }
683 683
                 $escaping = true;
684 684
             } else {
685 685
                 if ($escaping) {
686 686
                     $jquery_ui_format .= "'";
687 687
                     $moment_format    .= "'";
688
-                    $escaping         = false;
688
+                    $escaping = false;
689 689
                 }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
690
+                if (isset($symbols_map[$char])) {
691
+                    $jquery_ui_format .= $symbols_map[$char]['js'];
692
+                    $moment_format    .= $symbols_map[$char]['moment'];
693 693
                 } else {
694 694
                     $jquery_ui_format .= $char;
695 695
                     $moment_format    .= $char;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
     public static function dates_represent_one_24_hour_date($date_1, $date_2)
747 747
     {
748 748
 
749
-        if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
749
+        if (( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750 750
             || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751 751
                 || $date_2->format(
752 752
                     EE_Datetime_Field::mysql_time_format
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
             ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783 783
             : (float) get_option('gmt_offset');
784 784
         $query_interval = $offset < 0
785
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
785
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
786
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
787 787
         return $query_interval;
788 788
     }
789 789
 
@@ -800,16 +800,16 @@  discard block
 block discarded – undo
800 800
     public static function get_timezone_string_for_display()
801 801
     {
802 802
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
-        if (! empty($pretty_timezone)) {
803
+        if ( ! empty($pretty_timezone)) {
804 804
             return esc_html($pretty_timezone);
805 805
         }
806 806
         $timezone_string = get_option('timezone_string');
807 807
         if ($timezone_string) {
808 808
             static $mo_loaded = false;
809 809
             // Load translations for continents and cities just like wp_timezone_choice does
810
-            if (! $mo_loaded) {
810
+            if ( ! $mo_loaded) {
811 811
                 $locale = get_locale();
812
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
812
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
813 813
                 load_textdomain('continents-cities', $mofile);
814 814
                 $mo_loaded = true;
815 815
             }
@@ -836,10 +836,10 @@  discard block
 block discarded – undo
836 836
         } else {
837 837
             // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838 838
             // to minutes, eg 30 or 15, respectively
839
-            $hour_fraction = (float) ('0.' . $parts[1]);
839
+            $hour_fraction = (float) ('0.'.$parts[1]);
840 840
             $parts[1]      = (string) $hour_fraction * 60;
841 841
         }
842
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
842
+        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
843 843
     }
844 844
 
845 845
 
@@ -922,9 +922,9 @@  discard block
 block discarded – undo
922 922
             'Pacific',
923 923
         );
924 924
         // Load translations for continents and cities.
925
-        if (! $mo_loaded || $locale !== $locale_loaded) {
925
+        if ( ! $mo_loaded || $locale !== $locale_loaded) {
926 926
             $locale_loaded = $locale ? $locale : get_locale();
927
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
927
+            $mofile        = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
928 928
             unload_textdomain('continents-cities');
929 929
             load_textdomain('continents-cities', $mofile);
930 930
             $mo_loaded = true;
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
         $zone_data = array();
933 933
         foreach (timezone_identifiers_list() as $zone) {
934 934
             $zone = explode('/', $zone);
935
-            if (! in_array($zone[0], $continents, true)) {
935
+            if ( ! in_array($zone[0], $continents, true)) {
936 936
                 continue;
937 937
             }
938 938
             // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
-            $exists      = array(
939
+            $exists = array(
940 940
                 0 => isset($zone[0]) && $zone[0],
941 941
                 1 => isset($zone[1]) && $zone[1],
942 942
                 2 => isset($zone[2]) && $zone[2],
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
         usort($zone_data, '_wp_timezone_choice_usort_callback');
967 967
         $structure = array();
968 968
         if (empty($selected_zone)) {
969
-            $structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
969
+            $structure[] = '<option selected="selected" value="">'.__('Select a city', 'event_espresso').'</option>';
970 970
         }
971 971
         foreach ($zone_data as $key => $zone) {
972 972
             // Build value in an array to join later
@@ -977,30 +977,30 @@  discard block
 block discarded – undo
977 977
             } else {
978 978
                 // It's inside a continent group
979 979
                 // Continent optgroup
980
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
980
+                if ( ! isset($zone_data[$key - 1]) || $zone_data[$key - 1]['continent'] !== $zone['continent']) {
981 981
                     $label       = $zone['t_continent'];
982
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
982
+                    $structure[] = '<optgroup label="'.esc_attr($label).'">';
983 983
                 }
984 984
                 // Add the city to the value
985 985
                 $value[] = $zone['city'];
986 986
                 $display = $zone['t_city'];
987
-                if (! empty($zone['subcity'])) {
987
+                if ( ! empty($zone['subcity'])) {
988 988
                     // Add the subcity to the value
989 989
                     $value[] = $zone['subcity'];
990
-                    $display .= ' - ' . $zone['t_subcity'];
990
+                    $display .= ' - '.$zone['t_subcity'];
991 991
                 }
992 992
             }
993 993
             // Build the value
994 994
             $value       = implode('/', $value);
995 995
             $selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
996
+            $structure[] = '<option value="'.esc_attr($value).'"'.$selected.'>'
997 997
                            . esc_html($display)
998 998
                            . '</option>';
999 999
             // Close continent optgroup
1000
-            if (! empty($zone['city'])
1000
+            if ( ! empty($zone['city'])
1001 1001
                 && (
1002
-                    ! isset($zone_data[ $key + 1 ])
1003
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1002
+                    ! isset($zone_data[$key + 1])
1003
+                    || (isset($zone_data[$key + 1]) && $zone_data[$key + 1]['continent'] !== $zone['continent'])
1004 1004
                 )
1005 1005
             ) {
1006 1006
                 $structure[] = '</optgroup>';
Please login to merge, or discard this patch.