Completed
Branch BUG/reg-status-change-recursio... (2db0c9)
by
unknown
20:03 queued 10:32
created
core/domain/services/contexts/RequestTypeContextFactory.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -17,116 +17,116 @@
 block discarded – undo
17 17
 class RequestTypeContextFactory implements RequestTypeContextFactoryInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    private $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	private $loader;
24 24
 
25 25
 
26
-    /**
27
-     * RequestTypeContextFactory constructor.
28
-     *
29
-     * @param LoaderInterface $loader
30
-     */
31
-    public function __construct(LoaderInterface $loader)
32
-    {
33
-        $this->loader = $loader;
34
-    }
26
+	/**
27
+	 * RequestTypeContextFactory constructor.
28
+	 *
29
+	 * @param LoaderInterface $loader
30
+	 */
31
+	public function __construct(LoaderInterface $loader)
32
+	{
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @param string $slug
39
-     * @return RequestTypeContext
40
-     */
41
-    public function create($slug)
42
-    {
43
-        switch ($slug) {
44
-            case RequestTypeContext::ACTIVATION:
45
-                $description = esc_html__(
46
-                    'The current request is for some form of activation',
47
-                    'event_espresso'
48
-                );
49
-                break;
50
-            case RequestTypeContext::API:
51
-                $description = esc_html__(
52
-                    'The current request is for the EE REST API',
53
-                    'event_espresso'
54
-                );
55
-                break;
56
-            case RequestTypeContext::AJAX_FRONT:
57
-                $description = esc_html__(
58
-                    'The current request is for the frontend via AJAX',
59
-                    'event_espresso'
60
-                );
61
-                break;
62
-            case RequestTypeContext::AJAX_ADMIN:
63
-                $description = esc_html__(
64
-                    'The current request is for the admin via AJAX',
65
-                    'event_espresso'
66
-                );
67
-                break;
68
-            case RequestTypeContext::AJAX_OTHER:
69
-                $description = esc_html__(
70
-                    'The current request is for non-EE related code via AJAX',
71
-                    'event_espresso'
72
-                );
73
-                break;
74
-            case RequestTypeContext::CRON:
75
-                $description = esc_html__(
76
-                    'The current request is for a WP_Cron',
77
-                    'event_espresso'
78
-                );
79
-                break;
80
-            case RequestTypeContext::CLI:
81
-                $description = esc_html__(
82
-                    'The current request is from the command line',
83
-                    'event_espresso'
84
-                );
85
-                break;
86
-            case RequestTypeContext::ADMIN:
87
-                $description = esc_html__(
88
-                    'The current request is for the admin',
89
-                    'event_espresso'
90
-                );
91
-                break;
92
-            case RequestTypeContext::IFRAME:
93
-                $description = esc_html__(
94
-                    'The current request is for an iframe',
95
-                    'event_espresso'
96
-                );
97
-                break;
98
-            case RequestTypeContext::FEED:
99
-                $description = esc_html__(
100
-                    'The current request is for a feed (ie: RSS)',
101
-                    'event_espresso'
102
-                );
103
-                break;
104
-            case RequestTypeContext::WP_API:
105
-                $description = esc_html__(
106
-                    'The current request is for the WordPress REST API',
107
-                    'event_espresso'
108
-                );
109
-                break;
110
-            case RequestTypeContext::WP_SCRAPE:
111
-                $description = esc_html__(
112
-                    'The current request is for a WordPress loopback scrape',
113
-                    'event_espresso'
114
-                );
115
-                break;
116
-            case RequestTypeContext::FRONTEND:
117
-            default:
118
-                $description = esc_html__(
119
-                    'The current request is for the frontend',
120
-                    'event_espresso'
121
-                );
122
-                break;
123
-        }
124
-        // we're using the Loader with sharing turned on,
125
-        // so that the generated RequestTypeContext object is accessible anywhere
126
-        // by simply requesting it again from the loader
127
-        return $this->loader->getShared(
128
-            'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
129
-            array($slug, $description)
130
-        );
131
-    }
37
+	/**
38
+	 * @param string $slug
39
+	 * @return RequestTypeContext
40
+	 */
41
+	public function create($slug)
42
+	{
43
+		switch ($slug) {
44
+			case RequestTypeContext::ACTIVATION:
45
+				$description = esc_html__(
46
+					'The current request is for some form of activation',
47
+					'event_espresso'
48
+				);
49
+				break;
50
+			case RequestTypeContext::API:
51
+				$description = esc_html__(
52
+					'The current request is for the EE REST API',
53
+					'event_espresso'
54
+				);
55
+				break;
56
+			case RequestTypeContext::AJAX_FRONT:
57
+				$description = esc_html__(
58
+					'The current request is for the frontend via AJAX',
59
+					'event_espresso'
60
+				);
61
+				break;
62
+			case RequestTypeContext::AJAX_ADMIN:
63
+				$description = esc_html__(
64
+					'The current request is for the admin via AJAX',
65
+					'event_espresso'
66
+				);
67
+				break;
68
+			case RequestTypeContext::AJAX_OTHER:
69
+				$description = esc_html__(
70
+					'The current request is for non-EE related code via AJAX',
71
+					'event_espresso'
72
+				);
73
+				break;
74
+			case RequestTypeContext::CRON:
75
+				$description = esc_html__(
76
+					'The current request is for a WP_Cron',
77
+					'event_espresso'
78
+				);
79
+				break;
80
+			case RequestTypeContext::CLI:
81
+				$description = esc_html__(
82
+					'The current request is from the command line',
83
+					'event_espresso'
84
+				);
85
+				break;
86
+			case RequestTypeContext::ADMIN:
87
+				$description = esc_html__(
88
+					'The current request is for the admin',
89
+					'event_espresso'
90
+				);
91
+				break;
92
+			case RequestTypeContext::IFRAME:
93
+				$description = esc_html__(
94
+					'The current request is for an iframe',
95
+					'event_espresso'
96
+				);
97
+				break;
98
+			case RequestTypeContext::FEED:
99
+				$description = esc_html__(
100
+					'The current request is for a feed (ie: RSS)',
101
+					'event_espresso'
102
+				);
103
+				break;
104
+			case RequestTypeContext::WP_API:
105
+				$description = esc_html__(
106
+					'The current request is for the WordPress REST API',
107
+					'event_espresso'
108
+				);
109
+				break;
110
+			case RequestTypeContext::WP_SCRAPE:
111
+				$description = esc_html__(
112
+					'The current request is for a WordPress loopback scrape',
113
+					'event_espresso'
114
+				);
115
+				break;
116
+			case RequestTypeContext::FRONTEND:
117
+			default:
118
+				$description = esc_html__(
119
+					'The current request is for the frontend',
120
+					'event_espresso'
121
+				);
122
+				break;
123
+		}
124
+		// we're using the Loader with sharing turned on,
125
+		// so that the generated RequestTypeContext object is accessible anywhere
126
+		// by simply requesting it again from the loader
127
+		return $this->loader->getShared(
128
+			'EventEspresso\core\domain\entities\contexts\RequestTypeContext',
129
+			array($slug, $description)
130
+		);
131
+	}
132 132
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextFactoryInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 interface RequestTypeContextFactoryInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param string $slug
20
-     * @return RequestTypeContext
21
-     */
22
-    public function create($slug);
18
+	/**
19
+	 * @param string $slug
20
+	 * @return RequestTypeContext
21
+	 */
22
+	public function create($slug);
23 23
 }
Please login to merge, or discard this patch.
core/services/request/middleware/SetRequestTypeContextChecker.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
 class SetRequestTypeContextChecker extends Middleware
19 19
 {
20 20
 
21
-    /**
22
-     * converts a Request to a Response
23
-     *
24
-     * @param RequestInterface  $request
25
-     * @param ResponseInterface $response
26
-     * @return ResponseInterface
27
-     * @throws InvalidArgumentException
28
-     */
29
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
30
-    {
31
-        $this->request  = $request;
32
-        $this->response = $response;
33
-        /** @var RequestTypeContextDetector $request_type_context_detector */
34
-        $request_type_context_detector = $this->loader->getShared(
35
-            'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector',
36
-            array(
37
-                $this->request,
38
-                $this->loader->getShared(
39
-                    'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory',
40
-                    array($this->loader)
41
-                ),
42
-                array(
43
-                    'DOING_AJAX' => defined('DOING_AJAX') && DOING_AJAX,
44
-                    'WP_CLI'     => defined('WP_CLI') && WP_CLI,
45
-                    'is_admin'   => is_admin(),
46
-                )
47
-            )
48
-        );
49
-        $request_type_context          = $request_type_context_detector->detectRequestTypeContext();
50
-        $request_type_context_checker  = $this->loader->getShared(
51
-            'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker',
52
-            array($request_type_context)
53
-        );
54
-        $this->request->setRequestTypeContextChecker($request_type_context_checker);
55
-        $this->response = $this->processRequestStack($this->request, $this->response);
56
-        return $this->response;
57
-    }
21
+	/**
22
+	 * converts a Request to a Response
23
+	 *
24
+	 * @param RequestInterface  $request
25
+	 * @param ResponseInterface $response
26
+	 * @return ResponseInterface
27
+	 * @throws InvalidArgumentException
28
+	 */
29
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
30
+	{
31
+		$this->request  = $request;
32
+		$this->response = $response;
33
+		/** @var RequestTypeContextDetector $request_type_context_detector */
34
+		$request_type_context_detector = $this->loader->getShared(
35
+			'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector',
36
+			array(
37
+				$this->request,
38
+				$this->loader->getShared(
39
+					'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory',
40
+					array($this->loader)
41
+				),
42
+				array(
43
+					'DOING_AJAX' => defined('DOING_AJAX') && DOING_AJAX,
44
+					'WP_CLI'     => defined('WP_CLI') && WP_CLI,
45
+					'is_admin'   => is_admin(),
46
+				)
47
+			)
48
+		);
49
+		$request_type_context          = $request_type_context_detector->detectRequestTypeContext();
50
+		$request_type_context_checker  = $this->loader->getShared(
51
+			'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker',
52
+			array($request_type_context)
53
+		);
54
+		$this->request->setRequestTypeContextChecker($request_type_context_checker);
55
+		$this->response = $this->processRequestStack($this->request, $this->response);
56
+		return $this->response;
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/domain/services/assets/CoreAssetManager.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 
277 277
         $this->addJavascript(
278 278
             CoreAssetManager::JS_HANDLE_EE_CORE,
279
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
279
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
280 280
             array(CoreAssetManager::JS_HANDLE_JQUERY)
281 281
         )
282 282
         ->setInlineDataCallback(
283
-            function () {
283
+            function() {
284 284
                 wp_localize_script(
285 285
                     CoreAssetManager::JS_HANDLE_EE_CORE,
286 286
                     CoreAssetManager::JS_HANDLE_EE_I18N,
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
         if ($this->template_config->enable_default_style && ! is_admin()) {
350 350
             $this->addStylesheet(
351 351
                 CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
352
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
352
+                is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
353 353
                     ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
354
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
354
+                    : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
355 355
                 array('dashicons')
356 356
             );
357 357
             //Load custom style sheet if available
358 358
             if ($this->template_config->custom_style_sheet !== null) {
359 359
                 $this->addStylesheet(
360 360
                     CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
361
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
361
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
362 362
                     array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
363 363
                 );
364 364
             }
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
     {
386 386
         $this->addJavascript(
387 387
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
388
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
388
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
389 389
             array(CoreAssetManager::JS_HANDLE_JQUERY)
390 390
         )
391 391
         ->setVersion('1.15.0');
392 392
 
393 393
         $this->addJavascript(
394 394
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
395
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
395
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
396 396
             array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
397 397
         )
398 398
         ->setVersion('1.15.0');
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
         // @link http://josscrowcroft.github.io/accounting.js/
414 414
         $this->addJavascript(
415 415
             CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
416
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
416
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
417 417
             array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
418 418
         )
419 419
         ->setVersion('0.3.2');
420 420
 
421 421
         $this->addJavascript(
422 422
             CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
423
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
423
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
424 424
             array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
425 425
         )
426 426
         ->setInlineDataCallback(
427
-            function () {
427
+            function() {
428 428
                  wp_localize_script(
429 429
                      CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
430 430
                      'EE_ACCOUNTING_CFG',
Please login to merge, or discard this patch.
Indentation   +512 added lines, -512 removed lines patch added patch discarded remove patch
@@ -31,535 +31,535 @@
 block discarded – undo
31 31
 class CoreAssetManager extends AssetManager
32 32
 {
33 33
 
34
-    // WordPress core / Third party JS asset handles
35
-    const JS_HANDLE_JQUERY = 'jquery';
34
+	// WordPress core / Third party JS asset handles
35
+	const JS_HANDLE_JQUERY = 'jquery';
36 36
 
37
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
37
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
38 38
 
39
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
39
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
40 40
 
41
-    const JS_HANDLE_UNDERSCORE = 'underscore';
41
+	const JS_HANDLE_UNDERSCORE = 'underscore';
42 42
 
43
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
43
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
44 44
 
45
-    /**
46
-     * @since $VID:$
47
-     */
48
-    const JS_HANDLE_REACT = 'react';
45
+	/**
46
+	 * @since $VID:$
47
+	 */
48
+	const JS_HANDLE_REACT = 'react';
49 49
 
50
-    /**
51
-     * @since $VID:$
52
-     */
53
-    const JS_HANDLE_REACT_DOM = 'react-dom';
50
+	/**
51
+	 * @since $VID:$
52
+	 */
53
+	const JS_HANDLE_REACT_DOM = 'react-dom';
54 54
 
55
-    /**
56
-     * @since $VID:$
57
-     */
58
-    const JS_HANDLE_LODASH = 'lodash';
55
+	/**
56
+	 * @since $VID:$
57
+	 */
58
+	const JS_HANDLE_LODASH = 'lodash';
59 59
 
60
-    // EE JS assets handles
61
-    const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
60
+	// EE JS assets handles
61
+	const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
62 62
 
63
-    const JS_HANDLE_EE_JS_CORE = 'eejs-core';
63
+	const JS_HANDLE_EE_JS_CORE = 'eejs-core';
64 64
 
65
-    const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
65
+	const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
66 66
 
67
-    const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
67
+	const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
68 68
 
69
-    const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
69
+	const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
70 70
 
71
-    const JS_HANDLE_EE_MODEL = 'eventespresso-model';
71
+	const JS_HANDLE_EE_MODEL = 'eventespresso-model';
72 72
 
73
-    const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
73
+	const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
74 74
 
75
-    const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
75
+	const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
76 76
 
77
-    const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
78
-
79
-    const JS_HANDLE_EE_VALIDATORS = 'eventespresso-validators';
77
+	const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
78
+
79
+	const JS_HANDLE_EE_VALIDATORS = 'eventespresso-validators';
80 80
 
81
-    const JS_HANDLE_EE_JS_API = 'eejs-api';
81
+	const JS_HANDLE_EE_JS_API = 'eejs-api';
82 82
 
83
-    const JS_HANDLE_EE_CORE = 'espresso_core';
83
+	const JS_HANDLE_EE_CORE = 'espresso_core';
84 84
 
85
-    const JS_HANDLE_EE_I18N = 'eei18n';
86
-
87
-    const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
88
-
89
-    const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
90
-
91
-    // EE CSS assets handles
92
-    const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
93
-
94
-    const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
95
-
96
-    const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
97
-
98
-    /**
99
-     * @var EE_Currency_Config $currency_config
100
-     */
101
-    protected $currency_config;
102
-
103
-    /**
104
-     * @var EE_Template_Config $template_config
105
-     */
106
-    protected $template_config;
107
-
108
-
109
-    /**
110
-     * CoreAssetRegister constructor.
111
-     *
112
-     * @param AssetCollection    $assets
113
-     * @param EE_Currency_Config $currency_config
114
-     * @param EE_Template_Config $template_config
115
-     * @param DomainInterface    $domain
116
-     * @param Registry           $registry
117
-     */
118
-    public function __construct(
119
-        AssetCollection $assets,
120
-        EE_Currency_Config $currency_config,
121
-        EE_Template_Config $template_config,
122
-        DomainInterface $domain,
123
-        Registry $registry
124
-    ) {
125
-        $this->currency_config = $currency_config;
126
-        $this->template_config = $template_config;
127
-        parent::__construct($domain, $assets, $registry);
128
-    }
129
-
130
-
131
-    /**
132
-     * @since 4.9.62.p
133
-     * @throws DomainException
134
-     * @throws DuplicateCollectionIdentifierException
135
-     * @throws InvalidArgumentException
136
-     * @throws InvalidDataTypeException
137
-     * @throws InvalidEntityException
138
-     * @throws InvalidInterfaceException
139
-     */
140
-    public function addAssets()
141
-    {
142
-        $this->addJavascriptFiles();
143
-        $this->addStylesheetFiles();
144
-    }
145
-
146
-
147
-    /**
148
-     * @since 4.9.62.p
149
-     * @throws DomainException
150
-     * @throws DuplicateCollectionIdentifierException
151
-     * @throws InvalidArgumentException
152
-     * @throws InvalidDataTypeException
153
-     * @throws InvalidEntityException
154
-     * @throws InvalidInterfaceException
155
-     */
156
-    public function addJavascriptFiles()
157
-    {
158
-        $this->loadCoreJs();
159
-        $this->loadJqueryValidate();
160
-        $this->loadAccountingJs();
161
-        add_action(
162
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
163
-            array($this, 'loadQtipJs')
164
-        );
165
-        $this->registerAdminAssets();
166
-    }
167
-
168
-
169
-    /**
170
-     * @since 4.9.62.p
171
-     * @throws DuplicateCollectionIdentifierException
172
-     * @throws InvalidDataTypeException
173
-     * @throws InvalidEntityException
174
-     */
175
-    public function addStylesheetFiles()
176
-    {
177
-        $this->loadCoreCss();
178
-    }
179
-
180
-
181
-    /**
182
-     * core default javascript
183
-     *
184
-     * @since 4.9.62.p
185
-     * @throws DomainException
186
-     * @throws DuplicateCollectionIdentifierException
187
-     * @throws InvalidArgumentException
188
-     * @throws InvalidDataTypeException
189
-     * @throws InvalidEntityException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    private function loadCoreJs()
193
-    {
194
-        // conditionally load third-party libraries that WP core MIGHT have.
195
-        $this->registerWpAssets();
196
-
197
-        $this->addJavascript(
198
-            CoreAssetManager::JS_HANDLE_EE_MANIFEST,
199
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
200
-        );
201
-
202
-        $this->addJavascript(
203
-            CoreAssetManager::JS_HANDLE_EE_JS_CORE,
204
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
205
-            array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
206
-        )
207
-        ->setHasInlineData();
208
-
209
-        $this->addJavascript(
210
-            CoreAssetManager::JS_HANDLE_EE_VENDOR,
211
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
212
-            array(
213
-                CoreAssetManager::JS_HANDLE_EE_JS_CORE,
214
-                CoreAssetManager::JS_HANDLE_REACT,
215
-                CoreAssetManager::JS_HANDLE_REACT_DOM,
216
-                CoreAssetManager::JS_HANDLE_LODASH,
217
-            )
218
-        );
219
-
220
-        $this->addJavascript(
221
-            CoreAssetManager::JS_HANDLE_EE_VALIDATORS,
222
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
223
-        )->setRequiresTranslation();
224
-
225
-        $this->addJavascript(
226
-            CoreAssetManager::JS_HANDLE_EE_HELPERS,
227
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
228
-            array(
229
-                CoreAssetManager::JS_HANDLE_EE_VALIDATORS
230
-            )
231
-        )->setRequiresTranslation();
232
-
233
-        $this->addJavascript(
234
-            CoreAssetManager::JS_HANDLE_EE_MODEL,
235
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
236
-            array(
237
-                CoreAssetManager::JS_HANDLE_EE_HELPERS
238
-            )
239
-        )->setRequiresTranslation();
240
-
241
-        $this->addJavascript(
242
-            CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
243
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
244
-            array(
245
-                CoreAssetManager::JS_HANDLE_EE_MODEL
246
-            )
247
-        )->setRequiresTranslation();
248
-
249
-        $this->addJavascript(
250
-            CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
251
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
252
-            array(
253
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
254
-                'wp-data',
255
-                'wp-api-request',
256
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS
257
-            )
258
-        )
259
-             ->setRequiresTranslation();
260
-
261
-        $this->addJavascript(
262
-            CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
263
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
264
-            array(
265
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
266
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
267
-                'wp-components',
268
-            )
269
-        )->setRequiresTranslation();
270
-
271
-        $this->addJavascript(
272
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
273
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
274
-            array(
275
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
276
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
277
-                'wp-components',
278
-            )
279
-        )
280
-        ->setRequiresTranslation();
281
-
282
-        $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
283
-        $this->registry->addData(
284
-            'paths',
285
-            array(
286
-                'rest_route' => rest_url('ee/v4.8.36/'),
287
-                'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
288
-                'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
289
-                'site_url' => site_url('/'),
290
-                'admin_url' => admin_url('/'),
291
-            )
292
-        );
293
-        /** site formatting values **/
294
-        $this->registry->addData(
295
-            'site_formats',
296
-            array(
297
-                'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
298
-            )
299
-        );
300
-        /** currency data **/
301
-        $this->registry->addData(
302
-            'currency_config',
303
-            $this->getCurrencySettings()
304
-        );
305
-        /** site timezone */
306
-        $this->registry->addData(
307
-            'default_timezone',
308
-            array(
309
-                'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
310
-                'string' => get_option('timezone_string'),
311
-                'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
312
-            )
313
-        );
314
-        /** site locale (user locale if user logged in) */
315
-        $this->registry->addData(
316
-            'locale',
317
-            array(
318
-                'user' => get_user_locale(),
319
-                'site' => get_locale()
320
-            )
321
-        );
322
-
323
-        $this->addJavascript(
324
-            CoreAssetManager::JS_HANDLE_EE_CORE,
325
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
326
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
327
-        )
328
-        ->setInlineDataCallback(
329
-            function () {
330
-                wp_localize_script(
331
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
332
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
333
-                    EE_Registry::$i18n_js_strings
334
-                );
335
-            }
336
-        );
337
-    }
338
-
339
-
340
-    /**
341
-     * Registers vendor files that are bundled with a later version WP but might not be for the current version of
342
-     * WordPress in the running environment.
343
-     *
344
-     * @throws DuplicateCollectionIdentifierException
345
-     * @throws InvalidDataTypeException
346
-     * @throws InvalidEntityException
347
-     * @throws DomainException
348
-     * @since $VID:$
349
-     */
350
-    private function registerWpAssets()
351
-    {
352
-        global $wp_version;
353
-        if (version_compare($wp_version, '5.0.beta', '>=')) {
354
-            return;
355
-        }
356
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
357
-            ->setVersion('16.6.0');
358
-        $this->addVendorJavascript(
359
-            CoreAssetManager::JS_HANDLE_REACT_DOM,
360
-            array(CoreAssetManager::JS_HANDLE_REACT)
361
-        )->setVersion('16.6.0');
362
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
363
-            ->setInlineDataCallback(
364
-                function() {
365
-                    wp_add_inline_script(
366
-                        CoreAssetManager::JS_HANDLE_LODASH,
367
-                        'window.lodash = _.noConflict();'
368
-                    );
369
-                }
370
-            )
371
-            ->setVersion('4.17.11');
372
-    }
373
-
374
-
375
-    /**
376
-     * Returns configuration data for the accounting-js library.
377
-     * @since $VID:$
378
-     * @return array
379
-     */
380
-    private function getAccountingSettings() {
381
-        return array(
382
-            'currency' => array(
383
-                'symbol'    => $this->currency_config->sign,
384
-                'format'    => array(
385
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
386
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
387
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
388
-                ),
389
-                'decimal'   => $this->currency_config->dec_mrk,
390
-                'thousand'  => $this->currency_config->thsnds,
391
-                'precision' => $this->currency_config->dec_plc,
392
-            ),
393
-            'number'   => array(
394
-                'precision' => $this->currency_config->dec_plc,
395
-                'thousand'  => $this->currency_config->thsnds,
396
-                'decimal'   => $this->currency_config->dec_mrk,
397
-            ),
398
-        );
399
-    }
400
-
401
-
402
-    /**
403
-     * Returns configuration data for the js Currency VO.
404
-     * @since $VID:$
405
-     * @return array
406
-     */
407
-    private function getCurrencySettings()
408
-    {
409
-        return array(
410
-            'code' => $this->currency_config->code,
411
-            'singularLabel' => $this->currency_config->name,
412
-            'pluralLabel' => $this->currency_config->plural,
413
-            'sign' => $this->currency_config->sign,
414
-            'signB4' => $this->currency_config->sign_b4,
415
-            'decimalPlaces' => $this->currency_config->dec_plc,
416
-            'decimalMark' => $this->currency_config->dec_mrk,
417
-            'thousandsSeparator' => $this->currency_config->thsnds,
418
-        );
419
-    }
420
-
421
-
422
-    /**
423
-     * @since 4.9.62.p
424
-     * @throws DuplicateCollectionIdentifierException
425
-     * @throws InvalidDataTypeException
426
-     * @throws InvalidEntityException
427
-     */
428
-    private function loadCoreCss()
429
-    {
430
-        if ($this->template_config->enable_default_style && ! is_admin()) {
431
-            $this->addStylesheet(
432
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
433
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
434
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
435
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
436
-                array('dashicons')
437
-            );
438
-            //Load custom style sheet if available
439
-            if ($this->template_config->custom_style_sheet !== null) {
440
-                $this->addStylesheet(
441
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
442
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
443
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
444
-                );
445
-            }
446
-        }
447
-        $this->addStylesheet(
448
-            CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
449
-            $this->registry->getCssUrl(
450
-                $this->domain->assetNamespace(),
451
-                'components'
452
-            )
453
-        );
454
-    }
455
-
456
-
457
-    /**
458
-     * jQuery Validate for form validation
459
-     *
460
-     * @since 4.9.62.p
461
-     * @throws DomainException
462
-     * @throws DuplicateCollectionIdentifierException
463
-     * @throws InvalidDataTypeException
464
-     * @throws InvalidEntityException
465
-     */
466
-    private function loadJqueryValidate()
467
-    {
468
-        $this->addJavascript(
469
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
470
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
471
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
472
-        )
473
-        ->setVersion('1.15.0');
474
-
475
-        $this->addJavascript(
476
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
477
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
478
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
479
-        )
480
-        ->setVersion('1.15.0');
481
-    }
482
-
483
-
484
-    /**
485
-     * accounting.js for performing client-side calculations
486
-     *
487
-     * @since 4.9.62.p
488
-     * @throws DomainException
489
-     * @throws DuplicateCollectionIdentifierException
490
-     * @throws InvalidDataTypeException
491
-     * @throws InvalidEntityException
492
-     */
493
-    private function loadAccountingJs()
494
-    {
495
-        //accounting.js library
496
-        // @link http://josscrowcroft.github.io/accounting.js/
497
-        $this->addJavascript(
498
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
499
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
500
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
501
-        )
502
-        ->setVersion('0.3.2');
503
-
504
-        $this->addJavascript(
505
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
506
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
507
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
508
-        )
509
-        ->setInlineDataCallback(
510
-            function () {
511
-                 wp_localize_script(
512
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
513
-                     'EE_ACCOUNTING_CFG',
514
-                     $this->getAccountingSettings()
515
-                 );
516
-            }
517
-        )
518
-        ->setVersion();
519
-    }
520
-
521
-
522
-    /**
523
-     * registers assets for cleaning your ears
524
-     *
525
-     * @param JavascriptAsset $script
526
-     */
527
-    public function loadQtipJs(JavascriptAsset $script)
528
-    {
529
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
530
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
531
-        if (
532
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
533
-            && apply_filters('FHEE_load_qtip', false)
534
-        ) {
535
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
536
-        }
537
-    }
538
-
539
-
540
-    /**
541
-     * assets that are used in the WordPress admin
542
-     *
543
-     * @since 4.9.62.p
544
-     * @throws DuplicateCollectionIdentifierException
545
-     * @throws InvalidDataTypeException
546
-     * @throws InvalidEntityException
547
-     */
548
-    private function registerAdminAssets()
549
-    {
550
-        $this->addJavascript(
551
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
552
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
553
-            array(
554
-                CoreAssetManager::JS_HANDLE_JQUERY,
555
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
556
-            )
557
-        )
558
-        ->setRequiresTranslation();
559
-
560
-        $this->addStylesheet(
561
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
562
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
563
-        );
564
-    }
85
+	const JS_HANDLE_EE_I18N = 'eei18n';
86
+
87
+	const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
88
+
89
+	const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
90
+
91
+	// EE CSS assets handles
92
+	const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
93
+
94
+	const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
95
+
96
+	const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
97
+
98
+	/**
99
+	 * @var EE_Currency_Config $currency_config
100
+	 */
101
+	protected $currency_config;
102
+
103
+	/**
104
+	 * @var EE_Template_Config $template_config
105
+	 */
106
+	protected $template_config;
107
+
108
+
109
+	/**
110
+	 * CoreAssetRegister constructor.
111
+	 *
112
+	 * @param AssetCollection    $assets
113
+	 * @param EE_Currency_Config $currency_config
114
+	 * @param EE_Template_Config $template_config
115
+	 * @param DomainInterface    $domain
116
+	 * @param Registry           $registry
117
+	 */
118
+	public function __construct(
119
+		AssetCollection $assets,
120
+		EE_Currency_Config $currency_config,
121
+		EE_Template_Config $template_config,
122
+		DomainInterface $domain,
123
+		Registry $registry
124
+	) {
125
+		$this->currency_config = $currency_config;
126
+		$this->template_config = $template_config;
127
+		parent::__construct($domain, $assets, $registry);
128
+	}
129
+
130
+
131
+	/**
132
+	 * @since 4.9.62.p
133
+	 * @throws DomainException
134
+	 * @throws DuplicateCollectionIdentifierException
135
+	 * @throws InvalidArgumentException
136
+	 * @throws InvalidDataTypeException
137
+	 * @throws InvalidEntityException
138
+	 * @throws InvalidInterfaceException
139
+	 */
140
+	public function addAssets()
141
+	{
142
+		$this->addJavascriptFiles();
143
+		$this->addStylesheetFiles();
144
+	}
145
+
146
+
147
+	/**
148
+	 * @since 4.9.62.p
149
+	 * @throws DomainException
150
+	 * @throws DuplicateCollectionIdentifierException
151
+	 * @throws InvalidArgumentException
152
+	 * @throws InvalidDataTypeException
153
+	 * @throws InvalidEntityException
154
+	 * @throws InvalidInterfaceException
155
+	 */
156
+	public function addJavascriptFiles()
157
+	{
158
+		$this->loadCoreJs();
159
+		$this->loadJqueryValidate();
160
+		$this->loadAccountingJs();
161
+		add_action(
162
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
163
+			array($this, 'loadQtipJs')
164
+		);
165
+		$this->registerAdminAssets();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @since 4.9.62.p
171
+	 * @throws DuplicateCollectionIdentifierException
172
+	 * @throws InvalidDataTypeException
173
+	 * @throws InvalidEntityException
174
+	 */
175
+	public function addStylesheetFiles()
176
+	{
177
+		$this->loadCoreCss();
178
+	}
179
+
180
+
181
+	/**
182
+	 * core default javascript
183
+	 *
184
+	 * @since 4.9.62.p
185
+	 * @throws DomainException
186
+	 * @throws DuplicateCollectionIdentifierException
187
+	 * @throws InvalidArgumentException
188
+	 * @throws InvalidDataTypeException
189
+	 * @throws InvalidEntityException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	private function loadCoreJs()
193
+	{
194
+		// conditionally load third-party libraries that WP core MIGHT have.
195
+		$this->registerWpAssets();
196
+
197
+		$this->addJavascript(
198
+			CoreAssetManager::JS_HANDLE_EE_MANIFEST,
199
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
200
+		);
201
+
202
+		$this->addJavascript(
203
+			CoreAssetManager::JS_HANDLE_EE_JS_CORE,
204
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
205
+			array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
206
+		)
207
+		->setHasInlineData();
208
+
209
+		$this->addJavascript(
210
+			CoreAssetManager::JS_HANDLE_EE_VENDOR,
211
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
212
+			array(
213
+				CoreAssetManager::JS_HANDLE_EE_JS_CORE,
214
+				CoreAssetManager::JS_HANDLE_REACT,
215
+				CoreAssetManager::JS_HANDLE_REACT_DOM,
216
+				CoreAssetManager::JS_HANDLE_LODASH,
217
+			)
218
+		);
219
+
220
+		$this->addJavascript(
221
+			CoreAssetManager::JS_HANDLE_EE_VALIDATORS,
222
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
223
+		)->setRequiresTranslation();
224
+
225
+		$this->addJavascript(
226
+			CoreAssetManager::JS_HANDLE_EE_HELPERS,
227
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
228
+			array(
229
+				CoreAssetManager::JS_HANDLE_EE_VALIDATORS
230
+			)
231
+		)->setRequiresTranslation();
232
+
233
+		$this->addJavascript(
234
+			CoreAssetManager::JS_HANDLE_EE_MODEL,
235
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
236
+			array(
237
+				CoreAssetManager::JS_HANDLE_EE_HELPERS
238
+			)
239
+		)->setRequiresTranslation();
240
+
241
+		$this->addJavascript(
242
+			CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
243
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
244
+			array(
245
+				CoreAssetManager::JS_HANDLE_EE_MODEL
246
+			)
247
+		)->setRequiresTranslation();
248
+
249
+		$this->addJavascript(
250
+			CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
251
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
252
+			array(
253
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
254
+				'wp-data',
255
+				'wp-api-request',
256
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS
257
+			)
258
+		)
259
+			 ->setRequiresTranslation();
260
+
261
+		$this->addJavascript(
262
+			CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
263
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
264
+			array(
265
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
266
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
267
+				'wp-components',
268
+			)
269
+		)->setRequiresTranslation();
270
+
271
+		$this->addJavascript(
272
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
273
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
274
+			array(
275
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
276
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
277
+				'wp-components',
278
+			)
279
+		)
280
+		->setRequiresTranslation();
281
+
282
+		$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
283
+		$this->registry->addData(
284
+			'paths',
285
+			array(
286
+				'rest_route' => rest_url('ee/v4.8.36/'),
287
+				'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
288
+				'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
289
+				'site_url' => site_url('/'),
290
+				'admin_url' => admin_url('/'),
291
+			)
292
+		);
293
+		/** site formatting values **/
294
+		$this->registry->addData(
295
+			'site_formats',
296
+			array(
297
+				'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
298
+			)
299
+		);
300
+		/** currency data **/
301
+		$this->registry->addData(
302
+			'currency_config',
303
+			$this->getCurrencySettings()
304
+		);
305
+		/** site timezone */
306
+		$this->registry->addData(
307
+			'default_timezone',
308
+			array(
309
+				'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
310
+				'string' => get_option('timezone_string'),
311
+				'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
312
+			)
313
+		);
314
+		/** site locale (user locale if user logged in) */
315
+		$this->registry->addData(
316
+			'locale',
317
+			array(
318
+				'user' => get_user_locale(),
319
+				'site' => get_locale()
320
+			)
321
+		);
322
+
323
+		$this->addJavascript(
324
+			CoreAssetManager::JS_HANDLE_EE_CORE,
325
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
326
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
327
+		)
328
+		->setInlineDataCallback(
329
+			function () {
330
+				wp_localize_script(
331
+					CoreAssetManager::JS_HANDLE_EE_CORE,
332
+					CoreAssetManager::JS_HANDLE_EE_I18N,
333
+					EE_Registry::$i18n_js_strings
334
+				);
335
+			}
336
+		);
337
+	}
338
+
339
+
340
+	/**
341
+	 * Registers vendor files that are bundled with a later version WP but might not be for the current version of
342
+	 * WordPress in the running environment.
343
+	 *
344
+	 * @throws DuplicateCollectionIdentifierException
345
+	 * @throws InvalidDataTypeException
346
+	 * @throws InvalidEntityException
347
+	 * @throws DomainException
348
+	 * @since $VID:$
349
+	 */
350
+	private function registerWpAssets()
351
+	{
352
+		global $wp_version;
353
+		if (version_compare($wp_version, '5.0.beta', '>=')) {
354
+			return;
355
+		}
356
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
357
+			->setVersion('16.6.0');
358
+		$this->addVendorJavascript(
359
+			CoreAssetManager::JS_HANDLE_REACT_DOM,
360
+			array(CoreAssetManager::JS_HANDLE_REACT)
361
+		)->setVersion('16.6.0');
362
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
363
+			->setInlineDataCallback(
364
+				function() {
365
+					wp_add_inline_script(
366
+						CoreAssetManager::JS_HANDLE_LODASH,
367
+						'window.lodash = _.noConflict();'
368
+					);
369
+				}
370
+			)
371
+			->setVersion('4.17.11');
372
+	}
373
+
374
+
375
+	/**
376
+	 * Returns configuration data for the accounting-js library.
377
+	 * @since $VID:$
378
+	 * @return array
379
+	 */
380
+	private function getAccountingSettings() {
381
+		return array(
382
+			'currency' => array(
383
+				'symbol'    => $this->currency_config->sign,
384
+				'format'    => array(
385
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
386
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
387
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
388
+				),
389
+				'decimal'   => $this->currency_config->dec_mrk,
390
+				'thousand'  => $this->currency_config->thsnds,
391
+				'precision' => $this->currency_config->dec_plc,
392
+			),
393
+			'number'   => array(
394
+				'precision' => $this->currency_config->dec_plc,
395
+				'thousand'  => $this->currency_config->thsnds,
396
+				'decimal'   => $this->currency_config->dec_mrk,
397
+			),
398
+		);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Returns configuration data for the js Currency VO.
404
+	 * @since $VID:$
405
+	 * @return array
406
+	 */
407
+	private function getCurrencySettings()
408
+	{
409
+		return array(
410
+			'code' => $this->currency_config->code,
411
+			'singularLabel' => $this->currency_config->name,
412
+			'pluralLabel' => $this->currency_config->plural,
413
+			'sign' => $this->currency_config->sign,
414
+			'signB4' => $this->currency_config->sign_b4,
415
+			'decimalPlaces' => $this->currency_config->dec_plc,
416
+			'decimalMark' => $this->currency_config->dec_mrk,
417
+			'thousandsSeparator' => $this->currency_config->thsnds,
418
+		);
419
+	}
420
+
421
+
422
+	/**
423
+	 * @since 4.9.62.p
424
+	 * @throws DuplicateCollectionIdentifierException
425
+	 * @throws InvalidDataTypeException
426
+	 * @throws InvalidEntityException
427
+	 */
428
+	private function loadCoreCss()
429
+	{
430
+		if ($this->template_config->enable_default_style && ! is_admin()) {
431
+			$this->addStylesheet(
432
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
433
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
434
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
435
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
436
+				array('dashicons')
437
+			);
438
+			//Load custom style sheet if available
439
+			if ($this->template_config->custom_style_sheet !== null) {
440
+				$this->addStylesheet(
441
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
442
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
443
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
444
+				);
445
+			}
446
+		}
447
+		$this->addStylesheet(
448
+			CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
449
+			$this->registry->getCssUrl(
450
+				$this->domain->assetNamespace(),
451
+				'components'
452
+			)
453
+		);
454
+	}
455
+
456
+
457
+	/**
458
+	 * jQuery Validate for form validation
459
+	 *
460
+	 * @since 4.9.62.p
461
+	 * @throws DomainException
462
+	 * @throws DuplicateCollectionIdentifierException
463
+	 * @throws InvalidDataTypeException
464
+	 * @throws InvalidEntityException
465
+	 */
466
+	private function loadJqueryValidate()
467
+	{
468
+		$this->addJavascript(
469
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
470
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
471
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
472
+		)
473
+		->setVersion('1.15.0');
474
+
475
+		$this->addJavascript(
476
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
477
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
478
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
479
+		)
480
+		->setVersion('1.15.0');
481
+	}
482
+
483
+
484
+	/**
485
+	 * accounting.js for performing client-side calculations
486
+	 *
487
+	 * @since 4.9.62.p
488
+	 * @throws DomainException
489
+	 * @throws DuplicateCollectionIdentifierException
490
+	 * @throws InvalidDataTypeException
491
+	 * @throws InvalidEntityException
492
+	 */
493
+	private function loadAccountingJs()
494
+	{
495
+		//accounting.js library
496
+		// @link http://josscrowcroft.github.io/accounting.js/
497
+		$this->addJavascript(
498
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
499
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
500
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
501
+		)
502
+		->setVersion('0.3.2');
503
+
504
+		$this->addJavascript(
505
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
506
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
507
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
508
+		)
509
+		->setInlineDataCallback(
510
+			function () {
511
+				 wp_localize_script(
512
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
513
+					 'EE_ACCOUNTING_CFG',
514
+					 $this->getAccountingSettings()
515
+				 );
516
+			}
517
+		)
518
+		->setVersion();
519
+	}
520
+
521
+
522
+	/**
523
+	 * registers assets for cleaning your ears
524
+	 *
525
+	 * @param JavascriptAsset $script
526
+	 */
527
+	public function loadQtipJs(JavascriptAsset $script)
528
+	{
529
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
530
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
531
+		if (
532
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
533
+			&& apply_filters('FHEE_load_qtip', false)
534
+		) {
535
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
536
+		}
537
+	}
538
+
539
+
540
+	/**
541
+	 * assets that are used in the WordPress admin
542
+	 *
543
+	 * @since 4.9.62.p
544
+	 * @throws DuplicateCollectionIdentifierException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws InvalidEntityException
547
+	 */
548
+	private function registerAdminAssets()
549
+	{
550
+		$this->addJavascript(
551
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
552
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
553
+			array(
554
+				CoreAssetManager::JS_HANDLE_JQUERY,
555
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
556
+			)
557
+		)
558
+		->setRequiresTranslation();
559
+
560
+		$this->addStylesheet(
561
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
562
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
563
+		);
564
+	}
565 565
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextDetector.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -56,6 +56,8 @@
 block discarded – undo
56 56
 
57 57
 
58 58
     /**
59
+     * @param string $globalRouteCondition
60
+     * @param boolean $default
59 61
      * @return mixed
60 62
      */
61 63
     private function getGlobalRouteCondition($globalRouteCondition, $default)
Please login to merge, or discard this patch.
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -18,171 +18,171 @@
 block discarded – undo
18 18
 class RequestTypeContextDetector
19 19
 {
20 20
 
21
-    /**
22
-     * @var RequestTypeContextFactoryInterface $factory
23
-     */
24
-    private $factory;
25
-
26
-    /**
27
-     * @var RequestInterface $request
28
-     */
29
-    private $request;
30
-
31
-    /**
32
-     * @var array $globalRouteConditions
33
-     */
34
-    private $globalRouteConditions;
35
-
36
-
37
-    /**
38
-     * RequestTypeContextDetector constructor.
39
-     *
40
-     * @param RequestInterface                   $request
41
-     * @param RequestTypeContextFactoryInterface $factory
42
-     * @param array                              $globalRouteConditions an array for injecting values that would
43
-     *                                                                  otherwise be defined as global constants
44
-     *                                                                  or other global variables for the current
45
-     *                                                                  request route such as DOING_AJAX
46
-     */
47
-    public function __construct(
48
-        RequestInterface $request,
49
-        RequestTypeContextFactoryInterface $factory,
50
-        array $globalRouteConditions = array()
51
-    ) {
52
-        $this->request = $request;
53
-        $this->factory = $factory;
54
-        $this->globalRouteConditions = $globalRouteConditions;
55
-    }
56
-
57
-
58
-    /**
59
-     * @return mixed
60
-     */
61
-    private function getGlobalRouteCondition($globalRouteCondition, $default)
62
-    {
63
-        return isset($this->globalRouteConditions[ $globalRouteCondition ])
64
-            ? $this->globalRouteConditions[ $globalRouteCondition ]
65
-            : $default;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return RequestTypeContext
71
-     * @throws InvalidArgumentException
72
-     */
73
-    public function detectRequestTypeContext()
74
-    {
75
-        // Detect error scrapes
76
-        if ($this->request->getRequestParam('wp_scrape_key') !== null
77
-            && $this->request->getRequestParam('wp_scrape_nonce') !== null
78
-        ) {
79
-            return $this->factory->create(RequestTypeContext::WP_SCRAPE);
80
-        }
81
-        // Detect EE REST API
82
-        if ($this->isEspressoRestApiRequest()) {
83
-            return $this->factory->create(RequestTypeContext::API);
84
-        }
85
-        // Detect WP REST API
86
-        if ($this->isWordPressRestApiRequest()) {
87
-            return $this->factory->create(RequestTypeContext::WP_API);
88
-        }
89
-        // Detect AJAX
90
-        if ($this->getGlobalRouteCondition('DOING_AJAX', false)) {
91
-            if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) {
92
-                return $this->factory->create(RequestTypeContext::AJAX_FRONT);
93
-            }
94
-            if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) {
95
-                return $this->factory->create(RequestTypeContext::AJAX_ADMIN);
96
-            }
97
-            return $this->factory->create(RequestTypeContext::AJAX_OTHER);
98
-        }
99
-        // Detect WP_Cron
100
-        if ($this->isCronRequest()) {
101
-            return $this->factory->create(RequestTypeContext::CRON);
102
-        }
103
-        // Detect command line requests
104
-        if ($this->getGlobalRouteCondition('WP_CLI', false)) {
105
-            return $this->factory->create(RequestTypeContext::CLI);
106
-        }
107
-        // detect WordPress admin (ie: "Dashboard")
108
-        if ($this->getGlobalRouteCondition('is_admin', false)) {
109
-            return $this->factory->create(RequestTypeContext::ADMIN);
110
-        }
111
-        // Detect iFrames
112
-        if ($this->isIframeRoute()) {
113
-            return $this->factory->create(RequestTypeContext::IFRAME);
114
-        }
115
-        // Detect Feeds
116
-        if ($this->isFeedRequest()) {
117
-            return $this->factory->create(RequestTypeContext::FEED);
118
-        }
119
-        // and by process of elimination...
120
-        return $this->factory->create(RequestTypeContext::FRONTEND);
121
-    }
122
-
123
-
124
-    /**
125
-     * @return bool
126
-     */
127
-    private function isEspressoRestApiRequest()
128
-    {
129
-        return $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE);
130
-    }
131
-
132
-
133
-
134
-    /**
135
-     * @return bool
136
-     */
137
-    private function isWordPressRestApiRequest()
138
-    {
139
-        return $this->uriPathMatches(trim(rest_get_url_prefix(), '/'));
140
-    }
141
-
142
-
143
-    /**
144
-     * @return bool
145
-     */
146
-    private function isCronRequest()
147
-    {
148
-        return $this->uriPathMatches('wp-cron.php');
149
-    }
150
-
151
-
152
-    /**
153
-     * @return bool
154
-     */
155
-    private function isFeedRequest()
156
-    {
157
-        return $this->uriPathMatches('feed');
158
-    }
159
-
160
-
161
-    /**
162
-     * @param string $component
163
-     * @return bool
164
-     */
165
-    private function uriPathMatches($component)
166
-    {
167
-        $request_uri = $this->request->requestUri();
168
-        $parts = explode('?', $request_uri);
169
-        $path = trim(reset($parts), '/');
170
-        return strpos($path, $component) === 0;
171
-    }
172
-
173
-
174
-    /**
175
-     * @return bool
176
-     */
177
-    private function isIframeRoute()
178
-    {
179
-        $is_iframe_route = apply_filters(
180
-            'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute',
181
-            $this->request->getRequestParam('event_list', '') === 'iframe'
182
-            || $this->request->getRequestParam('ticket_selector', '') === 'iframe'
183
-            || $this->request->getRequestParam('calendar', '') === 'iframe',
184
-            $this
185
-        );
186
-        return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN);
187
-    }
21
+	/**
22
+	 * @var RequestTypeContextFactoryInterface $factory
23
+	 */
24
+	private $factory;
25
+
26
+	/**
27
+	 * @var RequestInterface $request
28
+	 */
29
+	private $request;
30
+
31
+	/**
32
+	 * @var array $globalRouteConditions
33
+	 */
34
+	private $globalRouteConditions;
35
+
36
+
37
+	/**
38
+	 * RequestTypeContextDetector constructor.
39
+	 *
40
+	 * @param RequestInterface                   $request
41
+	 * @param RequestTypeContextFactoryInterface $factory
42
+	 * @param array                              $globalRouteConditions an array for injecting values that would
43
+	 *                                                                  otherwise be defined as global constants
44
+	 *                                                                  or other global variables for the current
45
+	 *                                                                  request route such as DOING_AJAX
46
+	 */
47
+	public function __construct(
48
+		RequestInterface $request,
49
+		RequestTypeContextFactoryInterface $factory,
50
+		array $globalRouteConditions = array()
51
+	) {
52
+		$this->request = $request;
53
+		$this->factory = $factory;
54
+		$this->globalRouteConditions = $globalRouteConditions;
55
+	}
56
+
57
+
58
+	/**
59
+	 * @return mixed
60
+	 */
61
+	private function getGlobalRouteCondition($globalRouteCondition, $default)
62
+	{
63
+		return isset($this->globalRouteConditions[ $globalRouteCondition ])
64
+			? $this->globalRouteConditions[ $globalRouteCondition ]
65
+			: $default;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return RequestTypeContext
71
+	 * @throws InvalidArgumentException
72
+	 */
73
+	public function detectRequestTypeContext()
74
+	{
75
+		// Detect error scrapes
76
+		if ($this->request->getRequestParam('wp_scrape_key') !== null
77
+			&& $this->request->getRequestParam('wp_scrape_nonce') !== null
78
+		) {
79
+			return $this->factory->create(RequestTypeContext::WP_SCRAPE);
80
+		}
81
+		// Detect EE REST API
82
+		if ($this->isEspressoRestApiRequest()) {
83
+			return $this->factory->create(RequestTypeContext::API);
84
+		}
85
+		// Detect WP REST API
86
+		if ($this->isWordPressRestApiRequest()) {
87
+			return $this->factory->create(RequestTypeContext::WP_API);
88
+		}
89
+		// Detect AJAX
90
+		if ($this->getGlobalRouteCondition('DOING_AJAX', false)) {
91
+			if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) {
92
+				return $this->factory->create(RequestTypeContext::AJAX_FRONT);
93
+			}
94
+			if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) {
95
+				return $this->factory->create(RequestTypeContext::AJAX_ADMIN);
96
+			}
97
+			return $this->factory->create(RequestTypeContext::AJAX_OTHER);
98
+		}
99
+		// Detect WP_Cron
100
+		if ($this->isCronRequest()) {
101
+			return $this->factory->create(RequestTypeContext::CRON);
102
+		}
103
+		// Detect command line requests
104
+		if ($this->getGlobalRouteCondition('WP_CLI', false)) {
105
+			return $this->factory->create(RequestTypeContext::CLI);
106
+		}
107
+		// detect WordPress admin (ie: "Dashboard")
108
+		if ($this->getGlobalRouteCondition('is_admin', false)) {
109
+			return $this->factory->create(RequestTypeContext::ADMIN);
110
+		}
111
+		// Detect iFrames
112
+		if ($this->isIframeRoute()) {
113
+			return $this->factory->create(RequestTypeContext::IFRAME);
114
+		}
115
+		// Detect Feeds
116
+		if ($this->isFeedRequest()) {
117
+			return $this->factory->create(RequestTypeContext::FEED);
118
+		}
119
+		// and by process of elimination...
120
+		return $this->factory->create(RequestTypeContext::FRONTEND);
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return bool
126
+	 */
127
+	private function isEspressoRestApiRequest()
128
+	{
129
+		return $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE);
130
+	}
131
+
132
+
133
+
134
+	/**
135
+	 * @return bool
136
+	 */
137
+	private function isWordPressRestApiRequest()
138
+	{
139
+		return $this->uriPathMatches(trim(rest_get_url_prefix(), '/'));
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return bool
145
+	 */
146
+	private function isCronRequest()
147
+	{
148
+		return $this->uriPathMatches('wp-cron.php');
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return bool
154
+	 */
155
+	private function isFeedRequest()
156
+	{
157
+		return $this->uriPathMatches('feed');
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param string $component
163
+	 * @return bool
164
+	 */
165
+	private function uriPathMatches($component)
166
+	{
167
+		$request_uri = $this->request->requestUri();
168
+		$parts = explode('?', $request_uri);
169
+		$path = trim(reset($parts), '/');
170
+		return strpos($path, $component) === 0;
171
+	}
172
+
173
+
174
+	/**
175
+	 * @return bool
176
+	 */
177
+	private function isIframeRoute()
178
+	{
179
+		$is_iframe_route = apply_filters(
180
+			'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute',
181
+			$this->request->getRequestParam('event_list', '') === 'iframe'
182
+			|| $this->request->getRequestParam('ticket_selector', '') === 'iframe'
183
+			|| $this->request->getRequestParam('calendar', '') === 'iframe',
184
+			$this
185
+		);
186
+		return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN);
187
+	}
188 188
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function getGlobalRouteCondition($globalRouteCondition, $default)
62 62
     {
63
-        return isset($this->globalRouteConditions[ $globalRouteCondition ])
64
-            ? $this->globalRouteConditions[ $globalRouteCondition ]
63
+        return isset($this->globalRouteConditions[$globalRouteCondition])
64
+            ? $this->globalRouteConditions[$globalRouteCondition]
65 65
             : $default;
66 66
     }
67 67
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     private function isEspressoRestApiRequest()
128 128
     {
129
-        return $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE);
129
+        return $this->uriPathMatches(trim(rest_get_url_prefix(), '/').'/'.Domain::API_NAMESPACE);
130 130
     }
131 131
 
132 132
 
Please login to merge, or discard this patch.
admin_pages/venues/templates/event_venues_metabox_content.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@
 block discarded – undo
5 5
                 <?php echo $no_venues_info; ?>
6 6
                 <p><a href="admin.php?page=espresso_venues" target="_blank">
7 7
                         <?php echo __(
8
-                            'Add venues to the Venue Manager',
9
-                            'event_espresso'
10
-                        ) ?></a></p>
8
+							'Add venues to the Venue Manager',
9
+							'event_espresso'
10
+						) ?></a></p>
11 11
             </fieldset>
12 12
         </td>
13 13
     </tr>
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 2 patches
Indentation   +752 added lines, -752 removed lines patch added patch discarded remove patch
@@ -15,757 +15,757 @@
 block discarded – undo
15 15
 class EE_Datetime_Field extends EE_Model_Field_Base
16 16
 {
17 17
 
18
-    /**
19
-     * The pattern we're looking for is if only the characters 0-9 are found and there are only
20
-     * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
21
-     *
22
-     * @type string unix_timestamp_regex
23
-     */
24
-    const unix_timestamp_regex = '/[0-9]{10,}/';
25
-
26
-    /**
27
-     * @type string mysql_timestamp_format
28
-     */
29
-    const mysql_timestamp_format = 'Y-m-d H:i:s';
30
-
31
-    /**
32
-     * @type string mysql_date_format
33
-     */
34
-    const mysql_date_format = 'Y-m-d';
35
-
36
-    /**
37
-     * @type string mysql_time_format
38
-     */
39
-    const mysql_time_format = 'H:i:s';
40
-
41
-    /**
42
-     * Const for using in the default value. If the field's default is set to this,
43
-     * then we will return the time of calling `get_default_value()`, not
44
-     * just the current time at construction
45
-     */
46
-    const now = 'now';
47
-
48
-    /**
49
-     * The following properties hold the default formats for date and time.
50
-     * Defaults are set via the constructor and can be overridden on class instantiation.
51
-     * However they can also be overridden later by the set_format() method
52
-     * (and corresponding set_date_format, set_time_format methods);
53
-     */
54
-    /**
55
-     * @type string $_date_format
56
-     */
57
-    protected $_date_format = '';
58
-
59
-    /**
60
-     * @type string $_time_format
61
-     */
62
-    protected $_time_format = '';
63
-
64
-    /**
65
-     * @type string $_pretty_date_format
66
-     */
67
-    protected $_pretty_date_format = '';
68
-
69
-    /**
70
-     * @type string $_pretty_time_format
71
-     */
72
-    protected $_pretty_time_format = '';
73
-
74
-    /**
75
-     * @type DateTimeZone $_DateTimeZone
76
-     */
77
-    protected $_DateTimeZone;
78
-
79
-    /**
80
-     * @type DateTimeZone $_UTC_DateTimeZone
81
-     */
82
-    protected $_UTC_DateTimeZone;
83
-
84
-    /**
85
-     * @type DateTimeZone $_blog_DateTimeZone
86
-     */
87
-    protected $_blog_DateTimeZone;
88
-
89
-
90
-    /**
91
-     * This property holds how we want the output returned when getting a datetime string.  It is set for the
92
-     * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
93
-     * and time returned via getters.
94
-     *
95
-     * @var mixed (null|string)
96
-     */
97
-    protected $_date_time_output;
98
-
99
-
100
-    /**
101
-     * timezone string
102
-     * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
103
-     * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
104
-     * coming out of the object to be in.  Default timezone is the current WP timezone option setting
105
-     *
106
-     * @var string
107
-     */
108
-    protected $_timezone_string;
109
-
110
-
111
-    /**
112
-     * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
113
-     * offsets for comparison purposes).
114
-     *
115
-     * @var int
116
-     */
117
-    protected $_blog_offset;
118
-
119
-
120
-
121
-    /**
122
-     * @param string $table_column
123
-     * @param string $nice_name
124
-     * @param bool   $nullable
125
-     * @param string $default_value
126
-     * @param string $timezone_string
127
-     * @param string $date_format
128
-     * @param string $time_format
129
-     * @param string $pretty_date_format
130
-     * @param string $pretty_time_format
131
-     * @throws EE_Error
132
-     * @throws InvalidArgumentException
133
-     */
134
-    public function __construct(
135
-        $table_column,
136
-        $nice_name,
137
-        $nullable,
138
-        $default_value,
139
-        $timezone_string = '',
140
-        $date_format = '',
141
-        $time_format = '',
142
-        $pretty_date_format = '',
143
-        $pretty_time_format = ''
144
-    ) {
145
-
146
-        $this->_date_format        = ! empty($date_format) ? $date_format : get_option('date_format');
147
-        $this->_time_format        = ! empty($time_format) ? $time_format : get_option('time_format');
148
-        $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
149
-        $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
150
-
151
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
152
-        $this->set_timezone($timezone_string);
153
-        $this->setSchemaFormat('date-time');
154
-    }
155
-
156
-
157
-    /**
158
-     * @return DateTimeZone
159
-     * @throws \EE_Error
160
-     */
161
-    public function get_UTC_DateTimeZone()
162
-    {
163
-        return $this->_UTC_DateTimeZone instanceof DateTimeZone
164
-            ? $this->_UTC_DateTimeZone
165
-            : $this->_create_timezone_object_from_timezone_string('UTC');
166
-    }
167
-
168
-
169
-    /**
170
-     * @return DateTimeZone
171
-     * @throws \EE_Error
172
-     */
173
-    public function get_blog_DateTimeZone()
174
-    {
175
-        return $this->_blog_DateTimeZone instanceof DateTimeZone
176
-            ? $this->_blog_DateTimeZone
177
-            : $this->_create_timezone_object_from_timezone_string('');
178
-    }
179
-
180
-
181
-    /**
182
-     * this prepares any incoming date data and make sure its converted to a utc unix timestamp
183
-     *
184
-     * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix
185
-     *                                                              timestamp
186
-     * @return DateTime
187
-     */
188
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
189
-    {
190
-        return $this->_get_date_object($value_inputted_for_field_on_model_object);
191
-    }
192
-
193
-
194
-    /**
195
-     * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
196
-     * getters need to know whether we're just returning the date or the time or both.  By default we return both.
197
-     *
198
-     * @param bool $pretty If we're returning the pretty formats or standard format string.
199
-     * @return string    The final assembled format string.
200
-     */
201
-    protected function _get_date_time_output($pretty = false)
202
-    {
203
-
204
-        switch ($this->_date_time_output) {
205
-            case 'time':
206
-                return $pretty ? $this->_pretty_time_format : $this->_time_format;
207
-                break;
208
-
209
-            case 'date':
210
-                return $pretty ? $this->_pretty_date_format : $this->_date_format;
211
-                break;
212
-
213
-            default:
214
-                return $pretty
215
-                    ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format
216
-                    : $this->_date_format . ' ' . $this->_time_format;
217
-        }
218
-    }
219
-
220
-
221
-    /**
222
-     * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
223
-     * returned (using the format properties)
224
-     *
225
-     * @param string $what acceptable values are 'time' or 'date'.
226
-     *                     Any other value will be set but will always result
227
-     *                     in both 'date' and 'time' being returned.
228
-     * @return void
229
-     */
230
-    public function set_date_time_output($what = null)
231
-    {
232
-        $this->_date_time_output = $what;
233
-    }
234
-
235
-
236
-    /**
237
-     * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
238
-     * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
239
-     * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
240
-     * We also set some other properties in this method.
241
-     *
242
-     * @param string $timezone_string A valid timezone string as described by @link
243
-     *                                http://www.php.net/manual/en/timezones.php
244
-     * @return void
245
-     * @throws InvalidArgumentException
246
-     * @throws InvalidDataTypeException
247
-     * @throws InvalidInterfaceException
248
-     */
249
-    public function set_timezone($timezone_string)
250
-    {
251
-        if (empty($timezone_string) && $this->_timezone_string !== null) {
252
-            // leave the timezone AS-IS if we already have one and
253
-            // the function arg didn't provide one
254
-            return;
255
-        }
256
-        $timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
257
-        $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
258
-        $this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
259
-    }
260
-
261
-
262
-    /**
263
-     * _create_timezone_object_from_timezone_name
264
-     *
265
-     * @access protected
266
-     * @param string $timezone_string
267
-     * @return \DateTimeZone
268
-     * @throws InvalidArgumentException
269
-     * @throws InvalidDataTypeException
270
-     * @throws InvalidInterfaceException
271
-     */
272
-    protected function _create_timezone_object_from_timezone_string($timezone_string = '')
273
-    {
274
-        return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
275
-    }
276
-
277
-
278
-    /**
279
-     * This just returns whatever is set for the current timezone.
280
-     *
281
-     * @access public
282
-     * @return string timezone string
283
-     */
284
-    public function get_timezone()
285
-    {
286
-        return $this->_timezone_string;
287
-    }
288
-
289
-
290
-    /**
291
-     * set the $_date_format property
292
-     *
293
-     * @access public
294
-     * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
295
-     * @param bool   $pretty Whether to set pretty format or not.
296
-     * @return void
297
-     */
298
-    public function set_date_format($format, $pretty = false)
299
-    {
300
-        if ($pretty) {
301
-            $this->_pretty_date_format = $format;
302
-        } else {
303
-            $this->_date_format = $format;
304
-        }
305
-    }
306
-
307
-
308
-    /**
309
-     * return the $_date_format property value.
310
-     *
311
-     * @param bool $pretty Whether to get pretty format or not.
312
-     * @return string
313
-     */
314
-    public function get_date_format($pretty = false)
315
-    {
316
-        return $pretty ? $this->_pretty_date_format : $this->_date_format;
317
-    }
318
-
319
-
320
-    /**
321
-     * set the $_time_format property
322
-     *
323
-     * @access public
324
-     * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
325
-     * @param bool   $pretty Whether to set pretty format or not.
326
-     * @return void
327
-     */
328
-    public function set_time_format($format, $pretty = false)
329
-    {
330
-        if ($pretty) {
331
-            $this->_pretty_time_format = $format;
332
-        } else {
333
-            $this->_time_format = $format;
334
-        }
335
-    }
336
-
337
-
338
-    /**
339
-     * return the $_time_format property value.
340
-     *
341
-     * @param bool $pretty Whether to get pretty format or not.
342
-     * @return string
343
-     */
344
-    public function get_time_format($pretty = false)
345
-    {
346
-        return $pretty ? $this->_pretty_time_format : $this->_time_format;
347
-    }
348
-
349
-
350
-    /**
351
-     * set the $_pretty_date_format property
352
-     *
353
-     * @access public
354
-     * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
355
-     * @return void
356
-     */
357
-    public function set_pretty_date_format($format)
358
-    {
359
-        $this->_pretty_date_format = $format;
360
-    }
361
-
362
-
363
-    /**
364
-     * set the $_pretty_time_format property
365
-     *
366
-     * @access public
367
-     * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
368
-     * @return void
369
-     */
370
-    public function set_pretty_time_format($format)
371
-    {
372
-        $this->_pretty_time_format = $format;
373
-    }
374
-
375
-
376
-    /**
377
-     * Only sets the time portion of the datetime.
378
-     *
379
-     * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
380
-     * @param DateTime        $current            current DateTime object for the datetime field
381
-     * @return DateTime
382
-     */
383
-    public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current)
384
-    {
385
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
386
-        // Otherwise parse the string.
387
-        if ($time_to_set_string instanceof DateTime) {
388
-            $parsed = array(
389
-                'hour'   => $time_to_set_string->format('H'),
390
-                'minute' => $time_to_set_string->format('i'),
391
-                'second' => $time_to_set_string->format('s'),
392
-            );
393
-        } else {
394
-            // parse incoming string
395
-            $parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
396
-        }
397
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
398
-        return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
399
-    }
400
-
401
-
402
-    /**
403
-     * Only sets the date portion of the datetime.
404
-     *
405
-     * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
406
-     * @param DateTime        $current            current DateTime object for the datetime field
407
-     * @return DateTime
408
-     */
409
-    public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current)
410
-    {
411
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
412
-        // Otherwise parse the string.
413
-        if ($date_to_set_string instanceof DateTime) {
414
-            $parsed = array(
415
-                'year'  => $date_to_set_string->format('Y'),
416
-                'month' => $date_to_set_string->format('m'),
417
-                'day'   => $date_to_set_string->format('d'),
418
-            );
419
-        } else {
420
-            // parse incoming string
421
-            $parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
422
-        }
423
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
424
-        return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
425
-    }
426
-
427
-
428
-    /**
429
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
430
-     * datetime gets to this stage it should ALREADY be in UTC time
431
-     *
432
-     * @param  DateTime $DateTime
433
-     * @return string formatted date time for given timezone
434
-     * @throws \EE_Error
435
-     */
436
-    public function prepare_for_get($DateTime)
437
-    {
438
-        return $this->_prepare_for_display($DateTime);
439
-    }
440
-
441
-
442
-    /**
443
-     * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
444
-     * from the set wp timezone.  If so, then it returns the datetime string formatted via
445
-     * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
446
-     * abbreviation to the date_string.
447
-     *
448
-     * @param mixed $DateTime
449
-     * @param null  $schema
450
-     * @return string
451
-     * @throws \EE_Error
452
-     */
453
-    public function prepare_for_pretty_echoing($DateTime, $schema = null)
454
-    {
455
-        return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
456
-    }
457
-
458
-
459
-    /**
460
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
461
-     * timezone).
462
-     *
463
-     * @param DateTime    $DateTime
464
-     * @param bool|string $schema
465
-     * @return string
466
-     * @throws \EE_Error
467
-     */
468
-    protected function _prepare_for_display($DateTime, $schema = false)
469
-    {
470
-        if (! $DateTime instanceof DateTime) {
471
-            if ($this->_nullable) {
472
-                return '';
473
-            } else {
474
-                if (WP_DEBUG) {
475
-                    throw new EE_Error(
476
-                        sprintf(
477
-                            __(
478
-                                'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
479
-                                'event_espresso'
480
-                            ),
481
-                            $this->_nicename
482
-                        )
483
-                    );
484
-                } else {
485
-                    $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now);
486
-                    EE_Error::add_error(
487
-                        sprintf(
488
-                            __(
489
-                                'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
490
-                                'event_espresso'
491
-                            ),
492
-                            $this->_nicename
493
-                        )
494
-                    );
495
-                }
496
-            }
497
-        }
498
-        $format_string = $this->_get_date_time_output($schema);
499
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
500
-        if ($schema) {
501
-            if ($this->_display_timezone()) {
502
-                // must be explicit because schema could equal true.
503
-                if ($schema === 'no_html') {
504
-                    $timezone_string = ' (' . $DateTime->format('T') . ')';
505
-                } else {
506
-                    $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
507
-                }
508
-            } else {
509
-                $timezone_string = '';
510
-            }
511
-
512
-            return $DateTime->format($format_string) . $timezone_string;
513
-        }
514
-        return $DateTime->format($format_string);
515
-    }
516
-
517
-
518
-    /**
519
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
520
-     * timezone).
521
-     *
522
-     * @param  mixed $datetime_value u
523
-     * @return string mysql timestamp in UTC
524
-     * @throws \EE_Error
525
-     */
526
-    public function prepare_for_use_in_db($datetime_value)
527
-    {
528
-        // we allow an empty value or DateTime object, but nothing else.
529
-        if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
530
-            throw new EE_Error(
531
-                sprintf(
532
-                    __(
533
-                        'The incoming value being prepared for setting in the database must either be empty or a php 
18
+	/**
19
+	 * The pattern we're looking for is if only the characters 0-9 are found and there are only
20
+	 * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
21
+	 *
22
+	 * @type string unix_timestamp_regex
23
+	 */
24
+	const unix_timestamp_regex = '/[0-9]{10,}/';
25
+
26
+	/**
27
+	 * @type string mysql_timestamp_format
28
+	 */
29
+	const mysql_timestamp_format = 'Y-m-d H:i:s';
30
+
31
+	/**
32
+	 * @type string mysql_date_format
33
+	 */
34
+	const mysql_date_format = 'Y-m-d';
35
+
36
+	/**
37
+	 * @type string mysql_time_format
38
+	 */
39
+	const mysql_time_format = 'H:i:s';
40
+
41
+	/**
42
+	 * Const for using in the default value. If the field's default is set to this,
43
+	 * then we will return the time of calling `get_default_value()`, not
44
+	 * just the current time at construction
45
+	 */
46
+	const now = 'now';
47
+
48
+	/**
49
+	 * The following properties hold the default formats for date and time.
50
+	 * Defaults are set via the constructor and can be overridden on class instantiation.
51
+	 * However they can also be overridden later by the set_format() method
52
+	 * (and corresponding set_date_format, set_time_format methods);
53
+	 */
54
+	/**
55
+	 * @type string $_date_format
56
+	 */
57
+	protected $_date_format = '';
58
+
59
+	/**
60
+	 * @type string $_time_format
61
+	 */
62
+	protected $_time_format = '';
63
+
64
+	/**
65
+	 * @type string $_pretty_date_format
66
+	 */
67
+	protected $_pretty_date_format = '';
68
+
69
+	/**
70
+	 * @type string $_pretty_time_format
71
+	 */
72
+	protected $_pretty_time_format = '';
73
+
74
+	/**
75
+	 * @type DateTimeZone $_DateTimeZone
76
+	 */
77
+	protected $_DateTimeZone;
78
+
79
+	/**
80
+	 * @type DateTimeZone $_UTC_DateTimeZone
81
+	 */
82
+	protected $_UTC_DateTimeZone;
83
+
84
+	/**
85
+	 * @type DateTimeZone $_blog_DateTimeZone
86
+	 */
87
+	protected $_blog_DateTimeZone;
88
+
89
+
90
+	/**
91
+	 * This property holds how we want the output returned when getting a datetime string.  It is set for the
92
+	 * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
93
+	 * and time returned via getters.
94
+	 *
95
+	 * @var mixed (null|string)
96
+	 */
97
+	protected $_date_time_output;
98
+
99
+
100
+	/**
101
+	 * timezone string
102
+	 * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
103
+	 * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
104
+	 * coming out of the object to be in.  Default timezone is the current WP timezone option setting
105
+	 *
106
+	 * @var string
107
+	 */
108
+	protected $_timezone_string;
109
+
110
+
111
+	/**
112
+	 * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
113
+	 * offsets for comparison purposes).
114
+	 *
115
+	 * @var int
116
+	 */
117
+	protected $_blog_offset;
118
+
119
+
120
+
121
+	/**
122
+	 * @param string $table_column
123
+	 * @param string $nice_name
124
+	 * @param bool   $nullable
125
+	 * @param string $default_value
126
+	 * @param string $timezone_string
127
+	 * @param string $date_format
128
+	 * @param string $time_format
129
+	 * @param string $pretty_date_format
130
+	 * @param string $pretty_time_format
131
+	 * @throws EE_Error
132
+	 * @throws InvalidArgumentException
133
+	 */
134
+	public function __construct(
135
+		$table_column,
136
+		$nice_name,
137
+		$nullable,
138
+		$default_value,
139
+		$timezone_string = '',
140
+		$date_format = '',
141
+		$time_format = '',
142
+		$pretty_date_format = '',
143
+		$pretty_time_format = ''
144
+	) {
145
+
146
+		$this->_date_format        = ! empty($date_format) ? $date_format : get_option('date_format');
147
+		$this->_time_format        = ! empty($time_format) ? $time_format : get_option('time_format');
148
+		$this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
149
+		$this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
150
+
151
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
152
+		$this->set_timezone($timezone_string);
153
+		$this->setSchemaFormat('date-time');
154
+	}
155
+
156
+
157
+	/**
158
+	 * @return DateTimeZone
159
+	 * @throws \EE_Error
160
+	 */
161
+	public function get_UTC_DateTimeZone()
162
+	{
163
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone
164
+			? $this->_UTC_DateTimeZone
165
+			: $this->_create_timezone_object_from_timezone_string('UTC');
166
+	}
167
+
168
+
169
+	/**
170
+	 * @return DateTimeZone
171
+	 * @throws \EE_Error
172
+	 */
173
+	public function get_blog_DateTimeZone()
174
+	{
175
+		return $this->_blog_DateTimeZone instanceof DateTimeZone
176
+			? $this->_blog_DateTimeZone
177
+			: $this->_create_timezone_object_from_timezone_string('');
178
+	}
179
+
180
+
181
+	/**
182
+	 * this prepares any incoming date data and make sure its converted to a utc unix timestamp
183
+	 *
184
+	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix
185
+	 *                                                              timestamp
186
+	 * @return DateTime
187
+	 */
188
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
189
+	{
190
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
191
+	}
192
+
193
+
194
+	/**
195
+	 * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
196
+	 * getters need to know whether we're just returning the date or the time or both.  By default we return both.
197
+	 *
198
+	 * @param bool $pretty If we're returning the pretty formats or standard format string.
199
+	 * @return string    The final assembled format string.
200
+	 */
201
+	protected function _get_date_time_output($pretty = false)
202
+	{
203
+
204
+		switch ($this->_date_time_output) {
205
+			case 'time':
206
+				return $pretty ? $this->_pretty_time_format : $this->_time_format;
207
+				break;
208
+
209
+			case 'date':
210
+				return $pretty ? $this->_pretty_date_format : $this->_date_format;
211
+				break;
212
+
213
+			default:
214
+				return $pretty
215
+					? $this->_pretty_date_format . ' ' . $this->_pretty_time_format
216
+					: $this->_date_format . ' ' . $this->_time_format;
217
+		}
218
+	}
219
+
220
+
221
+	/**
222
+	 * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
223
+	 * returned (using the format properties)
224
+	 *
225
+	 * @param string $what acceptable values are 'time' or 'date'.
226
+	 *                     Any other value will be set but will always result
227
+	 *                     in both 'date' and 'time' being returned.
228
+	 * @return void
229
+	 */
230
+	public function set_date_time_output($what = null)
231
+	{
232
+		$this->_date_time_output = $what;
233
+	}
234
+
235
+
236
+	/**
237
+	 * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
238
+	 * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
239
+	 * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
240
+	 * We also set some other properties in this method.
241
+	 *
242
+	 * @param string $timezone_string A valid timezone string as described by @link
243
+	 *                                http://www.php.net/manual/en/timezones.php
244
+	 * @return void
245
+	 * @throws InvalidArgumentException
246
+	 * @throws InvalidDataTypeException
247
+	 * @throws InvalidInterfaceException
248
+	 */
249
+	public function set_timezone($timezone_string)
250
+	{
251
+		if (empty($timezone_string) && $this->_timezone_string !== null) {
252
+			// leave the timezone AS-IS if we already have one and
253
+			// the function arg didn't provide one
254
+			return;
255
+		}
256
+		$timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
257
+		$this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
258
+		$this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
259
+	}
260
+
261
+
262
+	/**
263
+	 * _create_timezone_object_from_timezone_name
264
+	 *
265
+	 * @access protected
266
+	 * @param string $timezone_string
267
+	 * @return \DateTimeZone
268
+	 * @throws InvalidArgumentException
269
+	 * @throws InvalidDataTypeException
270
+	 * @throws InvalidInterfaceException
271
+	 */
272
+	protected function _create_timezone_object_from_timezone_string($timezone_string = '')
273
+	{
274
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
275
+	}
276
+
277
+
278
+	/**
279
+	 * This just returns whatever is set for the current timezone.
280
+	 *
281
+	 * @access public
282
+	 * @return string timezone string
283
+	 */
284
+	public function get_timezone()
285
+	{
286
+		return $this->_timezone_string;
287
+	}
288
+
289
+
290
+	/**
291
+	 * set the $_date_format property
292
+	 *
293
+	 * @access public
294
+	 * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
295
+	 * @param bool   $pretty Whether to set pretty format or not.
296
+	 * @return void
297
+	 */
298
+	public function set_date_format($format, $pretty = false)
299
+	{
300
+		if ($pretty) {
301
+			$this->_pretty_date_format = $format;
302
+		} else {
303
+			$this->_date_format = $format;
304
+		}
305
+	}
306
+
307
+
308
+	/**
309
+	 * return the $_date_format property value.
310
+	 *
311
+	 * @param bool $pretty Whether to get pretty format or not.
312
+	 * @return string
313
+	 */
314
+	public function get_date_format($pretty = false)
315
+	{
316
+		return $pretty ? $this->_pretty_date_format : $this->_date_format;
317
+	}
318
+
319
+
320
+	/**
321
+	 * set the $_time_format property
322
+	 *
323
+	 * @access public
324
+	 * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
325
+	 * @param bool   $pretty Whether to set pretty format or not.
326
+	 * @return void
327
+	 */
328
+	public function set_time_format($format, $pretty = false)
329
+	{
330
+		if ($pretty) {
331
+			$this->_pretty_time_format = $format;
332
+		} else {
333
+			$this->_time_format = $format;
334
+		}
335
+	}
336
+
337
+
338
+	/**
339
+	 * return the $_time_format property value.
340
+	 *
341
+	 * @param bool $pretty Whether to get pretty format or not.
342
+	 * @return string
343
+	 */
344
+	public function get_time_format($pretty = false)
345
+	{
346
+		return $pretty ? $this->_pretty_time_format : $this->_time_format;
347
+	}
348
+
349
+
350
+	/**
351
+	 * set the $_pretty_date_format property
352
+	 *
353
+	 * @access public
354
+	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
355
+	 * @return void
356
+	 */
357
+	public function set_pretty_date_format($format)
358
+	{
359
+		$this->_pretty_date_format = $format;
360
+	}
361
+
362
+
363
+	/**
364
+	 * set the $_pretty_time_format property
365
+	 *
366
+	 * @access public
367
+	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
368
+	 * @return void
369
+	 */
370
+	public function set_pretty_time_format($format)
371
+	{
372
+		$this->_pretty_time_format = $format;
373
+	}
374
+
375
+
376
+	/**
377
+	 * Only sets the time portion of the datetime.
378
+	 *
379
+	 * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
380
+	 * @param DateTime        $current            current DateTime object for the datetime field
381
+	 * @return DateTime
382
+	 */
383
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current)
384
+	{
385
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
386
+		// Otherwise parse the string.
387
+		if ($time_to_set_string instanceof DateTime) {
388
+			$parsed = array(
389
+				'hour'   => $time_to_set_string->format('H'),
390
+				'minute' => $time_to_set_string->format('i'),
391
+				'second' => $time_to_set_string->format('s'),
392
+			);
393
+		} else {
394
+			// parse incoming string
395
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
396
+		}
397
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
398
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Only sets the date portion of the datetime.
404
+	 *
405
+	 * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
406
+	 * @param DateTime        $current            current DateTime object for the datetime field
407
+	 * @return DateTime
408
+	 */
409
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current)
410
+	{
411
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
412
+		// Otherwise parse the string.
413
+		if ($date_to_set_string instanceof DateTime) {
414
+			$parsed = array(
415
+				'year'  => $date_to_set_string->format('Y'),
416
+				'month' => $date_to_set_string->format('m'),
417
+				'day'   => $date_to_set_string->format('d'),
418
+			);
419
+		} else {
420
+			// parse incoming string
421
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
422
+		}
423
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
424
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
425
+	}
426
+
427
+
428
+	/**
429
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
430
+	 * datetime gets to this stage it should ALREADY be in UTC time
431
+	 *
432
+	 * @param  DateTime $DateTime
433
+	 * @return string formatted date time for given timezone
434
+	 * @throws \EE_Error
435
+	 */
436
+	public function prepare_for_get($DateTime)
437
+	{
438
+		return $this->_prepare_for_display($DateTime);
439
+	}
440
+
441
+
442
+	/**
443
+	 * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
444
+	 * from the set wp timezone.  If so, then it returns the datetime string formatted via
445
+	 * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
446
+	 * abbreviation to the date_string.
447
+	 *
448
+	 * @param mixed $DateTime
449
+	 * @param null  $schema
450
+	 * @return string
451
+	 * @throws \EE_Error
452
+	 */
453
+	public function prepare_for_pretty_echoing($DateTime, $schema = null)
454
+	{
455
+		return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
456
+	}
457
+
458
+
459
+	/**
460
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
461
+	 * timezone).
462
+	 *
463
+	 * @param DateTime    $DateTime
464
+	 * @param bool|string $schema
465
+	 * @return string
466
+	 * @throws \EE_Error
467
+	 */
468
+	protected function _prepare_for_display($DateTime, $schema = false)
469
+	{
470
+		if (! $DateTime instanceof DateTime) {
471
+			if ($this->_nullable) {
472
+				return '';
473
+			} else {
474
+				if (WP_DEBUG) {
475
+					throw new EE_Error(
476
+						sprintf(
477
+							__(
478
+								'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
479
+								'event_espresso'
480
+							),
481
+							$this->_nicename
482
+						)
483
+					);
484
+				} else {
485
+					$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now);
486
+					EE_Error::add_error(
487
+						sprintf(
488
+							__(
489
+								'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
490
+								'event_espresso'
491
+							),
492
+							$this->_nicename
493
+						)
494
+					);
495
+				}
496
+			}
497
+		}
498
+		$format_string = $this->_get_date_time_output($schema);
499
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
500
+		if ($schema) {
501
+			if ($this->_display_timezone()) {
502
+				// must be explicit because schema could equal true.
503
+				if ($schema === 'no_html') {
504
+					$timezone_string = ' (' . $DateTime->format('T') . ')';
505
+				} else {
506
+					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
507
+				}
508
+			} else {
509
+				$timezone_string = '';
510
+			}
511
+
512
+			return $DateTime->format($format_string) . $timezone_string;
513
+		}
514
+		return $DateTime->format($format_string);
515
+	}
516
+
517
+
518
+	/**
519
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
520
+	 * timezone).
521
+	 *
522
+	 * @param  mixed $datetime_value u
523
+	 * @return string mysql timestamp in UTC
524
+	 * @throws \EE_Error
525
+	 */
526
+	public function prepare_for_use_in_db($datetime_value)
527
+	{
528
+		// we allow an empty value or DateTime object, but nothing else.
529
+		if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
530
+			throw new EE_Error(
531
+				sprintf(
532
+					__(
533
+						'The incoming value being prepared for setting in the database must either be empty or a php 
534 534
             		    DateTime object, instead of: %1$s %2$s',
535
-                        'event_espresso'
536
-                    ),
537
-                    '<br />',
538
-                    print_r($datetime_value, true)
539
-                )
540
-            );
541
-        }
542
-
543
-        if ($datetime_value instanceof DateTime) {
544
-            if (! $datetime_value instanceof DbSafeDateTime) {
545
-                $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
546
-            }
547
-            EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
548
-            return $datetime_value->format(
549
-                EE_Datetime_Field::mysql_timestamp_format
550
-            );
551
-        }
552
-
553
-        // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
554
-        return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
555
-    }
556
-
557
-
558
-    /**
559
-     * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
560
-     * allowed)
561
-     *
562
-     * @param string $datetime_string mysql timestamp in UTC
563
-     * @return  mixed null | DateTime
564
-     * @throws \EE_Error
565
-     */
566
-    public function prepare_for_set_from_db($datetime_string)
567
-    {
568
-        // if $datetime_value is empty, and ! $this->_nullable, just use time()
569
-        if (empty($datetime_string) && $this->_nullable) {
570
-            return null;
571
-        }
572
-        // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
573
-        if (empty($datetime_string)) {
574
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
575
-        } else {
576
-            $DateTime = DbSafeDateTime::createFromFormat(
577
-                EE_Datetime_Field::mysql_timestamp_format,
578
-                $datetime_string,
579
-                $this->get_UTC_DateTimeZone()
580
-            );
581
-        }
582
-
583
-        if (! $DateTime instanceof DbSafeDateTime) {
584
-            // if still no datetime object, then let's just use now
585
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
586
-        }
587
-        // THEN apply the field's set DateTimeZone
588
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
589
-        return $DateTime;
590
-    }
591
-
592
-
593
-    /**
594
-     * All this method does is determine if we're going to display the timezone string or not on any output.
595
-     * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
596
-     * If so, then true.
597
-     *
598
-     * @return bool true for yes false for no
599
-     * @throws \EE_Error
600
-     */
601
-    protected function _display_timezone()
602
-    {
603
-
604
-        // first let's do a comparison of timezone strings.
605
-        // If they match then we can get out without any further calculations
606
-        $blog_string = get_option('timezone_string');
607
-        if ($blog_string === $this->_timezone_string) {
608
-            return false;
609
-        }
610
-        // now we need to calc the offset for the timezone string so we can compare with the blog offset.
611
-        $this_offset = $this->get_timezone_offset($this->_DateTimeZone);
612
-        $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
613
-        // now compare
614
-        return $blog_offset !== $this_offset;
615
-    }
616
-
617
-
618
-    /**
619
-     * This method returns a php DateTime object for setting on the EE_Base_Class model.
620
-     * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
621
-     * with.
622
-     *
623
-     * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
624
-     *                                                    in the format that is set on the date_field (or DateTime
625
-     *                                                    object)!
626
-     * @return DateTime
627
-     */
628
-    protected function _get_date_object($date_string)
629
-    {
630
-        // first if this is an empty date_string and nullable is allowed, just return null.
631
-        if ($this->_nullable && empty($date_string)) {
632
-            return null;
633
-        }
634
-
635
-        // if incoming date
636
-        if ($date_string instanceof DateTime) {
637
-            EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
638
-            return $date_string;
639
-        }
640
-        // if empty date_string and made it here.
641
-        // Return a datetime object for now in the given timezone.
642
-        if (empty($date_string)) {
643
-            return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
644
-        }
645
-        // if $date_string is matches something that looks like a Unix timestamp let's just use it.
646
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
647
-            try {
648
-                // This is operating under the assumption that the incoming Unix timestamp
649
-                // is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
650
-                $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
651
-                $DateTime->setTimestamp($date_string);
652
-
653
-                return $DateTime;
654
-            } catch (Exception $e) {
655
-                // should be rare, but if things got fooled then let's just continue
656
-            }
657
-        }
658
-        // not a unix timestamp.  So we will use the set format on this object and set timezone to
659
-        // create the DateTime object.
660
-        $format = $this->_date_format . ' ' . $this->_time_format;
661
-        try {
662
-            $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
663
-            if (! $DateTime instanceof DbSafeDateTime) {
664
-                throw new EE_Error(
665
-                    sprintf(
666
-                        __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
667
-                        $date_string,
668
-                        $format
669
-                    )
670
-                );
671
-            }
672
-        } catch (Exception $e) {
673
-            // if we made it here then likely then something went really wrong.
674
-            // Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
675
-            $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
676
-        }
677
-
678
-        return $DateTime;
679
-    }
680
-
681
-
682
-
683
-    /**
684
-     * get_timezone_transitions
685
-     *
686
-     * @param \DateTimeZone $DateTimeZone
687
-     * @param int           $time
688
-     * @param bool          $first_only
689
-     * @return mixed
690
-     */
691
-    public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true)
692
-    {
693
-        return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
694
-    }
695
-
696
-
697
-
698
-    /**
699
-     * get_timezone_offset
700
-     *
701
-     * @param \DateTimeZone $DateTimeZone
702
-     * @param int           $time
703
-     * @return mixed
704
-     * @throws \DomainException
705
-     */
706
-    public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
707
-    {
708
-        return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
709
-    }
710
-
711
-
712
-    /**
713
-     * This will take an incoming timezone string and return the abbreviation for that timezone
714
-     *
715
-     * @param  string $timezone_string
716
-     * @return string           abbreviation
717
-     * @throws \EE_Error
718
-     */
719
-    public function get_timezone_abbrev($timezone_string)
720
-    {
721
-        $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
722
-        $dateTime        = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string));
723
-
724
-        return $dateTime->format('T');
725
-    }
726
-
727
-    /**
728
-     * Overrides the parent to allow for having a dynamic "now" value
729
-     *
730
-     * @return mixed
731
-     */
732
-    public function get_default_value()
733
-    {
734
-        if ($this->_default_value === EE_Datetime_Field::now) {
735
-            return time();
736
-        } else {
737
-            return parent::get_default_value();
738
-        }
739
-    }
740
-
741
-    /**
742
-     * Gets the default datetime object from the field's default time
743
-     * @since 4.9.66.p
744
-     * @return DbSafeDateTime|null
745
-     * @throws InvalidArgumentException
746
-     * @throws InvalidDataTypeException
747
-     * @throws InvalidInterfaceException
748
-     */
749
-    public function getDefaultDateTimeObj()
750
-    {
751
-        $default_raw = $this->get_default_value();
752
-        if ($default_raw instanceof DateTime) {
753
-            return $default_raw;
754
-        } elseif (is_null($default_raw)) {
755
-            return $default_raw;
756
-        } else {
757
-            return new DbSafeDateTime(
758
-                $this->get_default_value(),
759
-                EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone())
760
-            );
761
-        }
762
-    }
763
-
764
-    public function getSchemaDescription()
765
-    {
766
-        return sprintf(
767
-            esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
768
-            $this->get_nicename()
769
-        );
770
-    }
535
+						'event_espresso'
536
+					),
537
+					'<br />',
538
+					print_r($datetime_value, true)
539
+				)
540
+			);
541
+		}
542
+
543
+		if ($datetime_value instanceof DateTime) {
544
+			if (! $datetime_value instanceof DbSafeDateTime) {
545
+				$datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
546
+			}
547
+			EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
548
+			return $datetime_value->format(
549
+				EE_Datetime_Field::mysql_timestamp_format
550
+			);
551
+		}
552
+
553
+		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
554
+		return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
555
+	}
556
+
557
+
558
+	/**
559
+	 * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
560
+	 * allowed)
561
+	 *
562
+	 * @param string $datetime_string mysql timestamp in UTC
563
+	 * @return  mixed null | DateTime
564
+	 * @throws \EE_Error
565
+	 */
566
+	public function prepare_for_set_from_db($datetime_string)
567
+	{
568
+		// if $datetime_value is empty, and ! $this->_nullable, just use time()
569
+		if (empty($datetime_string) && $this->_nullable) {
570
+			return null;
571
+		}
572
+		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
573
+		if (empty($datetime_string)) {
574
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
575
+		} else {
576
+			$DateTime = DbSafeDateTime::createFromFormat(
577
+				EE_Datetime_Field::mysql_timestamp_format,
578
+				$datetime_string,
579
+				$this->get_UTC_DateTimeZone()
580
+			);
581
+		}
582
+
583
+		if (! $DateTime instanceof DbSafeDateTime) {
584
+			// if still no datetime object, then let's just use now
585
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
586
+		}
587
+		// THEN apply the field's set DateTimeZone
588
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
589
+		return $DateTime;
590
+	}
591
+
592
+
593
+	/**
594
+	 * All this method does is determine if we're going to display the timezone string or not on any output.
595
+	 * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
596
+	 * If so, then true.
597
+	 *
598
+	 * @return bool true for yes false for no
599
+	 * @throws \EE_Error
600
+	 */
601
+	protected function _display_timezone()
602
+	{
603
+
604
+		// first let's do a comparison of timezone strings.
605
+		// If they match then we can get out without any further calculations
606
+		$blog_string = get_option('timezone_string');
607
+		if ($blog_string === $this->_timezone_string) {
608
+			return false;
609
+		}
610
+		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
611
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
612
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
613
+		// now compare
614
+		return $blog_offset !== $this_offset;
615
+	}
616
+
617
+
618
+	/**
619
+	 * This method returns a php DateTime object for setting on the EE_Base_Class model.
620
+	 * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
621
+	 * with.
622
+	 *
623
+	 * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
624
+	 *                                                    in the format that is set on the date_field (or DateTime
625
+	 *                                                    object)!
626
+	 * @return DateTime
627
+	 */
628
+	protected function _get_date_object($date_string)
629
+	{
630
+		// first if this is an empty date_string and nullable is allowed, just return null.
631
+		if ($this->_nullable && empty($date_string)) {
632
+			return null;
633
+		}
634
+
635
+		// if incoming date
636
+		if ($date_string instanceof DateTime) {
637
+			EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
638
+			return $date_string;
639
+		}
640
+		// if empty date_string and made it here.
641
+		// Return a datetime object for now in the given timezone.
642
+		if (empty($date_string)) {
643
+			return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
644
+		}
645
+		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
646
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
647
+			try {
648
+				// This is operating under the assumption that the incoming Unix timestamp
649
+				// is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
650
+				$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
651
+				$DateTime->setTimestamp($date_string);
652
+
653
+				return $DateTime;
654
+			} catch (Exception $e) {
655
+				// should be rare, but if things got fooled then let's just continue
656
+			}
657
+		}
658
+		// not a unix timestamp.  So we will use the set format on this object and set timezone to
659
+		// create the DateTime object.
660
+		$format = $this->_date_format . ' ' . $this->_time_format;
661
+		try {
662
+			$DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
663
+			if (! $DateTime instanceof DbSafeDateTime) {
664
+				throw new EE_Error(
665
+					sprintf(
666
+						__('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
667
+						$date_string,
668
+						$format
669
+					)
670
+				);
671
+			}
672
+		} catch (Exception $e) {
673
+			// if we made it here then likely then something went really wrong.
674
+			// Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
675
+			$DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone);
676
+		}
677
+
678
+		return $DateTime;
679
+	}
680
+
681
+
682
+
683
+	/**
684
+	 * get_timezone_transitions
685
+	 *
686
+	 * @param \DateTimeZone $DateTimeZone
687
+	 * @param int           $time
688
+	 * @param bool          $first_only
689
+	 * @return mixed
690
+	 */
691
+	public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true)
692
+	{
693
+		return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
694
+	}
695
+
696
+
697
+
698
+	/**
699
+	 * get_timezone_offset
700
+	 *
701
+	 * @param \DateTimeZone $DateTimeZone
702
+	 * @param int           $time
703
+	 * @return mixed
704
+	 * @throws \DomainException
705
+	 */
706
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
707
+	{
708
+		return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
709
+	}
710
+
711
+
712
+	/**
713
+	 * This will take an incoming timezone string and return the abbreviation for that timezone
714
+	 *
715
+	 * @param  string $timezone_string
716
+	 * @return string           abbreviation
717
+	 * @throws \EE_Error
718
+	 */
719
+	public function get_timezone_abbrev($timezone_string)
720
+	{
721
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
722
+		$dateTime        = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string));
723
+
724
+		return $dateTime->format('T');
725
+	}
726
+
727
+	/**
728
+	 * Overrides the parent to allow for having a dynamic "now" value
729
+	 *
730
+	 * @return mixed
731
+	 */
732
+	public function get_default_value()
733
+	{
734
+		if ($this->_default_value === EE_Datetime_Field::now) {
735
+			return time();
736
+		} else {
737
+			return parent::get_default_value();
738
+		}
739
+	}
740
+
741
+	/**
742
+	 * Gets the default datetime object from the field's default time
743
+	 * @since 4.9.66.p
744
+	 * @return DbSafeDateTime|null
745
+	 * @throws InvalidArgumentException
746
+	 * @throws InvalidDataTypeException
747
+	 * @throws InvalidInterfaceException
748
+	 */
749
+	public function getDefaultDateTimeObj()
750
+	{
751
+		$default_raw = $this->get_default_value();
752
+		if ($default_raw instanceof DateTime) {
753
+			return $default_raw;
754
+		} elseif (is_null($default_raw)) {
755
+			return $default_raw;
756
+		} else {
757
+			return new DbSafeDateTime(
758
+				$this->get_default_value(),
759
+				EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone())
760
+			);
761
+		}
762
+	}
763
+
764
+	public function getSchemaDescription()
765
+	{
766
+		return sprintf(
767
+			esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
768
+			$this->get_nicename()
769
+		);
770
+	}
771 771
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 
213 213
             default:
214 214
                 return $pretty
215
-                    ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format
216
-                    : $this->_date_format . ' ' . $this->_time_format;
215
+                    ? $this->_pretty_date_format.' '.$this->_pretty_time_format
216
+                    : $this->_date_format.' '.$this->_time_format;
217 217
         }
218 218
     }
219 219
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
      */
468 468
     protected function _prepare_for_display($DateTime, $schema = false)
469 469
     {
470
-        if (! $DateTime instanceof DateTime) {
470
+        if ( ! $DateTime instanceof DateTime) {
471 471
             if ($this->_nullable) {
472 472
                 return '';
473 473
             } else {
@@ -501,15 +501,15 @@  discard block
 block discarded – undo
501 501
             if ($this->_display_timezone()) {
502 502
                 // must be explicit because schema could equal true.
503 503
                 if ($schema === 'no_html') {
504
-                    $timezone_string = ' (' . $DateTime->format('T') . ')';
504
+                    $timezone_string = ' ('.$DateTime->format('T').')';
505 505
                 } else {
506
-                    $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
506
+                    $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>';
507 507
                 }
508 508
             } else {
509 509
                 $timezone_string = '';
510 510
             }
511 511
 
512
-            return $DateTime->format($format_string) . $timezone_string;
512
+            return $DateTime->format($format_string).$timezone_string;
513 513
         }
514 514
         return $DateTime->format($format_string);
515 515
     }
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
     public function prepare_for_use_in_db($datetime_value)
527 527
     {
528 528
         // we allow an empty value or DateTime object, but nothing else.
529
-        if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
529
+        if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
530 530
             throw new EE_Error(
531 531
                 sprintf(
532 532
                     __(
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
         }
542 542
 
543 543
         if ($datetime_value instanceof DateTime) {
544
-            if (! $datetime_value instanceof DbSafeDateTime) {
544
+            if ( ! $datetime_value instanceof DbSafeDateTime) {
545 545
                 $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
546 546
             }
547 547
             EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
             );
581 581
         }
582 582
 
583
-        if (! $DateTime instanceof DbSafeDateTime) {
583
+        if ( ! $DateTime instanceof DbSafeDateTime) {
584 584
             // if still no datetime object, then let's just use now
585 585
             $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
586 586
         }
@@ -657,10 +657,10 @@  discard block
 block discarded – undo
657 657
         }
658 658
         // not a unix timestamp.  So we will use the set format on this object and set timezone to
659 659
         // create the DateTime object.
660
-        $format = $this->_date_format . ' ' . $this->_time_format;
660
+        $format = $this->_date_format.' '.$this->_time_format;
661 661
         try {
662 662
             $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
663
-            if (! $DateTime instanceof DbSafeDateTime) {
663
+            if ( ! $DateTime instanceof DbSafeDateTime) {
664 664
                 throw new EE_Error(
665 665
                     sprintf(
666 666
                         __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
Please login to merge, or discard this patch.
core/domain/entities/DbSafeDateTime.php 1 patch
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -18,188 +18,188 @@
 block discarded – undo
18 18
 class DbSafeDateTime extends DateTime
19 19
 {
20 20
 
21
-    // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
22
-    /**
23
-     * @type string db_safe_timestamp_format
24
-     */
25
-    const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
26
-    // phpcs:enable
27
-
28
-    // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
29
-    /**
30
-     * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
31
-     *
32
-     * @type string $_datetime_string
33
-     */
34
-    protected $_datetime_string = '';
35
-
36
-    /**
37
-     * where to write the error log to
38
-     *
39
-     * @type string $_error_log_dir
40
-     */
41
-    protected $_error_log_dir = '';
42
-    // phpcs:enable
43
-
44
-
45
-    /**
46
-     * @param string $error_log_dir
47
-     */
48
-    public function setErrorLogDir($error_log_dir)
49
-    {
50
-        // if the folder path is writable, then except the path + filename, else keep empty
51
-        $this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
52
-            ? $error_log_dir
53
-            : '';
54
-    }
55
-
56
-
57
-    /**
58
-     * @return string
59
-     */
60
-    public function __toString()
61
-    {
62
-        return $this->format(DbSafeDateTime::db_safe_timestamp_format);
63
-    }
64
-
65
-
66
-    /**
67
-     * @return array
68
-     */
69
-    public function __sleep()
70
-    {
71
-        $this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
72
-        $date = DateTime::createFromFormat(
73
-            DbSafeDateTime::db_safe_timestamp_format,
74
-            $this->_datetime_string
75
-        );
76
-        if (! $date instanceof DateTime) {
77
-            try {
78
-                // we want a stack trace to determine where the malformed date came from, so...
79
-                throw new DomainException('');
80
-            } catch (DomainException $e) {
81
-                $stack_trace = $e->getTraceAsString();
82
-            }
83
-            $this->writeToErrorLog(
84
-                sprintf(
85
-                    __(
86
-                        'A valid DateTime could not be generated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s %2$s Stack Trace: %5$s',
87
-                        'event_espresso'
88
-                    ),
89
-                    $this->_datetime_string,
90
-                    '<br />',
91
-                    print_r(DateTime::getLastErrors(), true),
92
-                    PHP_VERSION,
93
-                    $stack_trace
94
-                )
95
-            );
96
-        }
97
-        return array('_datetime_string');
98
-    }
99
-
100
-
101
-    /**
102
-     * if an empty or null value got saved to the db for a datetime,
103
-     * then some servers and/or PHP itself will incorrectly convert that date string
104
-     * resulting in "-0001-11-30" for the year-month-day.
105
-     * see the Notes section
106
-     *
107
-     * @link http://php.net/manual/en/datetime.formats.date.php
108
-     * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
109
-     * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
110
-     * so we're no better off, but at least things won't go fatal on us.
111
-     */
112
-    public function __wakeup()
113
-    {
114
-        $date = self::createFromFormat(
115
-            DbSafeDateTime::db_safe_timestamp_format,
116
-            $this->_datetime_string
117
-        );
118
-        if (! $date instanceof DateTime) {
119
-            $this->writeToErrorLog(
120
-                sprintf(
121
-                    __(
122
-                        'A valid DateTime could not be recreated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s',
123
-                        'event_espresso'
124
-                    ),
125
-                    $this->_datetime_string,
126
-                    '<br />',
127
-                    print_r(DateTime::getLastErrors(), true),
128
-                    PHP_VERSION
129
-                )
130
-            );
131
-        } else {
132
-            $this->__construct(
133
-                $date->format(\EE_Datetime_Field::mysql_timestamp_format),
134
-                new DateTimeZone($date->format('e'))
135
-            );
136
-        }
137
-    }
138
-
139
-
140
-    /**
141
-     * Normalizes incoming date string so that it is a bit more stable for use.
142
-     * @param string $date_string
143
-     * @return string
144
-     */
145
-    public static function normalizeInvalidDate($date_string)
146
-    {
147
-        return str_replace(
148
-            array('-0001-11-29', '-0001-11-30', '0000-00-00'),
149
-            '0000-01-03',
150
-            $date_string
151
-        );
152
-    }
153
-
154
-
155
-    /**
156
-     * Creates a DbSafeDateTime from ye old DateTime
157
-     *
158
-     * @param DateTime $datetime
159
-     * @return \EventEspresso\core\domain\entities\DbSafeDateTime
160
-     */
161
-    public static function createFromDateTime(DateTime $datetime)
162
-    {
163
-        return new DbSafeDateTime(
164
-            $datetime->format(\EE_Datetime_Field::mysql_timestamp_format),
165
-            new DateTimeZone($datetime->format('e'))
166
-        );
167
-    }
168
-
169
-
170
-    /**
171
-     * Parse a string into a new DateTime object according to the specified format
172
-     *
173
-     * @param string       $format   Format accepted by date().
174
-     * @param string       $time     String representing the time.
175
-     * @param DateTimeZone $timezone A DateTimeZone object representing the desired time zone.
176
-     * @return DbSafeDateTime|boolean
177
-     * @link https://php.net/manual/en/datetime.createfromformat.php
178
-     */
179
-    public static function createFromFormat($format, $time, $timezone = null)
180
-    {
181
-        $time = self::normalizeInvalidDate($time);
182
-        // Various php versions handle the third argument differently.  This conditional accounts for that.
183
-        $DateTime = $timezone === null
184
-            ? parent::createFromFormat($format, $time)
185
-            : parent::createFromFormat($format, $time, $timezone);
186
-        return $DateTime instanceof DateTime
187
-            ? self::createFromDateTime($DateTime)
188
-            : $DateTime;
189
-    }
190
-
191
-
192
-    /**
193
-     * @param string $message
194
-     */
195
-    private function writeToErrorLog($message)
196
-    {
197
-        if (! empty($this->_error_log_dir)) {
198
-            /** @noinspection ForgottenDebugOutputInspection */
199
-            error_log($message, 3, $this->_error_log_dir);
200
-        } else {
201
-            /** @noinspection ForgottenDebugOutputInspection */
202
-            error_log($message);
203
-        }
204
-    }
21
+	// phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
22
+	/**
23
+	 * @type string db_safe_timestamp_format
24
+	 */
25
+	const db_safe_timestamp_format = 'Y-m-d H:i:s O e';
26
+	// phpcs:enable
27
+
28
+	// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
29
+	/**
30
+	 * DateTime object converted to a string that includes the date, time, UTC offset, and timezone identifier
31
+	 *
32
+	 * @type string $_datetime_string
33
+	 */
34
+	protected $_datetime_string = '';
35
+
36
+	/**
37
+	 * where to write the error log to
38
+	 *
39
+	 * @type string $_error_log_dir
40
+	 */
41
+	protected $_error_log_dir = '';
42
+	// phpcs:enable
43
+
44
+
45
+	/**
46
+	 * @param string $error_log_dir
47
+	 */
48
+	public function setErrorLogDir($error_log_dir)
49
+	{
50
+		// if the folder path is writable, then except the path + filename, else keep empty
51
+		$this->_error_log_dir = is_writable(str_replace(basename($error_log_dir), '', $error_log_dir))
52
+			? $error_log_dir
53
+			: '';
54
+	}
55
+
56
+
57
+	/**
58
+	 * @return string
59
+	 */
60
+	public function __toString()
61
+	{
62
+		return $this->format(DbSafeDateTime::db_safe_timestamp_format);
63
+	}
64
+
65
+
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function __sleep()
70
+	{
71
+		$this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format);
72
+		$date = DateTime::createFromFormat(
73
+			DbSafeDateTime::db_safe_timestamp_format,
74
+			$this->_datetime_string
75
+		);
76
+		if (! $date instanceof DateTime) {
77
+			try {
78
+				// we want a stack trace to determine where the malformed date came from, so...
79
+				throw new DomainException('');
80
+			} catch (DomainException $e) {
81
+				$stack_trace = $e->getTraceAsString();
82
+			}
83
+			$this->writeToErrorLog(
84
+				sprintf(
85
+					__(
86
+						'A valid DateTime could not be generated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s %2$s Stack Trace: %5$s',
87
+						'event_espresso'
88
+					),
89
+					$this->_datetime_string,
90
+					'<br />',
91
+					print_r(DateTime::getLastErrors(), true),
92
+					PHP_VERSION,
93
+					$stack_trace
94
+				)
95
+			);
96
+		}
97
+		return array('_datetime_string');
98
+	}
99
+
100
+
101
+	/**
102
+	 * if an empty or null value got saved to the db for a datetime,
103
+	 * then some servers and/or PHP itself will incorrectly convert that date string
104
+	 * resulting in "-0001-11-30" for the year-month-day.
105
+	 * see the Notes section
106
+	 *
107
+	 * @link http://php.net/manual/en/datetime.formats.date.php
108
+	 * We'll replace those with "0000-00-00" which will allow a valid DateTime object to be created,
109
+	 * but still result in the internal date for that object being set to "-0001-11-30 10:00:00.000000".
110
+	 * so we're no better off, but at least things won't go fatal on us.
111
+	 */
112
+	public function __wakeup()
113
+	{
114
+		$date = self::createFromFormat(
115
+			DbSafeDateTime::db_safe_timestamp_format,
116
+			$this->_datetime_string
117
+		);
118
+		if (! $date instanceof DateTime) {
119
+			$this->writeToErrorLog(
120
+				sprintf(
121
+					__(
122
+						'A valid DateTime could not be recreated from "%1$s" because the following errors occurred: %2$s %3$s %2$s PHP version: %4$s',
123
+						'event_espresso'
124
+					),
125
+					$this->_datetime_string,
126
+					'<br />',
127
+					print_r(DateTime::getLastErrors(), true),
128
+					PHP_VERSION
129
+				)
130
+			);
131
+		} else {
132
+			$this->__construct(
133
+				$date->format(\EE_Datetime_Field::mysql_timestamp_format),
134
+				new DateTimeZone($date->format('e'))
135
+			);
136
+		}
137
+	}
138
+
139
+
140
+	/**
141
+	 * Normalizes incoming date string so that it is a bit more stable for use.
142
+	 * @param string $date_string
143
+	 * @return string
144
+	 */
145
+	public static function normalizeInvalidDate($date_string)
146
+	{
147
+		return str_replace(
148
+			array('-0001-11-29', '-0001-11-30', '0000-00-00'),
149
+			'0000-01-03',
150
+			$date_string
151
+		);
152
+	}
153
+
154
+
155
+	/**
156
+	 * Creates a DbSafeDateTime from ye old DateTime
157
+	 *
158
+	 * @param DateTime $datetime
159
+	 * @return \EventEspresso\core\domain\entities\DbSafeDateTime
160
+	 */
161
+	public static function createFromDateTime(DateTime $datetime)
162
+	{
163
+		return new DbSafeDateTime(
164
+			$datetime->format(\EE_Datetime_Field::mysql_timestamp_format),
165
+			new DateTimeZone($datetime->format('e'))
166
+		);
167
+	}
168
+
169
+
170
+	/**
171
+	 * Parse a string into a new DateTime object according to the specified format
172
+	 *
173
+	 * @param string       $format   Format accepted by date().
174
+	 * @param string       $time     String representing the time.
175
+	 * @param DateTimeZone $timezone A DateTimeZone object representing the desired time zone.
176
+	 * @return DbSafeDateTime|boolean
177
+	 * @link https://php.net/manual/en/datetime.createfromformat.php
178
+	 */
179
+	public static function createFromFormat($format, $time, $timezone = null)
180
+	{
181
+		$time = self::normalizeInvalidDate($time);
182
+		// Various php versions handle the third argument differently.  This conditional accounts for that.
183
+		$DateTime = $timezone === null
184
+			? parent::createFromFormat($format, $time)
185
+			: parent::createFromFormat($format, $time, $timezone);
186
+		return $DateTime instanceof DateTime
187
+			? self::createFromDateTime($DateTime)
188
+			: $DateTime;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @param string $message
194
+	 */
195
+	private function writeToErrorLog($message)
196
+	{
197
+		if (! empty($this->_error_log_dir)) {
198
+			/** @noinspection ForgottenDebugOutputInspection */
199
+			error_log($message, 3, $this->_error_log_dir);
200
+		} else {
201
+			/** @noinspection ForgottenDebugOutputInspection */
202
+			error_log($message);
203
+		}
204
+	}
205 205
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Country_Select_Input.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -14,80 +14,80 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Country_Select_Input extends EE_Select_Input
16 16
 {
17
-    /**
18
-     * $input_settings key used for detecting the "get" option
19
-     */
20
-    const OPTION_GET_KEY = 'get';
17
+	/**
18
+	 * $input_settings key used for detecting the "get" option
19
+	 */
20
+	const OPTION_GET_KEY = 'get';
21 21
 
22
-    /**
23
-     * indicates that ALL countries should be retrieved from the db for the input
24
-     */
25
-    const OPTION_GET_ALL = 'all';
22
+	/**
23
+	 * indicates that ALL countries should be retrieved from the db for the input
24
+	 */
25
+	const OPTION_GET_ALL = 'all';
26 26
 
27
-    /**
28
-     * indicates that only ACTIVE countries should be retrieved from the db for the input
29
-     */
30
-    const OPTION_GET_ACTIVE = 'active';
27
+	/**
28
+	 * indicates that only ACTIVE countries should be retrieved from the db for the input
29
+	 */
30
+	const OPTION_GET_ACTIVE = 'active';
31 31
 
32 32
 
33
-    /**
34
-     * @param array $country_options
35
-     * @param array $input_settings
36
-     * @throws EE_Error
37
-     * @throws InvalidArgumentException
38
-     * @throws InvalidDataTypeException
39
-     * @throws InvalidInterfaceException
40
-     * @throws ReflectionException
41
-     */
42
-    public function __construct($country_options = null, $input_settings = array())
43
-    {
44
-        $get = isset($input_settings[ self::OPTION_GET_KEY ])
45
-            ? $input_settings[ self::OPTION_GET_KEY ]
46
-            : self::OPTION_GET_ACTIVE;
47
-        $country_options = apply_filters(
48
-            'FHEE__EE_Country_Select_Input____construct__country_options',
49
-            $this->get_country_answer_options($country_options, $get),
50
-            $this,
51
-            $get
52
-        );
53
-        $input_settings['html_class'] = isset($input_settings['html_class'])
54
-            ? $input_settings['html_class'] . ' ee-country-select-js'
55
-            : 'ee-country-select-js';
56
-        parent::__construct($country_options, $input_settings);
57
-    }
33
+	/**
34
+	 * @param array $country_options
35
+	 * @param array $input_settings
36
+	 * @throws EE_Error
37
+	 * @throws InvalidArgumentException
38
+	 * @throws InvalidDataTypeException
39
+	 * @throws InvalidInterfaceException
40
+	 * @throws ReflectionException
41
+	 */
42
+	public function __construct($country_options = null, $input_settings = array())
43
+	{
44
+		$get = isset($input_settings[ self::OPTION_GET_KEY ])
45
+			? $input_settings[ self::OPTION_GET_KEY ]
46
+			: self::OPTION_GET_ACTIVE;
47
+		$country_options = apply_filters(
48
+			'FHEE__EE_Country_Select_Input____construct__country_options',
49
+			$this->get_country_answer_options($country_options, $get),
50
+			$this,
51
+			$get
52
+		);
53
+		$input_settings['html_class'] = isset($input_settings['html_class'])
54
+			? $input_settings['html_class'] . ' ee-country-select-js'
55
+			: 'ee-country-select-js';
56
+		parent::__construct($country_options, $input_settings);
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * get_country_answer_options
62
-     *
63
-     * @param array  $country_options
64
-     * @param string $get
65
-     * @return array
66
-     * @throws EE_Error
67
-     * @throws InvalidArgumentException
68
-     * @throws ReflectionException
69
-     * @throws InvalidDataTypeException
70
-     * @throws InvalidInterfaceException
71
-     */
72
-    public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73
-    {
74
-        // if passed something that is NOT an array
75
-        if (! is_array($country_options)) {
76
-            // get possibly cached list of countries
77
-            $countries = $get === self::OPTION_GET_ALL
78
-                ? EEM_Country::instance()->get_all_countries()
79
-                : EEM_Country::instance()->get_all_active_countries();
80
-            if (! empty($countries)) {
81
-                $country_options[''] = '';
82
-                foreach ($countries as $country) {
83
-                    if ($country instanceof EE_Country) {
84
-                        $country_options[ $country->ID() ] = $country->name();
85
-                    }
86
-                }
87
-            } else {
88
-                $country_options = array();
89
-            }
90
-        }
91
-        return $country_options;
92
-    }
60
+	/**
61
+	 * get_country_answer_options
62
+	 *
63
+	 * @param array  $country_options
64
+	 * @param string $get
65
+	 * @return array
66
+	 * @throws EE_Error
67
+	 * @throws InvalidArgumentException
68
+	 * @throws ReflectionException
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws InvalidInterfaceException
71
+	 */
72
+	public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73
+	{
74
+		// if passed something that is NOT an array
75
+		if (! is_array($country_options)) {
76
+			// get possibly cached list of countries
77
+			$countries = $get === self::OPTION_GET_ALL
78
+				? EEM_Country::instance()->get_all_countries()
79
+				: EEM_Country::instance()->get_all_active_countries();
80
+			if (! empty($countries)) {
81
+				$country_options[''] = '';
82
+				foreach ($countries as $country) {
83
+					if ($country instanceof EE_Country) {
84
+						$country_options[ $country->ID() ] = $country->name();
85
+					}
86
+				}
87
+			} else {
88
+				$country_options = array();
89
+			}
90
+		}
91
+		return $country_options;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __construct($country_options = null, $input_settings = array())
43 43
     {
44
-        $get = isset($input_settings[ self::OPTION_GET_KEY ])
45
-            ? $input_settings[ self::OPTION_GET_KEY ]
44
+        $get = isset($input_settings[self::OPTION_GET_KEY])
45
+            ? $input_settings[self::OPTION_GET_KEY]
46 46
             : self::OPTION_GET_ACTIVE;
47 47
         $country_options = apply_filters(
48 48
             'FHEE__EE_Country_Select_Input____construct__country_options',
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $get
52 52
         );
53 53
         $input_settings['html_class'] = isset($input_settings['html_class'])
54
-            ? $input_settings['html_class'] . ' ee-country-select-js'
54
+            ? $input_settings['html_class'].' ee-country-select-js'
55 55
             : 'ee-country-select-js';
56 56
         parent::__construct($country_options, $input_settings);
57 57
     }
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE)
73 73
     {
74 74
         // if passed something that is NOT an array
75
-        if (! is_array($country_options)) {
75
+        if ( ! is_array($country_options)) {
76 76
             // get possibly cached list of countries
77 77
             $countries = $get === self::OPTION_GET_ALL
78 78
                 ? EEM_Country::instance()->get_all_countries()
79 79
                 : EEM_Country::instance()->get_all_active_countries();
80
-            if (! empty($countries)) {
80
+            if ( ! empty($countries)) {
81 81
                 $country_options[''] = '';
82 82
                 foreach ($countries as $country) {
83 83
                     if ($country instanceof EE_Country) {
84
-                        $country_options[ $country->ID() ] = $country->name();
84
+                        $country_options[$country->ID()] = $country->name();
85 85
                     }
86 86
                 }
87 87
             } else {
Please login to merge, or discard this patch.