Completed
Branch BUG/reg-status-change-recursio... (2db0c9)
by
unknown
20:03 queued 10:32
created
core/services/assets/AssetCollection.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -21,192 +21,192 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * AssetCollection constructor
26
-     *
27
-     * @throws InvalidInterfaceException
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
-    }
33
-
34
-
35
-    /**
36
-     * @return StylesheetAsset[]
37
-     * @since 4.9.62.p
38
-     */
39
-    public function getStylesheetAssets()
40
-    {
41
-        return $this->getAssetsOfType(Asset::TYPE_CSS);
42
-    }
43
-
44
-
45
-    /**
46
-     * @return JavascriptAsset[]
47
-     * @since 4.9.62.p
48
-     */
49
-    public function getJavascriptAssets()
50
-    {
51
-        return $this->getAssetsOfType(Asset::TYPE_JS);
52
-    }
53
-
54
-
55
-    /**
56
-     * @return ManifestFile[]
57
-     * @since 4.9.62.p
58
-     */
59
-    public function getManifestFiles()
60
-    {
61
-        return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
-    }
63
-
64
-
65
-    /**
66
-     * @param $type
67
-     * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
-     * @since 4.9.62.p
69
-     */
70
-    protected function getAssetsOfType($type)
71
-    {
72
-        $files = array();
73
-        $this->rewind();
74
-        while ($this->valid()) {
75
-            /** @var Asset $asset */
76
-            $asset = $this->current();
77
-            if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
79
-            }
80
-            $this->next();
81
-        }
82
-        $this->rewind();
83
-        return $files;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return JavascriptAsset[]
89
-     * @since 4.9.62.p
90
-     */
91
-    public function getJavascriptAssetsWithData()
92
-    {
93
-        $files = array();
94
-        $this->rewind();
95
-        while ($this->valid()) {
96
-            /** @var JavascriptAsset $asset */
97
-            $asset = $this->current();
98
-            if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
100
-            }
101
-            $this->next();
102
-        }
103
-        $this->rewind();
104
-        return $files;
105
-    }
106
-
107
-
108
-    /**
109
-     * returns TRUE or FALSE
110
-     * depending on whether the object is within the Collection
111
-     * based on the supplied $identifier and type
112
-     *
113
-     * @param  mixed $identifier
114
-     * @param string $type
115
-     * @return bool
116
-     * @since 4.9.63.p
117
-     */
118
-    public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
-    {
120
-        $this->rewind();
121
-        while ($this->valid()) {
122
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
-                $this->rewind();
124
-                return true;
125
-            }
126
-            $this->next();
127
-        }
128
-        return false;
129
-    }
130
-
131
-
132
-    /**
133
-     * returns TRUE or FALSE
134
-     * depending on whether the Javascript Asset is within the Collection
135
-     * based on the supplied $identifier
136
-     *
137
-     * @param  mixed $identifier
138
-     * @return bool
139
-     * @since 4.9.63.p
140
-     */
141
-    public function hasJavascriptAsset($identifier)
142
-    {
143
-        return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
-    }
145
-
146
-
147
-    /**
148
-     * returns TRUE or FALSE
149
-     * depending on whether the Stylesheet Asset is within the Collection
150
-     * based on the supplied $identifier
151
-     *
152
-     * @param  mixed $identifier
153
-     * @return bool
154
-     * @since 4.9.63.p
155
-     */
156
-    public function hasStylesheetAsset($identifier)
157
-    {
158
-        return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
-    }
160
-
161
-    /**
162
-     * returns the object from the Collection
163
-     * based on the supplied $identifier and type
164
-     *
165
-     * @param  mixed $identifier
166
-     * @param string $type
167
-     * @return JavascriptAsset|StylesheetAsset
168
-     * @since 4.9.63.p
169
-     */
170
-    public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
-    {
172
-        $this->rewind();
173
-        while ($this->valid()) {
174
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
-                /** @var JavascriptAsset|StylesheetAsset $object */
176
-                $object = $this->current();
177
-                $this->rewind();
178
-                return $object;
179
-            }
180
-            $this->next();
181
-        }
182
-        return null;
183
-    }
184
-
185
-
186
-    /**
187
-     * returns the Stylesheet Asset from the Collection
188
-     * based on the supplied $identifier
189
-     *
190
-     * @param  mixed $identifier
191
-     * @return StylesheetAsset
192
-     * @since 4.9.63.p
193
-     */
194
-    public function getStylesheetAsset($identifier)
195
-    {
196
-        return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
-    }
198
-
199
-
200
-    /**
201
-     * returns the Javascript Asset from the Collection
202
-     * based on the supplied $identifier
203
-     *
204
-     * @param  mixed $identifier
205
-     * @return JavascriptAsset
206
-     * @since 4.9.63.p
207
-     */
208
-    public function getJavascriptAsset($identifier)
209
-    {
210
-        return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
-    }
24
+	/**
25
+	 * AssetCollection constructor
26
+	 *
27
+	 * @throws InvalidInterfaceException
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return StylesheetAsset[]
37
+	 * @since 4.9.62.p
38
+	 */
39
+	public function getStylesheetAssets()
40
+	{
41
+		return $this->getAssetsOfType(Asset::TYPE_CSS);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @return JavascriptAsset[]
47
+	 * @since 4.9.62.p
48
+	 */
49
+	public function getJavascriptAssets()
50
+	{
51
+		return $this->getAssetsOfType(Asset::TYPE_JS);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return ManifestFile[]
57
+	 * @since 4.9.62.p
58
+	 */
59
+	public function getManifestFiles()
60
+	{
61
+		return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param $type
67
+	 * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
+	 * @since 4.9.62.p
69
+	 */
70
+	protected function getAssetsOfType($type)
71
+	{
72
+		$files = array();
73
+		$this->rewind();
74
+		while ($this->valid()) {
75
+			/** @var Asset $asset */
76
+			$asset = $this->current();
77
+			if ($asset->type() === $type) {
78
+				$files[ $asset->handle() ] = $asset;
79
+			}
80
+			$this->next();
81
+		}
82
+		$this->rewind();
83
+		return $files;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return JavascriptAsset[]
89
+	 * @since 4.9.62.p
90
+	 */
91
+	public function getJavascriptAssetsWithData()
92
+	{
93
+		$files = array();
94
+		$this->rewind();
95
+		while ($this->valid()) {
96
+			/** @var JavascriptAsset $asset */
97
+			$asset = $this->current();
98
+			if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
+				$files[ $asset->handle() ] = $asset;
100
+			}
101
+			$this->next();
102
+		}
103
+		$this->rewind();
104
+		return $files;
105
+	}
106
+
107
+
108
+	/**
109
+	 * returns TRUE or FALSE
110
+	 * depending on whether the object is within the Collection
111
+	 * based on the supplied $identifier and type
112
+	 *
113
+	 * @param  mixed $identifier
114
+	 * @param string $type
115
+	 * @return bool
116
+	 * @since 4.9.63.p
117
+	 */
118
+	public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
+	{
120
+		$this->rewind();
121
+		while ($this->valid()) {
122
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
+				$this->rewind();
124
+				return true;
125
+			}
126
+			$this->next();
127
+		}
128
+		return false;
129
+	}
130
+
131
+
132
+	/**
133
+	 * returns TRUE or FALSE
134
+	 * depending on whether the Javascript Asset is within the Collection
135
+	 * based on the supplied $identifier
136
+	 *
137
+	 * @param  mixed $identifier
138
+	 * @return bool
139
+	 * @since 4.9.63.p
140
+	 */
141
+	public function hasJavascriptAsset($identifier)
142
+	{
143
+		return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
+	}
145
+
146
+
147
+	/**
148
+	 * returns TRUE or FALSE
149
+	 * depending on whether the Stylesheet Asset is within the Collection
150
+	 * based on the supplied $identifier
151
+	 *
152
+	 * @param  mixed $identifier
153
+	 * @return bool
154
+	 * @since 4.9.63.p
155
+	 */
156
+	public function hasStylesheetAsset($identifier)
157
+	{
158
+		return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
+	}
160
+
161
+	/**
162
+	 * returns the object from the Collection
163
+	 * based on the supplied $identifier and type
164
+	 *
165
+	 * @param  mixed $identifier
166
+	 * @param string $type
167
+	 * @return JavascriptAsset|StylesheetAsset
168
+	 * @since 4.9.63.p
169
+	 */
170
+	public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
+	{
172
+		$this->rewind();
173
+		while ($this->valid()) {
174
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
+				/** @var JavascriptAsset|StylesheetAsset $object */
176
+				$object = $this->current();
177
+				$this->rewind();
178
+				return $object;
179
+			}
180
+			$this->next();
181
+		}
182
+		return null;
183
+	}
184
+
185
+
186
+	/**
187
+	 * returns the Stylesheet Asset from the Collection
188
+	 * based on the supplied $identifier
189
+	 *
190
+	 * @param  mixed $identifier
191
+	 * @return StylesheetAsset
192
+	 * @since 4.9.63.p
193
+	 */
194
+	public function getStylesheetAsset($identifier)
195
+	{
196
+		return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
+	}
198
+
199
+
200
+	/**
201
+	 * returns the Javascript Asset from the Collection
202
+	 * based on the supplied $identifier
203
+	 *
204
+	 * @param  mixed $identifier
205
+	 * @return JavascriptAsset
206
+	 * @since 4.9.63.p
207
+	 */
208
+	public function getJavascriptAsset($identifier)
209
+	{
210
+		return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
+	}
212 212
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 1 patch
Indentation   +679 added lines, -679 removed lines patch added patch discarded remove patch
@@ -11,670 +11,670 @@  discard block
 block discarded – undo
11 11
 class EEH_Debug_Tools
12 12
 {
13 13
 
14
-    /**
15
-     *    instance of the EEH_Autoloader object
16
-     *
17
-     * @var    $_instance
18
-     * @access    private
19
-     */
20
-    private static $_instance;
21
-
22
-    /**
23
-     * @var array
24
-     */
25
-    protected $_memory_usage_points = array();
26
-
27
-
28
-
29
-    /**
30
-     * @singleton method used to instantiate class object
31
-     * @access    public
32
-     * @return EEH_Debug_Tools
33
-     */
34
-    public static function instance()
35
-    {
36
-        // check if class object is instantiated, and instantiated properly
37
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
38
-            self::$_instance = new self();
39
-        }
40
-        return self::$_instance;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * private class constructor
47
-     */
48
-    private function __construct()
49
-    {
50
-        // load Kint PHP debugging library
51
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
52
-            // despite EE4 having a check for an existing copy of the Kint debugging class,
53
-            // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
54
-            // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
55
-            // so we've moved it to our test folder so that it is not included with production releases
56
-            // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
57
-            require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
58
-        }
59
-        // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
60
-        // add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
61
-        // }
62
-        $plugin = basename(EE_PLUGIN_DIR_PATH);
63
-        add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
64
-        add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
65
-        add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     *    show_db_name
72
-     *
73
-     * @return void
74
-     */
75
-    public static function show_db_name()
76
-    {
77
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
78
-            echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
79
-                 . DB_NAME
80
-                 . '</p>';
81
-        }
82
-        if (EE_DEBUG) {
83
-            Benchmark::displayResults();
84
-        }
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     *    dump EE_Session object at bottom of page after everything else has happened
91
-     *
92
-     * @return void
93
-     */
94
-    public function espresso_session_footer_dump()
95
-    {
96
-        if ((defined('WP_DEBUG') && WP_DEBUG)
97
-            && ! defined('DOING_AJAX')
98
-            && class_exists('Kint')
99
-            && function_exists('wp_get_current_user')
100
-            && current_user_can('update_core')
101
-            && class_exists('EE_Registry')
102
-        ) {
103
-            Kint::dump(EE_Registry::instance()->SSN->id());
104
-            Kint::dump(EE_Registry::instance()->SSN);
105
-            //          Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
106
-            $this->espresso_list_hooked_functions();
107
-            Benchmark::displayResults();
108
-        }
109
-    }
110
-
111
-
112
-
113
-    /**
114
-     *    List All Hooked Functions
115
-     *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
116
-     *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
117
-     *
118
-     * @param string $tag
119
-     * @return void
120
-     */
121
-    public function espresso_list_hooked_functions($tag = '')
122
-    {
123
-        global $wp_filter;
124
-        echo '<br/><br/><br/><h3>Hooked Functions</h3>';
125
-        if ($tag) {
126
-            $hook[ $tag ] = $wp_filter[ $tag ];
127
-            if (! is_array($hook[ $tag ])) {
128
-                trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
129
-                return;
130
-            }
131
-            echo '<h5>For Tag: ' . $tag . '</h5>';
132
-        } else {
133
-            $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
134
-            ksort($hook);
135
-        }
136
-        foreach ($hook as $tag_name => $priorities) {
137
-            echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
138
-            ksort($priorities);
139
-            foreach ($priorities as $priority => $function) {
140
-                echo $priority;
141
-                foreach ($function as $name => $properties) {
142
-                    echo "\t$name<br />";
143
-                }
144
-            }
145
-        }
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     *    registered_filter_callbacks
152
-     *
153
-     * @param string $hook_name
154
-     * @return array
155
-     */
156
-    public static function registered_filter_callbacks($hook_name = '')
157
-    {
158
-        $filters = array();
159
-        global $wp_filter;
160
-        if (isset($wp_filter[ $hook_name ])) {
161
-            $filters[ $hook_name ] = array();
162
-            foreach ($wp_filter[ $hook_name ] as $priority => $callbacks) {
163
-                $filters[ $hook_name ][ $priority ] = array();
164
-                foreach ($callbacks as $callback) {
165
-                    $filters[ $hook_name ][ $priority ][] = $callback['function'];
166
-                }
167
-            }
168
-        }
169
-        return $filters;
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     *    captures plugin activation errors for debugging
176
-     *
177
-     * @return void
178
-     * @throws EE_Error
179
-     */
180
-    public static function ee_plugin_activation_errors()
181
-    {
182
-        if (WP_DEBUG) {
183
-            $activation_errors = ob_get_contents();
184
-            if (! empty($activation_errors)) {
185
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
186
-            }
187
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
188
-            if (class_exists('EEH_File')) {
189
-                try {
190
-                    EEH_File::ensure_file_exists_and_is_writable(
191
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
192
-                    );
193
-                    EEH_File::write_to_file(
194
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
195
-                        $activation_errors
196
-                    );
197
-                } catch (EE_Error $e) {
198
-                    EE_Error::add_error(
199
-                        sprintf(
200
-                            __(
201
-                                'The Event Espresso activation errors file could not be setup because: %s',
202
-                                'event_espresso'
203
-                            ),
204
-                            $e->getMessage()
205
-                        ),
206
-                        __FILE__,
207
-                        __FUNCTION__,
208
-                        __LINE__
209
-                    );
210
-                }
211
-            } else {
212
-                // old school attempt
213
-                file_put_contents(
214
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
215
-                    $activation_errors
216
-                );
217
-            }
218
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
219
-            update_option('ee_plugin_activation_errors', $activation_errors);
220
-        }
221
-    }
222
-
223
-
224
-
225
-    /**
226
-     * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
227
-     * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
228
-     * or we want to make sure they use something the right way.
229
-     *
230
-     * @access public
231
-     * @param string $function      The function that was called
232
-     * @param string $message       A message explaining what has been done incorrectly
233
-     * @param string $version       The version of Event Espresso where the error was added
234
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
235
-     *                              for a deprecated function. This allows deprecation to occur during one version,
236
-     *                              but not have any notices appear until a later version. This allows developers
237
-     *                              extra time to update their code before notices appear.
238
-     * @param int    $error_type
239
-     * @uses   trigger_error()
240
-     */
241
-    public function doing_it_wrong(
242
-        $function,
243
-        $message,
244
-        $version,
245
-        $applies_when = '',
246
-        $error_type = null
247
-    ) {
248
-        $applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
249
-        $error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
250
-        // because we swapped the parameter order around for the last two params,
251
-        // let's verify that some third party isn't still passing an error type value for the third param
252
-        if (is_int($applies_when)) {
253
-            $error_type = $applies_when;
254
-            $applies_when = espresso_version();
255
-        }
256
-        // if not displaying notices yet, then just leave
257
-        if (version_compare(espresso_version(), $applies_when, '<')) {
258
-            return;
259
-        }
260
-        do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
261
-        $version = $version === null
262
-            ? ''
263
-            : sprintf(
264
-                __('(This message was added in version %s of Event Espresso)', 'event_espresso'),
265
-                $version
266
-            );
267
-        $error_message = sprintf(
268
-            esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
269
-            $function,
270
-            '<strong>',
271
-            '</strong>',
272
-            $message,
273
-            $version
274
-        );
275
-        // don't trigger error if doing ajax,
276
-        // instead we'll add a transient EE_Error notice that in theory should show on the next request.
277
-        if (defined('DOING_AJAX') && DOING_AJAX) {
278
-            $error_message .= ' ' . esc_html__(
279
-                'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
280
-                'event_espresso'
281
-            );
282
-            $error_message .= '<ul><li>';
283
-            $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
284
-            $error_message .= '</ul>';
285
-            EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
286
-            // now we set this on the transient so it shows up on the next request.
287
-            EE_Error::get_notices(false, true);
288
-        } else {
289
-            trigger_error($error_message, $error_type);
290
-        }
291
-    }
292
-
293
-
294
-
295
-
296
-    /**
297
-     * Logger helpers
298
-     */
299
-    /**
300
-     * debug
301
-     *
302
-     * @param string $class
303
-     * @param string $func
304
-     * @param string $line
305
-     * @param array  $info
306
-     * @param bool   $display_request
307
-     * @param string $debug_index
308
-     * @param string $debug_key
309
-     * @throws EE_Error
310
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
311
-     */
312
-    public static function log(
313
-        $class = '',
314
-        $func = '',
315
-        $line = '',
316
-        $info = array(),
317
-        $display_request = false,
318
-        $debug_index = '',
319
-        $debug_key = 'EE_DEBUG_SPCO'
320
-    ) {
321
-        if (WP_DEBUG) {
322
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
323
-            $debug_data = get_option($debug_key, array());
324
-            $default_data = array(
325
-                $class => $func . '() : ' . $line,
326
-                'REQ'  => $display_request ? $_REQUEST : '',
327
-            );
328
-            // don't serialize objects
329
-            $info = self::strip_objects($info);
330
-            $index = ! empty($debug_index) ? $debug_index : 0;
331
-            if (! isset($debug_data[ $index ])) {
332
-                $debug_data[ $index ] = array();
333
-            }
334
-            $debug_data[ $index ][ microtime() ] = array_merge($default_data, $info);
335
-            update_option($debug_key, $debug_data);
336
-        }
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * strip_objects
343
-     *
344
-     * @param array $info
345
-     * @return array
346
-     */
347
-    public static function strip_objects($info = array())
348
-    {
349
-        foreach ($info as $key => $value) {
350
-            if (is_array($value)) {
351
-                $info[ $key ] = self::strip_objects($value);
352
-            } elseif (is_object($value)) {
353
-                $object_class = get_class($value);
354
-                $info[ $object_class ] = array();
355
-                $info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
356
-                if (method_exists($value, 'ID')) {
357
-                    $info[ $object_class ]['ID'] = $value->ID();
358
-                }
359
-                if (method_exists($value, 'status')) {
360
-                    $info[ $object_class ]['status'] = $value->status();
361
-                } elseif (method_exists($value, 'status_ID')) {
362
-                    $info[ $object_class ]['status'] = $value->status_ID();
363
-                }
364
-                unset($info[ $key ]);
365
-            }
366
-        }
367
-        return (array) $info;
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     * @param mixed      $var
374
-     * @param string     $var_name
375
-     * @param string     $file
376
-     * @param int|string $line
377
-     * @param int|string $heading_tag
378
-     * @param bool       $die
379
-     * @param string     $margin
380
-     */
381
-    public static function printv(
382
-        $var,
383
-        $var_name = '',
384
-        $file = '',
385
-        $line = '',
386
-        $heading_tag = 5,
387
-        $die = false,
388
-        $margin = ''
389
-    ) {
390
-        $var_name = ! $var_name ? 'string' : $var_name;
391
-        $var_name = ucwords(str_replace('$', '', $var_name));
392
-        $is_method = method_exists($var_name, $var);
393
-        $var_name = ucwords(str_replace('_', ' ', $var_name));
394
-        $heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
395
-        $result = EEH_Debug_Tools::headingSpacer($heading_tag);
396
-        $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
397
-        $result .= $is_method
398
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
399
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
400
-        $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
401
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
402
-        if ($die) {
403
-            die($result);
404
-        }
405
-        echo $result;
406
-    }
407
-
408
-
409
-    protected static function headingTag($heading_tag)
410
-    {
411
-        $heading_tag = absint($heading_tag);
412
-        return $heading_tag > 0 && $heading_tag < 7 ? "h{$heading_tag}" : 'h5';
413
-    }
414
-
415
-
416
-    protected static function headingSpacer($heading_tag)
417
-    {
418
-        return EEH_Debug_Tools::plainOutput() && ($heading_tag === 'h1' || $heading_tag === 'h2')
419
-            ? "\n"
420
-            : '';
421
-    }
422
-
423
-
424
-    protected static function plainOutput()
425
-    {
426
-        return defined('EE_TESTS_DIR')
427
-               || (defined('DOING_AJAX') && DOING_AJAX)
428
-               || (
429
-                   isset($_SERVER['REQUEST_URI'])
430
-                   && strpos(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 'wp-json') !== false
431
-               );
432
-    }
433
-
434
-
435
-    /**
436
-     * @param string $var_name
437
-     * @param string $heading_tag
438
-     * @param string $margin
439
-     * @param int    $line
440
-     * @return string
441
-     */
442
-    protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0)
443
-    {
444
-        if (EEH_Debug_Tools::plainOutput()) {
445
-            $heading = '';
446
-            if ($heading_tag === 'h1' || $heading_tag === 'h2') {
447
-                $heading .= "\n";
448
-            }
449
-            $heading .= "\n{$line}) {$var_name}";
450
-            return $heading;
451
-        }
452
-        $margin = "25px 0 0 {$margin}";
453
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
454
-    }
455
-
456
-
457
-
458
-    /**
459
-     * @param string $heading_tag
460
-     * @return string
461
-     */
462
-    protected static function headingX($heading_tag = 'h5')
463
-    {
464
-        if (EEH_Debug_Tools::plainOutput()) {
465
-            return '';
466
-        }
467
-        return '</' . $heading_tag . '>';
468
-    }
469
-
470
-
471
-
472
-    /**
473
-     * @param string $content
474
-     * @return string
475
-     */
476
-    protected static function grey_span($content = '')
477
-    {
478
-        if (EEH_Debug_Tools::plainOutput()) {
479
-            return $content;
480
-        }
481
-        return '<span style="color:#999">' . $content . '</span>';
482
-    }
483
-
484
-
485
-
486
-    /**
487
-     * @param string $file
488
-     * @param int    $line
489
-     * @return string
490
-     */
491
-    protected static function file_and_line($file, $line, $heading_tag)
492
-    {
493
-        if ($file === '' || $line === '') {
494
-            return '';
495
-        }
496
-        $file = str_replace(EE_PLUGIN_DIR_PATH, '/', $file);
497
-        if (EEH_Debug_Tools::plainOutput()) {
498
-            if ($heading_tag === 'h1' || $heading_tag === 'h2') {
499
-                return " ({$file})";
500
-            }
501
-            return '';
502
-        }
503
-        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
504
-               . $file
505
-               . '<br />line no: '
506
-               . $line
507
-               . '</span>';
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * @param string $content
514
-     * @return string
515
-     */
516
-    protected static function orange_span($content = '')
517
-    {
518
-        if (EEH_Debug_Tools::plainOutput()) {
519
-            return $content;
520
-        }
521
-        return '<span style="color:#E76700">' . $content . '</span>';
522
-    }
523
-
524
-
525
-
526
-    /**
527
-     * @param mixed $var
528
-     * @return string
529
-     */
530
-    protected static function pre_span($var)
531
-    {
532
-        ob_start();
533
-        var_dump($var);
534
-        $var = ob_get_clean();
535
-        if (EEH_Debug_Tools::plainOutput()) {
536
-            return $var;
537
-        }
538
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
539
-    }
540
-
541
-
542
-
543
-    /**
544
-     * @param mixed      $var
545
-     * @param string     $var_name
546
-     * @param string     $file
547
-     * @param int|string $line
548
-     * @param int|string $heading_tag
549
-     * @param bool       $die
550
-     */
551
-    public static function printr(
552
-        $var,
553
-        $var_name = '',
554
-        $file = '',
555
-        $line = '',
556
-        $heading_tag = 5,
557
-        $die = false
558
-    ) {
559
-        // return;
560
-        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
561
-        $margin = is_admin() ? ' 180px' : '0';
562
-        // $print_r = false;
563
-        if (is_string($var)) {
564
-            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
565
-            return;
566
-        }
567
-        if (is_object($var)) {
568
-            $var_name = ! $var_name ? 'object' : $var_name;
569
-            // $print_r = true;
570
-        } elseif (is_array($var)) {
571
-            $var_name = ! $var_name ? 'array' : $var_name;
572
-            // $print_r = true;
573
-        } elseif (is_numeric($var)) {
574
-            $var_name = ! $var_name ? 'numeric' : $var_name;
575
-        } elseif ($var === null) {
576
-            $var_name = ! $var_name ? 'null' : $var_name;
577
-        }
578
-        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
579
-        $heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
580
-        $result = EEH_Debug_Tools::headingSpacer($heading_tag);
581
-        $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
582
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
583
-            EEH_Debug_Tools::pre_span($var)
584
-        );
585
-        $result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
586
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
587
-        if ($die) {
588
-            die($result);
589
-        }
590
-        echo $result;
591
-    }
592
-
593
-
594
-
595
-    /******************** deprecated ********************/
596
-
597
-
598
-
599
-    /**
600
-     * @deprecated 4.9.39.rc.034
601
-     */
602
-    public function reset_times()
603
-    {
604
-        Benchmark::resetTimes();
605
-    }
606
-
607
-
608
-
609
-    /**
610
-     * @deprecated 4.9.39.rc.034
611
-     * @param null $timer_name
612
-     */
613
-    public function start_timer($timer_name = null)
614
-    {
615
-        Benchmark::startTimer($timer_name);
616
-    }
617
-
618
-
619
-
620
-    /**
621
-     * @deprecated 4.9.39.rc.034
622
-     * @param string $timer_name
623
-     */
624
-    public function stop_timer($timer_name = '')
625
-    {
626
-        Benchmark::stopTimer($timer_name);
627
-    }
628
-
629
-
630
-
631
-    /**
632
-     * @deprecated 4.9.39.rc.034
633
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
634
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
635
-     * @return void
636
-     */
637
-    public function measure_memory($label, $output_now = false)
638
-    {
639
-        Benchmark::measureMemory($label, $output_now);
640
-    }
641
-
642
-
643
-
644
-    /**
645
-     * @deprecated 4.9.39.rc.034
646
-     * @param int $size
647
-     * @return string
648
-     */
649
-    public function convert($size)
650
-    {
651
-        return Benchmark::convert($size);
652
-    }
653
-
654
-
655
-
656
-    /**
657
-     * @deprecated 4.9.39.rc.034
658
-     * @param bool $output_now
659
-     * @return string
660
-     */
661
-    public function show_times($output_now = true)
662
-    {
663
-        return Benchmark::displayResults($output_now);
664
-    }
665
-
666
-
667
-
668
-    /**
669
-     * @deprecated 4.9.39.rc.034
670
-     * @param string $timer_name
671
-     * @param float  $total_time
672
-     * @return string
673
-     */
674
-    public function format_time($timer_name, $total_time)
675
-    {
676
-        return Benchmark::formatTime($timer_name, $total_time);
677
-    }
14
+	/**
15
+	 *    instance of the EEH_Autoloader object
16
+	 *
17
+	 * @var    $_instance
18
+	 * @access    private
19
+	 */
20
+	private static $_instance;
21
+
22
+	/**
23
+	 * @var array
24
+	 */
25
+	protected $_memory_usage_points = array();
26
+
27
+
28
+
29
+	/**
30
+	 * @singleton method used to instantiate class object
31
+	 * @access    public
32
+	 * @return EEH_Debug_Tools
33
+	 */
34
+	public static function instance()
35
+	{
36
+		// check if class object is instantiated, and instantiated properly
37
+		if (! self::$_instance instanceof EEH_Debug_Tools) {
38
+			self::$_instance = new self();
39
+		}
40
+		return self::$_instance;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * private class constructor
47
+	 */
48
+	private function __construct()
49
+	{
50
+		// load Kint PHP debugging library
51
+		if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
52
+			// despite EE4 having a check for an existing copy of the Kint debugging class,
53
+			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
54
+			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
55
+			// so we've moved it to our test folder so that it is not included with production releases
56
+			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
57
+			require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
58
+		}
59
+		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
60
+		// add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
61
+		// }
62
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
63
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
64
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
65
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 *    show_db_name
72
+	 *
73
+	 * @return void
74
+	 */
75
+	public static function show_db_name()
76
+	{
77
+		if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
78
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
79
+				 . DB_NAME
80
+				 . '</p>';
81
+		}
82
+		if (EE_DEBUG) {
83
+			Benchmark::displayResults();
84
+		}
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 *    dump EE_Session object at bottom of page after everything else has happened
91
+	 *
92
+	 * @return void
93
+	 */
94
+	public function espresso_session_footer_dump()
95
+	{
96
+		if ((defined('WP_DEBUG') && WP_DEBUG)
97
+			&& ! defined('DOING_AJAX')
98
+			&& class_exists('Kint')
99
+			&& function_exists('wp_get_current_user')
100
+			&& current_user_can('update_core')
101
+			&& class_exists('EE_Registry')
102
+		) {
103
+			Kint::dump(EE_Registry::instance()->SSN->id());
104
+			Kint::dump(EE_Registry::instance()->SSN);
105
+			//          Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
106
+			$this->espresso_list_hooked_functions();
107
+			Benchmark::displayResults();
108
+		}
109
+	}
110
+
111
+
112
+
113
+	/**
114
+	 *    List All Hooked Functions
115
+	 *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
116
+	 *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
117
+	 *
118
+	 * @param string $tag
119
+	 * @return void
120
+	 */
121
+	public function espresso_list_hooked_functions($tag = '')
122
+	{
123
+		global $wp_filter;
124
+		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
125
+		if ($tag) {
126
+			$hook[ $tag ] = $wp_filter[ $tag ];
127
+			if (! is_array($hook[ $tag ])) {
128
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
129
+				return;
130
+			}
131
+			echo '<h5>For Tag: ' . $tag . '</h5>';
132
+		} else {
133
+			$hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
134
+			ksort($hook);
135
+		}
136
+		foreach ($hook as $tag_name => $priorities) {
137
+			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
138
+			ksort($priorities);
139
+			foreach ($priorities as $priority => $function) {
140
+				echo $priority;
141
+				foreach ($function as $name => $properties) {
142
+					echo "\t$name<br />";
143
+				}
144
+			}
145
+		}
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 *    registered_filter_callbacks
152
+	 *
153
+	 * @param string $hook_name
154
+	 * @return array
155
+	 */
156
+	public static function registered_filter_callbacks($hook_name = '')
157
+	{
158
+		$filters = array();
159
+		global $wp_filter;
160
+		if (isset($wp_filter[ $hook_name ])) {
161
+			$filters[ $hook_name ] = array();
162
+			foreach ($wp_filter[ $hook_name ] as $priority => $callbacks) {
163
+				$filters[ $hook_name ][ $priority ] = array();
164
+				foreach ($callbacks as $callback) {
165
+					$filters[ $hook_name ][ $priority ][] = $callback['function'];
166
+				}
167
+			}
168
+		}
169
+		return $filters;
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 *    captures plugin activation errors for debugging
176
+	 *
177
+	 * @return void
178
+	 * @throws EE_Error
179
+	 */
180
+	public static function ee_plugin_activation_errors()
181
+	{
182
+		if (WP_DEBUG) {
183
+			$activation_errors = ob_get_contents();
184
+			if (! empty($activation_errors)) {
185
+				$activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
186
+			}
187
+			espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
188
+			if (class_exists('EEH_File')) {
189
+				try {
190
+					EEH_File::ensure_file_exists_and_is_writable(
191
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
192
+					);
193
+					EEH_File::write_to_file(
194
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
195
+						$activation_errors
196
+					);
197
+				} catch (EE_Error $e) {
198
+					EE_Error::add_error(
199
+						sprintf(
200
+							__(
201
+								'The Event Espresso activation errors file could not be setup because: %s',
202
+								'event_espresso'
203
+							),
204
+							$e->getMessage()
205
+						),
206
+						__FILE__,
207
+						__FUNCTION__,
208
+						__LINE__
209
+					);
210
+				}
211
+			} else {
212
+				// old school attempt
213
+				file_put_contents(
214
+					EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
215
+					$activation_errors
216
+				);
217
+			}
218
+			$activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
219
+			update_option('ee_plugin_activation_errors', $activation_errors);
220
+		}
221
+	}
222
+
223
+
224
+
225
+	/**
226
+	 * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
227
+	 * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
228
+	 * or we want to make sure they use something the right way.
229
+	 *
230
+	 * @access public
231
+	 * @param string $function      The function that was called
232
+	 * @param string $message       A message explaining what has been done incorrectly
233
+	 * @param string $version       The version of Event Espresso where the error was added
234
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
235
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
236
+	 *                              but not have any notices appear until a later version. This allows developers
237
+	 *                              extra time to update their code before notices appear.
238
+	 * @param int    $error_type
239
+	 * @uses   trigger_error()
240
+	 */
241
+	public function doing_it_wrong(
242
+		$function,
243
+		$message,
244
+		$version,
245
+		$applies_when = '',
246
+		$error_type = null
247
+	) {
248
+		$applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
249
+		$error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
250
+		// because we swapped the parameter order around for the last two params,
251
+		// let's verify that some third party isn't still passing an error type value for the third param
252
+		if (is_int($applies_when)) {
253
+			$error_type = $applies_when;
254
+			$applies_when = espresso_version();
255
+		}
256
+		// if not displaying notices yet, then just leave
257
+		if (version_compare(espresso_version(), $applies_when, '<')) {
258
+			return;
259
+		}
260
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
261
+		$version = $version === null
262
+			? ''
263
+			: sprintf(
264
+				__('(This message was added in version %s of Event Espresso)', 'event_espresso'),
265
+				$version
266
+			);
267
+		$error_message = sprintf(
268
+			esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
269
+			$function,
270
+			'<strong>',
271
+			'</strong>',
272
+			$message,
273
+			$version
274
+		);
275
+		// don't trigger error if doing ajax,
276
+		// instead we'll add a transient EE_Error notice that in theory should show on the next request.
277
+		if (defined('DOING_AJAX') && DOING_AJAX) {
278
+			$error_message .= ' ' . esc_html__(
279
+				'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
280
+				'event_espresso'
281
+			);
282
+			$error_message .= '<ul><li>';
283
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
284
+			$error_message .= '</ul>';
285
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
286
+			// now we set this on the transient so it shows up on the next request.
287
+			EE_Error::get_notices(false, true);
288
+		} else {
289
+			trigger_error($error_message, $error_type);
290
+		}
291
+	}
292
+
293
+
294
+
295
+
296
+	/**
297
+	 * Logger helpers
298
+	 */
299
+	/**
300
+	 * debug
301
+	 *
302
+	 * @param string $class
303
+	 * @param string $func
304
+	 * @param string $line
305
+	 * @param array  $info
306
+	 * @param bool   $display_request
307
+	 * @param string $debug_index
308
+	 * @param string $debug_key
309
+	 * @throws EE_Error
310
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
311
+	 */
312
+	public static function log(
313
+		$class = '',
314
+		$func = '',
315
+		$line = '',
316
+		$info = array(),
317
+		$display_request = false,
318
+		$debug_index = '',
319
+		$debug_key = 'EE_DEBUG_SPCO'
320
+	) {
321
+		if (WP_DEBUG) {
322
+			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
323
+			$debug_data = get_option($debug_key, array());
324
+			$default_data = array(
325
+				$class => $func . '() : ' . $line,
326
+				'REQ'  => $display_request ? $_REQUEST : '',
327
+			);
328
+			// don't serialize objects
329
+			$info = self::strip_objects($info);
330
+			$index = ! empty($debug_index) ? $debug_index : 0;
331
+			if (! isset($debug_data[ $index ])) {
332
+				$debug_data[ $index ] = array();
333
+			}
334
+			$debug_data[ $index ][ microtime() ] = array_merge($default_data, $info);
335
+			update_option($debug_key, $debug_data);
336
+		}
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * strip_objects
343
+	 *
344
+	 * @param array $info
345
+	 * @return array
346
+	 */
347
+	public static function strip_objects($info = array())
348
+	{
349
+		foreach ($info as $key => $value) {
350
+			if (is_array($value)) {
351
+				$info[ $key ] = self::strip_objects($value);
352
+			} elseif (is_object($value)) {
353
+				$object_class = get_class($value);
354
+				$info[ $object_class ] = array();
355
+				$info[ $object_class ]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
356
+				if (method_exists($value, 'ID')) {
357
+					$info[ $object_class ]['ID'] = $value->ID();
358
+				}
359
+				if (method_exists($value, 'status')) {
360
+					$info[ $object_class ]['status'] = $value->status();
361
+				} elseif (method_exists($value, 'status_ID')) {
362
+					$info[ $object_class ]['status'] = $value->status_ID();
363
+				}
364
+				unset($info[ $key ]);
365
+			}
366
+		}
367
+		return (array) $info;
368
+	}
369
+
370
+
371
+
372
+	/**
373
+	 * @param mixed      $var
374
+	 * @param string     $var_name
375
+	 * @param string     $file
376
+	 * @param int|string $line
377
+	 * @param int|string $heading_tag
378
+	 * @param bool       $die
379
+	 * @param string     $margin
380
+	 */
381
+	public static function printv(
382
+		$var,
383
+		$var_name = '',
384
+		$file = '',
385
+		$line = '',
386
+		$heading_tag = 5,
387
+		$die = false,
388
+		$margin = ''
389
+	) {
390
+		$var_name = ! $var_name ? 'string' : $var_name;
391
+		$var_name = ucwords(str_replace('$', '', $var_name));
392
+		$is_method = method_exists($var_name, $var);
393
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
394
+		$heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
395
+		$result = EEH_Debug_Tools::headingSpacer($heading_tag);
396
+		$result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
397
+		$result .= $is_method
398
+			? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
399
+			: EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
400
+		$result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
401
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
402
+		if ($die) {
403
+			die($result);
404
+		}
405
+		echo $result;
406
+	}
407
+
408
+
409
+	protected static function headingTag($heading_tag)
410
+	{
411
+		$heading_tag = absint($heading_tag);
412
+		return $heading_tag > 0 && $heading_tag < 7 ? "h{$heading_tag}" : 'h5';
413
+	}
414
+
415
+
416
+	protected static function headingSpacer($heading_tag)
417
+	{
418
+		return EEH_Debug_Tools::plainOutput() && ($heading_tag === 'h1' || $heading_tag === 'h2')
419
+			? "\n"
420
+			: '';
421
+	}
422
+
423
+
424
+	protected static function plainOutput()
425
+	{
426
+		return defined('EE_TESTS_DIR')
427
+			   || (defined('DOING_AJAX') && DOING_AJAX)
428
+			   || (
429
+				   isset($_SERVER['REQUEST_URI'])
430
+				   && strpos(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), 'wp-json') !== false
431
+			   );
432
+	}
433
+
434
+
435
+	/**
436
+	 * @param string $var_name
437
+	 * @param string $heading_tag
438
+	 * @param string $margin
439
+	 * @param int    $line
440
+	 * @return string
441
+	 */
442
+	protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0)
443
+	{
444
+		if (EEH_Debug_Tools::plainOutput()) {
445
+			$heading = '';
446
+			if ($heading_tag === 'h1' || $heading_tag === 'h2') {
447
+				$heading .= "\n";
448
+			}
449
+			$heading .= "\n{$line}) {$var_name}";
450
+			return $heading;
451
+		}
452
+		$margin = "25px 0 0 {$margin}";
453
+		return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
454
+	}
455
+
456
+
457
+
458
+	/**
459
+	 * @param string $heading_tag
460
+	 * @return string
461
+	 */
462
+	protected static function headingX($heading_tag = 'h5')
463
+	{
464
+		if (EEH_Debug_Tools::plainOutput()) {
465
+			return '';
466
+		}
467
+		return '</' . $heading_tag . '>';
468
+	}
469
+
470
+
471
+
472
+	/**
473
+	 * @param string $content
474
+	 * @return string
475
+	 */
476
+	protected static function grey_span($content = '')
477
+	{
478
+		if (EEH_Debug_Tools::plainOutput()) {
479
+			return $content;
480
+		}
481
+		return '<span style="color:#999">' . $content . '</span>';
482
+	}
483
+
484
+
485
+
486
+	/**
487
+	 * @param string $file
488
+	 * @param int    $line
489
+	 * @return string
490
+	 */
491
+	protected static function file_and_line($file, $line, $heading_tag)
492
+	{
493
+		if ($file === '' || $line === '') {
494
+			return '';
495
+		}
496
+		$file = str_replace(EE_PLUGIN_DIR_PATH, '/', $file);
497
+		if (EEH_Debug_Tools::plainOutput()) {
498
+			if ($heading_tag === 'h1' || $heading_tag === 'h2') {
499
+				return " ({$file})";
500
+			}
501
+			return '';
502
+		}
503
+		return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
504
+			   . $file
505
+			   . '<br />line no: '
506
+			   . $line
507
+			   . '</span>';
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * @param string $content
514
+	 * @return string
515
+	 */
516
+	protected static function orange_span($content = '')
517
+	{
518
+		if (EEH_Debug_Tools::plainOutput()) {
519
+			return $content;
520
+		}
521
+		return '<span style="color:#E76700">' . $content . '</span>';
522
+	}
523
+
524
+
525
+
526
+	/**
527
+	 * @param mixed $var
528
+	 * @return string
529
+	 */
530
+	protected static function pre_span($var)
531
+	{
532
+		ob_start();
533
+		var_dump($var);
534
+		$var = ob_get_clean();
535
+		if (EEH_Debug_Tools::plainOutput()) {
536
+			return $var;
537
+		}
538
+		return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
539
+	}
540
+
541
+
542
+
543
+	/**
544
+	 * @param mixed      $var
545
+	 * @param string     $var_name
546
+	 * @param string     $file
547
+	 * @param int|string $line
548
+	 * @param int|string $heading_tag
549
+	 * @param bool       $die
550
+	 */
551
+	public static function printr(
552
+		$var,
553
+		$var_name = '',
554
+		$file = '',
555
+		$line = '',
556
+		$heading_tag = 5,
557
+		$die = false
558
+	) {
559
+		// return;
560
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
561
+		$margin = is_admin() ? ' 180px' : '0';
562
+		// $print_r = false;
563
+		if (is_string($var)) {
564
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
565
+			return;
566
+		}
567
+		if (is_object($var)) {
568
+			$var_name = ! $var_name ? 'object' : $var_name;
569
+			// $print_r = true;
570
+		} elseif (is_array($var)) {
571
+			$var_name = ! $var_name ? 'array' : $var_name;
572
+			// $print_r = true;
573
+		} elseif (is_numeric($var)) {
574
+			$var_name = ! $var_name ? 'numeric' : $var_name;
575
+		} elseif ($var === null) {
576
+			$var_name = ! $var_name ? 'null' : $var_name;
577
+		}
578
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
579
+		$heading_tag = EEH_Debug_Tools::headingTag($heading_tag);
580
+		$result = EEH_Debug_Tools::headingSpacer($heading_tag);
581
+		$result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line);
582
+		$result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
583
+			EEH_Debug_Tools::pre_span($var)
584
+		);
585
+		$result .= EEH_Debug_Tools::file_and_line($file, $line, $heading_tag);
586
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
587
+		if ($die) {
588
+			die($result);
589
+		}
590
+		echo $result;
591
+	}
592
+
593
+
594
+
595
+	/******************** deprecated ********************/
596
+
597
+
598
+
599
+	/**
600
+	 * @deprecated 4.9.39.rc.034
601
+	 */
602
+	public function reset_times()
603
+	{
604
+		Benchmark::resetTimes();
605
+	}
606
+
607
+
608
+
609
+	/**
610
+	 * @deprecated 4.9.39.rc.034
611
+	 * @param null $timer_name
612
+	 */
613
+	public function start_timer($timer_name = null)
614
+	{
615
+		Benchmark::startTimer($timer_name);
616
+	}
617
+
618
+
619
+
620
+	/**
621
+	 * @deprecated 4.9.39.rc.034
622
+	 * @param string $timer_name
623
+	 */
624
+	public function stop_timer($timer_name = '')
625
+	{
626
+		Benchmark::stopTimer($timer_name);
627
+	}
628
+
629
+
630
+
631
+	/**
632
+	 * @deprecated 4.9.39.rc.034
633
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
634
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
635
+	 * @return void
636
+	 */
637
+	public function measure_memory($label, $output_now = false)
638
+	{
639
+		Benchmark::measureMemory($label, $output_now);
640
+	}
641
+
642
+
643
+
644
+	/**
645
+	 * @deprecated 4.9.39.rc.034
646
+	 * @param int $size
647
+	 * @return string
648
+	 */
649
+	public function convert($size)
650
+	{
651
+		return Benchmark::convert($size);
652
+	}
653
+
654
+
655
+
656
+	/**
657
+	 * @deprecated 4.9.39.rc.034
658
+	 * @param bool $output_now
659
+	 * @return string
660
+	 */
661
+	public function show_times($output_now = true)
662
+	{
663
+		return Benchmark::displayResults($output_now);
664
+	}
665
+
666
+
667
+
668
+	/**
669
+	 * @deprecated 4.9.39.rc.034
670
+	 * @param string $timer_name
671
+	 * @param float  $total_time
672
+	 * @return string
673
+	 */
674
+	public function format_time($timer_name, $total_time)
675
+	{
676
+		return Benchmark::formatTime($timer_name, $total_time);
677
+	}
678 678
 }
679 679
 
680 680
 
@@ -684,31 +684,31 @@  discard block
 block discarded – undo
684 684
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
685 685
  */
686 686
 if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
687
-    function dump_wp_query()
688
-    {
689
-        global $wp_query;
690
-        d($wp_query);
691
-    }
687
+	function dump_wp_query()
688
+	{
689
+		global $wp_query;
690
+		d($wp_query);
691
+	}
692 692
 }
693 693
 /**
694 694
  * borrowed from Kint Debugger
695 695
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
696 696
  */
697 697
 if (class_exists('Kint') && ! function_exists('dump_wp')) {
698
-    function dump_wp()
699
-    {
700
-        global $wp;
701
-        d($wp);
702
-    }
698
+	function dump_wp()
699
+	{
700
+		global $wp;
701
+		d($wp);
702
+	}
703 703
 }
704 704
 /**
705 705
  * borrowed from Kint Debugger
706 706
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
707 707
  */
708 708
 if (class_exists('Kint') && ! function_exists('dump_post')) {
709
-    function dump_post()
710
-    {
711
-        global $post;
712
-        d($post);
713
-    }
709
+	function dump_post()
710
+	{
711
+		global $post;
712
+		d($post);
713
+	}
714 714
 }
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 2 patches
Indentation   +981 added lines, -981 removed lines patch added patch discarded remove patch
@@ -17,1043 +17,1043 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * return the timezone set for the WP install
22
-     *
23
-     * @return string valid timezone string for PHP DateTimeZone() class
24
-     * @throws InvalidArgumentException
25
-     * @throws InvalidDataTypeException
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public static function get_timezone()
29
-    {
30
-        return EEH_DTT_Helper::get_valid_timezone_string();
31
-    }
20
+	/**
21
+	 * return the timezone set for the WP install
22
+	 *
23
+	 * @return string valid timezone string for PHP DateTimeZone() class
24
+	 * @throws InvalidArgumentException
25
+	 * @throws InvalidDataTypeException
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public static function get_timezone()
29
+	{
30
+		return EEH_DTT_Helper::get_valid_timezone_string();
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * get_valid_timezone_string
36
-     *    ensures that a valid timezone string is returned
37
-     *
38
-     * @param string $timezone_string
39
-     * @return string
40
-     * @throws InvalidArgumentException
41
-     * @throws InvalidDataTypeException
42
-     * @throws InvalidInterfaceException
43
-     */
44
-    public static function get_valid_timezone_string($timezone_string = '')
45
-    {
46
-        return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
-    }
34
+	/**
35
+	 * get_valid_timezone_string
36
+	 *    ensures that a valid timezone string is returned
37
+	 *
38
+	 * @param string $timezone_string
39
+	 * @return string
40
+	 * @throws InvalidArgumentException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws InvalidInterfaceException
43
+	 */
44
+	public static function get_valid_timezone_string($timezone_string = '')
45
+	{
46
+		return self::getHelperAdapter()->getValidTimezoneString($timezone_string);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
-     *
53
-     * @static
54
-     * @param  string $timezone_string Timezone string to check
55
-     * @param bool    $throw_error
56
-     * @return bool
57
-     * @throws InvalidArgumentException
58
-     * @throws InvalidDataTypeException
59
-     * @throws InvalidInterfaceException
60
-     */
61
-    public static function validate_timezone($timezone_string, $throw_error = true)
62
-    {
63
-        return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
-    }
50
+	/**
51
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
52
+	 *
53
+	 * @static
54
+	 * @param  string $timezone_string Timezone string to check
55
+	 * @param bool    $throw_error
56
+	 * @return bool
57
+	 * @throws InvalidArgumentException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws InvalidInterfaceException
60
+	 */
61
+	public static function validate_timezone($timezone_string, $throw_error = true)
62
+	{
63
+		return self::getHelperAdapter()->validateTimezone($timezone_string, $throw_error);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * This returns a string that can represent the provided gmt offset in format that can be passed into
69
-     * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
-     *
71
-     * @param float|string $gmt_offset
72
-     * @return string
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
-    {
79
-        return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
-    }
67
+	/**
68
+	 * This returns a string that can represent the provided gmt offset in format that can be passed into
69
+	 * DateTimeZone.  This is NOT a string that can be passed as a value on the WordPress timezone_string option.
70
+	 *
71
+	 * @param float|string $gmt_offset
72
+	 * @return string
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
78
+	{
79
+		return self::getHelperAdapter()->getTimezoneStringFromGmtOffset($gmt_offset);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Gets the site's GMT offset based on either the timezone string
85
-     * (in which case teh gmt offset will vary depending on the location's
86
-     * observance of daylight savings time) or the gmt_offset wp option
87
-     *
88
-     * @return int seconds offset
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     */
93
-    public static function get_site_timezone_gmt_offset()
94
-    {
95
-        return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
-    }
83
+	/**
84
+	 * Gets the site's GMT offset based on either the timezone string
85
+	 * (in which case teh gmt offset will vary depending on the location's
86
+	 * observance of daylight savings time) or the gmt_offset wp option
87
+	 *
88
+	 * @return int seconds offset
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 */
93
+	public static function get_site_timezone_gmt_offset()
94
+	{
95
+		return self::getHelperAdapter()->getSiteTimezoneGmtOffset();
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * Depending on PHP version,
101
-     * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
103
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
-     *
105
-     * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
-     *                          removed in a future version of EE.
107
-     * @param int $gmt_offset
108
-     * @return int
109
-     * @throws InvalidArgumentException
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     */
113
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
-    {
115
-        return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
-    }
99
+	/**
100
+	 * Depending on PHP version,
101
+	 * there might not be valid current timezone strings to match these gmt_offsets in its timezone tables.
102
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
103
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
104
+	 *
105
+	 * @deprecated 4.9.54.rc    Developers this was always meant to only be an internally used method.  This will be
106
+	 *                          removed in a future version of EE.
107
+	 * @param int $gmt_offset
108
+	 * @return int
109
+	 * @throws InvalidArgumentException
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 */
113
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
114
+	{
115
+		return self::getHelperAdapter()->adjustInvalidGmtOffsets($gmt_offset);
116
+	}
117 117
 
118 118
 
119
-    /**
120
-     * get_timezone_string_from_abbreviations_list
121
-     *
122
-     * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
-     *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
-     * @param int  $gmt_offset
125
-     * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
-     * @return string
127
-     * @throws EE_Error
128
-     * @throws InvalidArgumentException
129
-     * @throws InvalidDataTypeException
130
-     * @throws InvalidInterfaceException
131
-     */
132
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
-    {
134
-        $gmt_offset =  (int) $gmt_offset;
135
-        /** @var array[] $abbreviations */
136
-        $abbreviations = DateTimeZone::listAbbreviations();
137
-        foreach ($abbreviations as $abbreviation) {
138
-            foreach ($abbreviation as $timezone) {
139
-                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
-                    try {
141
-                        $offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
-                        if ($offset !== $gmt_offset) {
143
-                            continue;
144
-                        }
145
-                        return $timezone['timezone_id'];
146
-                    } catch (Exception $e) {
147
-                        continue;
148
-                    }
149
-                }
150
-            }
151
-        }
152
-        // if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
-        if ($coerce === true) {
154
-            $timezone_string = self::get_timezone_string_from_abbreviations_list(
155
-                self::adjust_invalid_gmt_offsets($gmt_offset),
156
-                false
157
-            );
158
-            if ($timezone_string) {
159
-                return $timezone_string;
160
-            }
161
-        }
162
-        throw new EE_Error(
163
-            sprintf(
164
-                esc_html__(
165
-                    'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
-                    'event_espresso'
167
-                ),
168
-                $gmt_offset / HOUR_IN_SECONDS,
169
-                '<a href="http://www.php.net/manual/en/timezones.php">',
170
-                '</a>'
171
-            )
172
-        );
173
-    }
119
+	/**
120
+	 * get_timezone_string_from_abbreviations_list
121
+	 *
122
+	 * @deprecated 4.9.54.rc  Developers, this was never intended to be public.  This is a soft deprecation for now.
123
+	 *                        If you are using this, you'll want to work out an alternate way of getting the value.
124
+	 * @param int  $gmt_offset
125
+	 * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
126
+	 * @return string
127
+	 * @throws EE_Error
128
+	 * @throws InvalidArgumentException
129
+	 * @throws InvalidDataTypeException
130
+	 * @throws InvalidInterfaceException
131
+	 */
132
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133
+	{
134
+		$gmt_offset =  (int) $gmt_offset;
135
+		/** @var array[] $abbreviations */
136
+		$abbreviations = DateTimeZone::listAbbreviations();
137
+		foreach ($abbreviations as $abbreviation) {
138
+			foreach ($abbreviation as $timezone) {
139
+				if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
140
+					try {
141
+						$offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
142
+						if ($offset !== $gmt_offset) {
143
+							continue;
144
+						}
145
+						return $timezone['timezone_id'];
146
+					} catch (Exception $e) {
147
+						continue;
148
+					}
149
+				}
150
+			}
151
+		}
152
+		// if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
153
+		if ($coerce === true) {
154
+			$timezone_string = self::get_timezone_string_from_abbreviations_list(
155
+				self::adjust_invalid_gmt_offsets($gmt_offset),
156
+				false
157
+			);
158
+			if ($timezone_string) {
159
+				return $timezone_string;
160
+			}
161
+		}
162
+		throw new EE_Error(
163
+			sprintf(
164
+				esc_html__(
165
+					'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
166
+					'event_espresso'
167
+				),
168
+				$gmt_offset / HOUR_IN_SECONDS,
169
+				'<a href="http://www.php.net/manual/en/timezones.php">',
170
+				'</a>'
171
+			)
172
+		);
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * Get Timezone Transitions
178
-     *
179
-     * @param DateTimeZone $date_time_zone
180
-     * @param int|null     $time
181
-     * @param bool         $first_only
182
-     * @return array
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     */
187
-    public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
-    {
189
-        return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
-    }
176
+	/**
177
+	 * Get Timezone Transitions
178
+	 *
179
+	 * @param DateTimeZone $date_time_zone
180
+	 * @param int|null     $time
181
+	 * @param bool         $first_only
182
+	 * @return array
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 */
187
+	public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
188
+	{
189
+		return self::getHelperAdapter()->getTimezoneTransitions($date_time_zone, $time, $first_only);
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * Get Timezone Offset for given timezone object.
195
-     *
196
-     * @param DateTimeZone $date_time_zone
197
-     * @param null         $time
198
-     * @return mixed
199
-     * @throws InvalidArgumentException
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidInterfaceException
202
-     */
203
-    public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
-    {
205
-        return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
-    }
193
+	/**
194
+	 * Get Timezone Offset for given timezone object.
195
+	 *
196
+	 * @param DateTimeZone $date_time_zone
197
+	 * @param null         $time
198
+	 * @return mixed
199
+	 * @throws InvalidArgumentException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidInterfaceException
202
+	 */
203
+	public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
204
+	{
205
+		return self::getHelperAdapter()->getTimezoneOffset($date_time_zone, $time);
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * Prints a select input for the given timezone string.
211
-     * @param string $timezone_string
212
-     * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
-     * @throws InvalidArgumentException
214
-     * @throws InvalidDataTypeException
215
-     * @throws InvalidInterfaceException
216
-     */
217
-    public static function timezone_select_input($timezone_string = '')
218
-    {
219
-        self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
-    }
209
+	/**
210
+	 * Prints a select input for the given timezone string.
211
+	 * @param string $timezone_string
212
+	 * @deprecatd 4.9.54.rc   Soft deprecation.  Consider using \EEH_DTT_Helper::wp_timezone_choice instead.
213
+	 * @throws InvalidArgumentException
214
+	 * @throws InvalidDataTypeException
215
+	 * @throws InvalidInterfaceException
216
+	 */
217
+	public static function timezone_select_input($timezone_string = '')
218
+	{
219
+		self::getHelperAdapter()->timezoneSelectInput($timezone_string);
220
+	}
221 221
 
222 222
 
223
-    /**
224
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
-     * the site is used.
227
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
-     * computed timestamp (i.e. date_i18n() )
229
-     *
230
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
231
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
-     *                                                site will be used.
233
-     * @return int $unix_timestamp with the offset applied for the given timezone.
234
-     * @throws InvalidArgumentException
235
-     * @throws InvalidDataTypeException
236
-     * @throws InvalidInterfaceException
237
-     */
238
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
-    {
240
-        return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
-    }
223
+	/**
224
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
225
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
226
+	 * the site is used.
227
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
228
+	 * computed timestamp (i.e. date_i18n() )
229
+	 *
230
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
231
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
232
+	 *                                                site will be used.
233
+	 * @return int $unix_timestamp with the offset applied for the given timezone.
234
+	 * @throws InvalidArgumentException
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws InvalidInterfaceException
237
+	 */
238
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
239
+	{
240
+		return self::getHelperAdapter()->getTimestampWithOffset($unix_timestamp, $timezone_string);
241
+	}
242 242
 
243 243
 
244
-    /**
245
-     *    _set_date_time_field
246
-     *    modifies EE_Base_Class EE_Datetime_Field objects
247
-     *
248
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
249
-     * @param    DateTime    $DateTime            PHP DateTime object
250
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
-     * @return EE_Base_Class
252
-     * @throws EE_Error
253
-     */
254
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
-    {
256
-        // grab current datetime format
257
-        $current_format = $obj->get_format();
258
-        // set new full timestamp format
259
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
-        // set the new date value using a full timestamp format so that no data is lost
262
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
-        // reset datetime formats
264
-        $obj->set_date_format($current_format[0]);
265
-        $obj->set_time_format($current_format[1]);
266
-        return $obj;
267
-    }
244
+	/**
245
+	 *    _set_date_time_field
246
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
247
+	 *
248
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
249
+	 * @param    DateTime    $DateTime            PHP DateTime object
250
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
251
+	 * @return EE_Base_Class
252
+	 * @throws EE_Error
253
+	 */
254
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
255
+	{
256
+		// grab current datetime format
257
+		$current_format = $obj->get_format();
258
+		// set new full timestamp format
259
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
260
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
261
+		// set the new date value using a full timestamp format so that no data is lost
262
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
263
+		// reset datetime formats
264
+		$obj->set_date_format($current_format[0]);
265
+		$obj->set_time_format($current_format[1]);
266
+		return $obj;
267
+	}
268 268
 
269 269
 
270
-    /**
271
-     *    date_time_add
272
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
-     *
275
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
276
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
-     *                                            minutes, seconds) defaults to years
279
-     * @param  integer       $value               what you want to increment the time by
280
-     * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
-     *                                            (chaining)
282
-     * @throws EE_Error
283
-     * @throws Exception
284
-     */
285
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
-    {
287
-        // get the raw UTC date.
288
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
289
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
-    }
270
+	/**
271
+	 *    date_time_add
272
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
273
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
274
+	 *
275
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
276
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
277
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
278
+	 *                                            minutes, seconds) defaults to years
279
+	 * @param  integer       $value               what you want to increment the time by
280
+	 * @return EE_Base_Class return the EE_Base_Class object so right away you can do something with it
281
+	 *                                            (chaining)
282
+	 * @throws EE_Error
283
+	 * @throws Exception
284
+	 */
285
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
286
+	{
287
+		// get the raw UTC date.
288
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
289
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
290
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
291
+	}
292 292
 
293 293
 
294
-    /**
295
-     *    date_time_subtract
296
-     *    same as date_time_add except subtracting value instead of adding.
297
-     *
298
-     * @param EE_Base_Class $obj
299
-     * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
-     * @param string        $period
301
-     * @param int           $value
302
-     * @return EE_Base_Class
303
-     * @throws EE_Error
304
-     * @throws Exception
305
-     */
306
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
-    {
308
-        // get the raw UTC date
309
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
310
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
-    }
294
+	/**
295
+	 *    date_time_subtract
296
+	 *    same as date_time_add except subtracting value instead of adding.
297
+	 *
298
+	 * @param EE_Base_Class $obj
299
+	 * @param  string       $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
300
+	 * @param string        $period
301
+	 * @param int           $value
302
+	 * @return EE_Base_Class
303
+	 * @throws EE_Error
304
+	 * @throws Exception
305
+	 */
306
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
307
+	{
308
+		// get the raw UTC date
309
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
310
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
311
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
312
+	}
313 313
 
314 314
 
315
-    /**
316
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
-     *
318
-     * @param  DateTime   $DateTime DateTime object
319
-     * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
-     *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
-     * @param  int|string $value    What you want to increment the date by
322
-     * @param  string     $operand  What operand you wish to use for the calculation
323
-     * @return DateTime return whatever type came in.
324
-     * @throws Exception
325
-     * @throws EE_Error
326
-     */
327
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
-    {
329
-        if (! $DateTime instanceof DateTime) {
330
-            throw new EE_Error(
331
-                sprintf(
332
-                    esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
-                    print_r($DateTime, true)
334
-                )
335
-            );
336
-        }
337
-        switch ($period) {
338
-            case 'years':
339
-                $value = 'P' . $value . 'Y';
340
-                break;
341
-            case 'months':
342
-                $value = 'P' . $value . 'M';
343
-                break;
344
-            case 'weeks':
345
-                $value = 'P' . $value . 'W';
346
-                break;
347
-            case 'days':
348
-                $value = 'P' . $value . 'D';
349
-                break;
350
-            case 'hours':
351
-                $value = 'PT' . $value . 'H';
352
-                break;
353
-            case 'minutes':
354
-                $value = 'PT' . $value . 'M';
355
-                break;
356
-            case 'seconds':
357
-                $value = 'PT' . $value . 'S';
358
-                break;
359
-        }
360
-        switch ($operand) {
361
-            case '+':
362
-                $DateTime->add(new DateInterval($value));
363
-                break;
364
-            case '-':
365
-                $DateTime->sub(new DateInterval($value));
366
-                break;
367
-        }
368
-        return $DateTime;
369
-    }
315
+	/**
316
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
317
+	 *
318
+	 * @param  DateTime   $DateTime DateTime object
319
+	 * @param  string     $period   a value to indicate what interval is being used in the calculation. The options are
320
+	 *                              'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
321
+	 * @param  int|string $value    What you want to increment the date by
322
+	 * @param  string     $operand  What operand you wish to use for the calculation
323
+	 * @return DateTime return whatever type came in.
324
+	 * @throws Exception
325
+	 * @throws EE_Error
326
+	 */
327
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328
+	{
329
+		if (! $DateTime instanceof DateTime) {
330
+			throw new EE_Error(
331
+				sprintf(
332
+					esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
333
+					print_r($DateTime, true)
334
+				)
335
+			);
336
+		}
337
+		switch ($period) {
338
+			case 'years':
339
+				$value = 'P' . $value . 'Y';
340
+				break;
341
+			case 'months':
342
+				$value = 'P' . $value . 'M';
343
+				break;
344
+			case 'weeks':
345
+				$value = 'P' . $value . 'W';
346
+				break;
347
+			case 'days':
348
+				$value = 'P' . $value . 'D';
349
+				break;
350
+			case 'hours':
351
+				$value = 'PT' . $value . 'H';
352
+				break;
353
+			case 'minutes':
354
+				$value = 'PT' . $value . 'M';
355
+				break;
356
+			case 'seconds':
357
+				$value = 'PT' . $value . 'S';
358
+				break;
359
+		}
360
+		switch ($operand) {
361
+			case '+':
362
+				$DateTime->add(new DateInterval($value));
363
+				break;
364
+			case '-':
365
+				$DateTime->sub(new DateInterval($value));
366
+				break;
367
+		}
368
+		return $DateTime;
369
+	}
370 370
 
371 371
 
372
-    /**
373
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
-     *
375
-     * @param  int     $timestamp Unix timestamp
376
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
-     * @param  integer $value     What you want to increment the date by
379
-     * @param  string  $operand   What operand you wish to use for the calculation
380
-     * @return int
381
-     * @throws EE_Error
382
-     */
383
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
-    {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
-            throw new EE_Error(
387
-                sprintf(
388
-                    esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
-                    print_r($timestamp, true)
390
-                )
391
-            );
392
-        }
393
-        switch ($period) {
394
-            case 'years':
395
-                $value = YEAR_IN_SECONDS * $value;
396
-                break;
397
-            case 'months':
398
-                $value = YEAR_IN_SECONDS / 12 * $value;
399
-                break;
400
-            case 'weeks':
401
-                $value = WEEK_IN_SECONDS * $value;
402
-                break;
403
-            case 'days':
404
-                $value = DAY_IN_SECONDS * $value;
405
-                break;
406
-            case 'hours':
407
-                $value = HOUR_IN_SECONDS * $value;
408
-                break;
409
-            case 'minutes':
410
-                $value = MINUTE_IN_SECONDS * $value;
411
-                break;
412
-        }
413
-        switch ($operand) {
414
-            case '+':
415
-                $timestamp += $value;
416
-                break;
417
-            case '-':
418
-                $timestamp -= $value;
419
-                break;
420
-        }
421
-        return $timestamp;
422
-    }
372
+	/**
373
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
374
+	 *
375
+	 * @param  int     $timestamp Unix timestamp
376
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
377
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
378
+	 * @param  integer $value     What you want to increment the date by
379
+	 * @param  string  $operand   What operand you wish to use for the calculation
380
+	 * @return int
381
+	 * @throws EE_Error
382
+	 */
383
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384
+	{
385
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386
+			throw new EE_Error(
387
+				sprintf(
388
+					esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
389
+					print_r($timestamp, true)
390
+				)
391
+			);
392
+		}
393
+		switch ($period) {
394
+			case 'years':
395
+				$value = YEAR_IN_SECONDS * $value;
396
+				break;
397
+			case 'months':
398
+				$value = YEAR_IN_SECONDS / 12 * $value;
399
+				break;
400
+			case 'weeks':
401
+				$value = WEEK_IN_SECONDS * $value;
402
+				break;
403
+			case 'days':
404
+				$value = DAY_IN_SECONDS * $value;
405
+				break;
406
+			case 'hours':
407
+				$value = HOUR_IN_SECONDS * $value;
408
+				break;
409
+			case 'minutes':
410
+				$value = MINUTE_IN_SECONDS * $value;
411
+				break;
412
+		}
413
+		switch ($operand) {
414
+			case '+':
415
+				$timestamp += $value;
416
+				break;
417
+			case '-':
418
+				$timestamp -= $value;
419
+				break;
420
+		}
421
+		return $timestamp;
422
+	}
423 423
 
424 424
 
425
-    /**
426
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
-     * parameters and returns the new timestamp or DateTime.
428
-     *
429
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
-     * @param  string         $period                a value to indicate what interval is being used in the
431
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
-     *                                               'minutes', 'seconds'. Defaults to years.
433
-     * @param  integer        $value                 What you want to increment the date by
434
-     * @param  string         $operand               What operand you wish to use for the calculation
435
-     * @return mixed string|DateTime          return whatever type came in.
436
-     * @throws Exception
437
-     * @throws EE_Error
438
-     */
439
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
-    {
441
-        if ($DateTime_or_timestamp instanceof DateTime) {
442
-            return EEH_DTT_Helper::_modify_datetime_object(
443
-                $DateTime_or_timestamp,
444
-                $period,
445
-                $value,
446
-                $operand
447
-            );
448
-        }
449
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
-            return EEH_DTT_Helper::_modify_timestamp(
451
-                $DateTime_or_timestamp,
452
-                $period,
453
-                $value,
454
-                $operand
455
-            );
456
-        }
457
-        // error
458
-        return $DateTime_or_timestamp;
459
-    }
425
+	/**
426
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
427
+	 * parameters and returns the new timestamp or DateTime.
428
+	 *
429
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
430
+	 * @param  string         $period                a value to indicate what interval is being used in the
431
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
432
+	 *                                               'minutes', 'seconds'. Defaults to years.
433
+	 * @param  integer        $value                 What you want to increment the date by
434
+	 * @param  string         $operand               What operand you wish to use for the calculation
435
+	 * @return mixed string|DateTime          return whatever type came in.
436
+	 * @throws Exception
437
+	 * @throws EE_Error
438
+	 */
439
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
440
+	{
441
+		if ($DateTime_or_timestamp instanceof DateTime) {
442
+			return EEH_DTT_Helper::_modify_datetime_object(
443
+				$DateTime_or_timestamp,
444
+				$period,
445
+				$value,
446
+				$operand
447
+			);
448
+		}
449
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
450
+			return EEH_DTT_Helper::_modify_timestamp(
451
+				$DateTime_or_timestamp,
452
+				$period,
453
+				$value,
454
+				$operand
455
+			);
456
+		}
457
+		// error
458
+		return $DateTime_or_timestamp;
459
+	}
460 460
 
461 461
 
462
-    /**
463
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
464
-     * and spit out the js and moment.js equivalent formats.
465
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
-     * time picker.
468
-     *
469
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
-     * @param string $date_format_string
471
-     * @param string $time_format_string
472
-     * @return array
473
-     *              array(
474
-     *              'js' => array (
475
-     *              'date' => //date format
476
-     *              'time' => //time format
477
-     *              ),
478
-     *              'moment' => //date and time format.
479
-     *              )
480
-     */
481
-    public static function convert_php_to_js_and_moment_date_formats(
482
-        $date_format_string = null,
483
-        $time_format_string = null
484
-    ) {
485
-        if ($date_format_string === null) {
486
-            $date_format_string = (string) get_option('date_format');
487
-        }
488
-        if ($time_format_string === null) {
489
-            $time_format_string = (string) get_option('time_format');
490
-        }
491
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
492
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
493
-        return array(
494
-            'js'     => array(
495
-                'date' => $date_format['js'],
496
-                'time' => $time_format['js'],
497
-            ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
-            'moment_split' => array(
500
-                'date' => $date_format['moment'],
501
-                'time' => $time_format['moment']
502
-            )
503
-        );
504
-    }
462
+	/**
463
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
464
+	 * and spit out the js and moment.js equivalent formats.
465
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
466
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
467
+	 * time picker.
468
+	 *
469
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
470
+	 * @param string $date_format_string
471
+	 * @param string $time_format_string
472
+	 * @return array
473
+	 *              array(
474
+	 *              'js' => array (
475
+	 *              'date' => //date format
476
+	 *              'time' => //time format
477
+	 *              ),
478
+	 *              'moment' => //date and time format.
479
+	 *              )
480
+	 */
481
+	public static function convert_php_to_js_and_moment_date_formats(
482
+		$date_format_string = null,
483
+		$time_format_string = null
484
+	) {
485
+		if ($date_format_string === null) {
486
+			$date_format_string = (string) get_option('date_format');
487
+		}
488
+		if ($time_format_string === null) {
489
+			$time_format_string = (string) get_option('time_format');
490
+		}
491
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
492
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
493
+		return array(
494
+			'js'     => array(
495
+				'date' => $date_format['js'],
496
+				'time' => $time_format['js'],
497
+			),
498
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
499
+			'moment_split' => array(
500
+				'date' => $date_format['moment'],
501
+				'time' => $time_format['moment']
502
+			)
503
+		);
504
+	}
505 505
 
506 506
 
507
-    /**
508
-     * This converts incoming format string into js and moment variations.
509
-     *
510
-     * @param string $format_string incoming php format string
511
-     * @return array js and moment formats.
512
-     */
513
-    protected static function _php_to_js_moment_converter($format_string)
514
-    {
515
-        /**
516
-         * This is a map of symbols for formats.
517
-         * The index is the php symbol, the equivalent values are in the array.
518
-         *
519
-         * @var array
520
-         */
521
-        $symbols_map          = array(
522
-            // Day
523
-            // 01
524
-            'd' => array(
525
-                'js'     => 'dd',
526
-                'moment' => 'DD',
527
-            ),
528
-            // Mon
529
-            'D' => array(
530
-                'js'     => 'D',
531
-                'moment' => 'ddd',
532
-            ),
533
-            // 1,2,...31
534
-            'j' => array(
535
-                'js'     => 'd',
536
-                'moment' => 'D',
537
-            ),
538
-            // Monday
539
-            'l' => array(
540
-                'js'     => 'DD',
541
-                'moment' => 'dddd',
542
-            ),
543
-            // ISO numeric representation of the day of the week (1-6)
544
-            'N' => array(
545
-                'js'     => '',
546
-                'moment' => 'E',
547
-            ),
548
-            // st,nd.rd
549
-            'S' => array(
550
-                'js'     => '',
551
-                'moment' => 'o',
552
-            ),
553
-            // numeric representation of day of week (0-6)
554
-            'w' => array(
555
-                'js'     => '',
556
-                'moment' => 'd',
557
-            ),
558
-            // day of year starting from 0 (0-365)
559
-            'z' => array(
560
-                'js'     => 'o',
561
-                'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
-            ),
563
-            // Week
564
-            // ISO-8601 week number of year (weeks starting on monday)
565
-            'W' => array(
566
-                'js'     => '',
567
-                'moment' => 'w',
568
-            ),
569
-            // Month
570
-            // January...December
571
-            'F' => array(
572
-                'js'     => 'MM',
573
-                'moment' => 'MMMM',
574
-            ),
575
-            // 01...12
576
-            'm' => array(
577
-                'js'     => 'mm',
578
-                'moment' => 'MM',
579
-            ),
580
-            // Jan...Dec
581
-            'M' => array(
582
-                'js'     => 'M',
583
-                'moment' => 'MMM',
584
-            ),
585
-            // 1-12
586
-            'n' => array(
587
-                'js'     => 'm',
588
-                'moment' => 'M',
589
-            ),
590
-            // number of days in given month
591
-            't' => array(
592
-                'js'     => '',
593
-                'moment' => '',
594
-            ),
595
-            // Year
596
-            // whether leap year or not 1/0
597
-            'L' => array(
598
-                'js'     => '',
599
-                'moment' => '',
600
-            ),
601
-            // ISO-8601 year number
602
-            'o' => array(
603
-                'js'     => '',
604
-                'moment' => 'GGGG',
605
-            ),
606
-            // 1999...2003
607
-            'Y' => array(
608
-                'js'     => 'yy',
609
-                'moment' => 'YYYY',
610
-            ),
611
-            // 99...03
612
-            'y' => array(
613
-                'js'     => 'y',
614
-                'moment' => 'YY',
615
-            ),
616
-            // Time
617
-            // am/pm
618
-            'a' => array(
619
-                'js'     => 'tt',
620
-                'moment' => 'a',
621
-            ),
622
-            // AM/PM
623
-            'A' => array(
624
-                'js'     => 'TT',
625
-                'moment' => 'A',
626
-            ),
627
-            // Swatch Internet Time?!?
628
-            'B' => array(
629
-                'js'     => '',
630
-                'moment' => '',
631
-            ),
632
-            // 1...12
633
-            'g' => array(
634
-                'js'     => 'h',
635
-                'moment' => 'h',
636
-            ),
637
-            // 0...23
638
-            'G' => array(
639
-                'js'     => 'H',
640
-                'moment' => 'H',
641
-            ),
642
-            // 01...12
643
-            'h' => array(
644
-                'js'     => 'hh',
645
-                'moment' => 'hh',
646
-            ),
647
-            // 00...23
648
-            'H' => array(
649
-                'js'     => 'HH',
650
-                'moment' => 'HH',
651
-            ),
652
-            // 00..59
653
-            'i' => array(
654
-                'js'     => 'mm',
655
-                'moment' => 'mm',
656
-            ),
657
-            // seconds... 00...59
658
-            's' => array(
659
-                'js'     => 'ss',
660
-                'moment' => 'ss',
661
-            ),
662
-            // microseconds
663
-            'u' => array(
664
-                'js'     => '',
665
-                'moment' => '',
666
-            ),
667
-        );
668
-        $jquery_ui_format     = '';
669
-        $moment_format        = '';
670
-        $escaping             = false;
671
-        $format_string_length = strlen($format_string);
672
-        for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
674
-            if ($char === '\\') { // PHP date format escaping character
675
-                $i++;
676
-                if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
679
-                } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
682
-                }
683
-                $escaping = true;
684
-            } else {
685
-                if ($escaping) {
686
-                    $jquery_ui_format .= "'";
687
-                    $moment_format    .= "'";
688
-                    $escaping         = false;
689
-                }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
693
-                } else {
694
-                    $jquery_ui_format .= $char;
695
-                    $moment_format    .= $char;
696
-                }
697
-            }
698
-        }
699
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
-    }
507
+	/**
508
+	 * This converts incoming format string into js and moment variations.
509
+	 *
510
+	 * @param string $format_string incoming php format string
511
+	 * @return array js and moment formats.
512
+	 */
513
+	protected static function _php_to_js_moment_converter($format_string)
514
+	{
515
+		/**
516
+		 * This is a map of symbols for formats.
517
+		 * The index is the php symbol, the equivalent values are in the array.
518
+		 *
519
+		 * @var array
520
+		 */
521
+		$symbols_map          = array(
522
+			// Day
523
+			// 01
524
+			'd' => array(
525
+				'js'     => 'dd',
526
+				'moment' => 'DD',
527
+			),
528
+			// Mon
529
+			'D' => array(
530
+				'js'     => 'D',
531
+				'moment' => 'ddd',
532
+			),
533
+			// 1,2,...31
534
+			'j' => array(
535
+				'js'     => 'd',
536
+				'moment' => 'D',
537
+			),
538
+			// Monday
539
+			'l' => array(
540
+				'js'     => 'DD',
541
+				'moment' => 'dddd',
542
+			),
543
+			// ISO numeric representation of the day of the week (1-6)
544
+			'N' => array(
545
+				'js'     => '',
546
+				'moment' => 'E',
547
+			),
548
+			// st,nd.rd
549
+			'S' => array(
550
+				'js'     => '',
551
+				'moment' => 'o',
552
+			),
553
+			// numeric representation of day of week (0-6)
554
+			'w' => array(
555
+				'js'     => '',
556
+				'moment' => 'd',
557
+			),
558
+			// day of year starting from 0 (0-365)
559
+			'z' => array(
560
+				'js'     => 'o',
561
+				'moment' => 'DDD' // note moment does not start with 0 so will need to modify by subtracting 1
562
+			),
563
+			// Week
564
+			// ISO-8601 week number of year (weeks starting on monday)
565
+			'W' => array(
566
+				'js'     => '',
567
+				'moment' => 'w',
568
+			),
569
+			// Month
570
+			// January...December
571
+			'F' => array(
572
+				'js'     => 'MM',
573
+				'moment' => 'MMMM',
574
+			),
575
+			// 01...12
576
+			'm' => array(
577
+				'js'     => 'mm',
578
+				'moment' => 'MM',
579
+			),
580
+			// Jan...Dec
581
+			'M' => array(
582
+				'js'     => 'M',
583
+				'moment' => 'MMM',
584
+			),
585
+			// 1-12
586
+			'n' => array(
587
+				'js'     => 'm',
588
+				'moment' => 'M',
589
+			),
590
+			// number of days in given month
591
+			't' => array(
592
+				'js'     => '',
593
+				'moment' => '',
594
+			),
595
+			// Year
596
+			// whether leap year or not 1/0
597
+			'L' => array(
598
+				'js'     => '',
599
+				'moment' => '',
600
+			),
601
+			// ISO-8601 year number
602
+			'o' => array(
603
+				'js'     => '',
604
+				'moment' => 'GGGG',
605
+			),
606
+			// 1999...2003
607
+			'Y' => array(
608
+				'js'     => 'yy',
609
+				'moment' => 'YYYY',
610
+			),
611
+			// 99...03
612
+			'y' => array(
613
+				'js'     => 'y',
614
+				'moment' => 'YY',
615
+			),
616
+			// Time
617
+			// am/pm
618
+			'a' => array(
619
+				'js'     => 'tt',
620
+				'moment' => 'a',
621
+			),
622
+			// AM/PM
623
+			'A' => array(
624
+				'js'     => 'TT',
625
+				'moment' => 'A',
626
+			),
627
+			// Swatch Internet Time?!?
628
+			'B' => array(
629
+				'js'     => '',
630
+				'moment' => '',
631
+			),
632
+			// 1...12
633
+			'g' => array(
634
+				'js'     => 'h',
635
+				'moment' => 'h',
636
+			),
637
+			// 0...23
638
+			'G' => array(
639
+				'js'     => 'H',
640
+				'moment' => 'H',
641
+			),
642
+			// 01...12
643
+			'h' => array(
644
+				'js'     => 'hh',
645
+				'moment' => 'hh',
646
+			),
647
+			// 00...23
648
+			'H' => array(
649
+				'js'     => 'HH',
650
+				'moment' => 'HH',
651
+			),
652
+			// 00..59
653
+			'i' => array(
654
+				'js'     => 'mm',
655
+				'moment' => 'mm',
656
+			),
657
+			// seconds... 00...59
658
+			's' => array(
659
+				'js'     => 'ss',
660
+				'moment' => 'ss',
661
+			),
662
+			// microseconds
663
+			'u' => array(
664
+				'js'     => '',
665
+				'moment' => '',
666
+			),
667
+		);
668
+		$jquery_ui_format     = '';
669
+		$moment_format        = '';
670
+		$escaping             = false;
671
+		$format_string_length = strlen($format_string);
672
+		for ($i = 0; $i < $format_string_length; $i++) {
673
+			$char = $format_string[ $i ];
674
+			if ($char === '\\') { // PHP date format escaping character
675
+				$i++;
676
+				if ($escaping) {
677
+					$jquery_ui_format .= $format_string[ $i ];
678
+					$moment_format    .= $format_string[ $i ];
679
+				} else {
680
+					$jquery_ui_format .= '\'' . $format_string[ $i ];
681
+					$moment_format    .= $format_string[ $i ];
682
+				}
683
+				$escaping = true;
684
+			} else {
685
+				if ($escaping) {
686
+					$jquery_ui_format .= "'";
687
+					$moment_format    .= "'";
688
+					$escaping         = false;
689
+				}
690
+				if (isset($symbols_map[ $char ])) {
691
+					$jquery_ui_format .= $symbols_map[ $char ]['js'];
692
+					$moment_format    .= $symbols_map[ $char ]['moment'];
693
+				} else {
694
+					$jquery_ui_format .= $char;
695
+					$moment_format    .= $char;
696
+				}
697
+			}
698
+		}
699
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
700
+	}
701 701
 
702 702
 
703
-    /**
704
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
-     *
706
-     * @param string $format_string   Incoming format string for php date().
707
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
-     *                                errors is returned.  So for client code calling, check for is_array() to
709
-     *                                indicate failed validations.
710
-     */
711
-    public static function validate_format_string($format_string)
712
-    {
713
-        $error_msg = array();
714
-        // time format checks
715
-        switch (true) {
716
-            case strpos($format_string, 'h') !== false:
717
-            case strpos($format_string, 'g') !== false:
718
-                /**
719
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
-                 */
723
-                if (stripos($format_string, 'A') === false) {
724
-                    $error_msg[] = esc_html__(
725
-                        'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
-                        'event_espresso'
727
-                    );
728
-                }
729
-                break;
730
-        }
731
-        return empty($error_msg) ? true : $error_msg;
732
-    }
703
+	/**
704
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
705
+	 *
706
+	 * @param string $format_string   Incoming format string for php date().
707
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
708
+	 *                                errors is returned.  So for client code calling, check for is_array() to
709
+	 *                                indicate failed validations.
710
+	 */
711
+	public static function validate_format_string($format_string)
712
+	{
713
+		$error_msg = array();
714
+		// time format checks
715
+		switch (true) {
716
+			case strpos($format_string, 'h') !== false:
717
+			case strpos($format_string, 'g') !== false:
718
+				/**
719
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
720
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
721
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
722
+				 */
723
+				if (stripos($format_string, 'A') === false) {
724
+					$error_msg[] = esc_html__(
725
+						'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
726
+						'event_espresso'
727
+					);
728
+				}
729
+				break;
730
+		}
731
+		return empty($error_msg) ? true : $error_msg;
732
+	}
733 733
 
734 734
 
735
-    /**
736
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
-     *     very next day then this method will return true.
738
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
-     *
742
-     * @param mixed $date_1
743
-     * @param mixed $date_2
744
-     * @return bool
745
-     */
746
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
-    {
735
+	/**
736
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
737
+	 *     very next day then this method will return true.
738
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
739
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
740
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
741
+	 *
742
+	 * @param mixed $date_1
743
+	 * @param mixed $date_2
744
+	 * @return bool
745
+	 */
746
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
747
+	{
748 748
 
749
-        if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750
-            || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751
-                || $date_2->format(
752
-                    EE_Datetime_Field::mysql_time_format
753
-                ) !== '00:00:00')
754
-        ) {
755
-            return false;
756
-        }
757
-        return $date_2->format('U') - $date_1->format('U') === 86400;
758
-    }
749
+		if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750
+			|| ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751
+				|| $date_2->format(
752
+					EE_Datetime_Field::mysql_time_format
753
+				) !== '00:00:00')
754
+		) {
755
+			return false;
756
+		}
757
+		return $date_2->format('U') - $date_1->format('U') === 86400;
758
+	}
759 759
 
760 760
 
761
-    /**
762
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
763
-     * Functions.
764
-     *
765
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
766
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
767
-     * @return string
768
-     */
769
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
770
-    {
771
-        try {
772
-            /** need to account for timezone offset on the selects */
773
-            $DateTimeZone = new DateTimeZone($timezone_string);
774
-        } catch (Exception $e) {
775
-            $DateTimeZone = null;
776
-        }
777
-        /**
778
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
779
-         * Hence we do the calc for DateTimeZone::getOffset.
780
-         */
781
-        $offset         = $DateTimeZone instanceof DateTimeZone
782
-            ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783
-            : (float) get_option('gmt_offset');
784
-        $query_interval = $offset < 0
785
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
787
-        return $query_interval;
788
-    }
761
+	/**
762
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
763
+	 * Functions.
764
+	 *
765
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
766
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
767
+	 * @return string
768
+	 */
769
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
770
+	{
771
+		try {
772
+			/** need to account for timezone offset on the selects */
773
+			$DateTimeZone = new DateTimeZone($timezone_string);
774
+		} catch (Exception $e) {
775
+			$DateTimeZone = null;
776
+		}
777
+		/**
778
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
779
+		 * Hence we do the calc for DateTimeZone::getOffset.
780
+		 */
781
+		$offset         = $DateTimeZone instanceof DateTimeZone
782
+			? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783
+			: (float) get_option('gmt_offset');
784
+		$query_interval = $offset < 0
785
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
787
+		return $query_interval;
788
+	}
789 789
 
790 790
 
791
-    /**
792
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
793
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
794
-     * and 'gmt_offset' WordPress options directly; or use the filter
795
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
796
-     * (although note that we remove any HTML that may be added)
797
-     *
798
-     * @return string
799
-     */
800
-    public static function get_timezone_string_for_display()
801
-    {
802
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
-        if (! empty($pretty_timezone)) {
804
-            return esc_html($pretty_timezone);
805
-        }
806
-        $timezone_string = get_option('timezone_string');
807
-        if ($timezone_string) {
808
-            static $mo_loaded = false;
809
-            // Load translations for continents and cities just like wp_timezone_choice does
810
-            if (! $mo_loaded) {
811
-                $locale = get_locale();
812
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
813
-                load_textdomain('continents-cities', $mofile);
814
-                $mo_loaded = true;
815
-            }
816
-            // well that was easy.
817
-            $parts = explode('/', $timezone_string);
818
-            // remove the continent
819
-            unset($parts[0]);
820
-            $t_parts = array();
821
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
822
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
823
-            // disabled because this code is copied from WordPress and is a WordPress domain
824
-            foreach ($parts as $part) {
825
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
826
-            }
827
-            return implode(' - ', $t_parts);
828
-            // phpcs:enable
829
-        }
830
-        // they haven't set the timezone string, so let's return a string like "UTC+1"
831
-        $gmt_offset = get_option('gmt_offset');
832
-        $prefix     = (int) $gmt_offset >= 0 ? '+' : '';
833
-        $parts      = explode('.', (string) $gmt_offset);
834
-        if (count($parts) === 1) {
835
-            $parts[1] = '00';
836
-        } else {
837
-            // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838
-            // to minutes, eg 30 or 15, respectively
839
-            $hour_fraction = (float) ('0.' . $parts[1]);
840
-            $parts[1]      = (string) $hour_fraction * 60;
841
-        }
842
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
843
-    }
791
+	/**
792
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
793
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
794
+	 * and 'gmt_offset' WordPress options directly; or use the filter
795
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
796
+	 * (although note that we remove any HTML that may be added)
797
+	 *
798
+	 * @return string
799
+	 */
800
+	public static function get_timezone_string_for_display()
801
+	{
802
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
+		if (! empty($pretty_timezone)) {
804
+			return esc_html($pretty_timezone);
805
+		}
806
+		$timezone_string = get_option('timezone_string');
807
+		if ($timezone_string) {
808
+			static $mo_loaded = false;
809
+			// Load translations for continents and cities just like wp_timezone_choice does
810
+			if (! $mo_loaded) {
811
+				$locale = get_locale();
812
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
813
+				load_textdomain('continents-cities', $mofile);
814
+				$mo_loaded = true;
815
+			}
816
+			// well that was easy.
817
+			$parts = explode('/', $timezone_string);
818
+			// remove the continent
819
+			unset($parts[0]);
820
+			$t_parts = array();
821
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
822
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
823
+			// disabled because this code is copied from WordPress and is a WordPress domain
824
+			foreach ($parts as $part) {
825
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
826
+			}
827
+			return implode(' - ', $t_parts);
828
+			// phpcs:enable
829
+		}
830
+		// they haven't set the timezone string, so let's return a string like "UTC+1"
831
+		$gmt_offset = get_option('gmt_offset');
832
+		$prefix     = (int) $gmt_offset >= 0 ? '+' : '';
833
+		$parts      = explode('.', (string) $gmt_offset);
834
+		if (count($parts) === 1) {
835
+			$parts[1] = '00';
836
+		} else {
837
+			// convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838
+			// to minutes, eg 30 or 15, respectively
839
+			$hour_fraction = (float) ('0.' . $parts[1]);
840
+			$parts[1]      = (string) $hour_fraction * 60;
841
+		}
842
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
843
+	}
844 844
 
845 845
 
846 846
 
847
-    /**
848
-     * So PHP does this awesome thing where if you are trying to get a timestamp
849
-     * for a month using a string like "February" or "February 2017",
850
-     * and you don't specify a day as part of your string,
851
-     * then PHP will use whatever the current day of the month is.
852
-     * IF the current day of the month happens to be the 30th or 31st,
853
-     * then PHP gets really confused by a date like February 30,
854
-     * so instead of saying
855
-     *      "Hey February only has 28 days (this year)...
856
-     *      ...you must have meant the last day of the month!"
857
-     * PHP does the next most logical thing, and bumps the date up to March 2nd,
858
-     * because someone requesting February 30th obviously meant March 1st!
859
-     * The way around this is to always set the day to the first,
860
-     * so that the month will stay on the month you wanted.
861
-     * this method will add that "1" into your date regardless of the format.
862
-     *
863
-     * @param string $month
864
-     * @return string
865
-     */
866
-    public static function first_of_month_timestamp($month = '')
867
-    {
868
-        $month = (string) $month;
869
-        $year  = '';
870
-        // check if the incoming string has a year in it or not
871
-        if (preg_match('/\b\d{4}\b/', $month, $matches)) {
872
-            $year = $matches[0];
873
-            // ten remove that from the month string as well as any spaces
874
-            $month = trim(str_replace($year, '', $month));
875
-            // add a space before the year
876
-            $year = " {$year}";
877
-        }
878
-        // return timestamp for something like "February 1 2017"
879
-        return strtotime("{$month} 1{$year}");
880
-    }
847
+	/**
848
+	 * So PHP does this awesome thing where if you are trying to get a timestamp
849
+	 * for a month using a string like "February" or "February 2017",
850
+	 * and you don't specify a day as part of your string,
851
+	 * then PHP will use whatever the current day of the month is.
852
+	 * IF the current day of the month happens to be the 30th or 31st,
853
+	 * then PHP gets really confused by a date like February 30,
854
+	 * so instead of saying
855
+	 *      "Hey February only has 28 days (this year)...
856
+	 *      ...you must have meant the last day of the month!"
857
+	 * PHP does the next most logical thing, and bumps the date up to March 2nd,
858
+	 * because someone requesting February 30th obviously meant March 1st!
859
+	 * The way around this is to always set the day to the first,
860
+	 * so that the month will stay on the month you wanted.
861
+	 * this method will add that "1" into your date regardless of the format.
862
+	 *
863
+	 * @param string $month
864
+	 * @return string
865
+	 */
866
+	public static function first_of_month_timestamp($month = '')
867
+	{
868
+		$month = (string) $month;
869
+		$year  = '';
870
+		// check if the incoming string has a year in it or not
871
+		if (preg_match('/\b\d{4}\b/', $month, $matches)) {
872
+			$year = $matches[0];
873
+			// ten remove that from the month string as well as any spaces
874
+			$month = trim(str_replace($year, '', $month));
875
+			// add a space before the year
876
+			$year = " {$year}";
877
+		}
878
+		// return timestamp for something like "February 1 2017"
879
+		return strtotime("{$month} 1{$year}");
880
+	}
881 881
 
882 882
 
883
-    /**
884
-     * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
885
-     * for this sites timezone, but the timestamp could be some other time GMT.
886
-     */
887
-    public static function tomorrow()
888
-    {
889
-        // The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
890
-        // before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
891
-        // not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
892
-        // final timestamp is equivalent to midnight in this timezone as represented in GMT.
893
-        return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
894
-    }
883
+	/**
884
+	 * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
885
+	 * for this sites timezone, but the timestamp could be some other time GMT.
886
+	 */
887
+	public static function tomorrow()
888
+	{
889
+		// The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
890
+		// before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
891
+		// not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
892
+		// final timestamp is equivalent to midnight in this timezone as represented in GMT.
893
+		return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
894
+	}
895 895
 
896 896
 
897
-    /**
898
-     * **
899
-     * Gives a nicely-formatted list of timezone strings.
900
-     * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
901
-     *
902
-     * @since     4.9.40.rc.008
903
-     * @staticvar bool $mo_loaded
904
-     * @staticvar string $locale_loaded
905
-     * @param string $selected_zone Selected timezone.
906
-     * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
907
-     * @return string
908
-     */
909
-    public static function wp_timezone_choice($selected_zone, $locale = null)
910
-    {
911
-        static $mo_loaded = false, $locale_loaded = null;
912
-        $continents = array(
913
-            'Africa',
914
-            'America',
915
-            'Antarctica',
916
-            'Arctic',
917
-            'Asia',
918
-            'Atlantic',
919
-            'Australia',
920
-            'Europe',
921
-            'Indian',
922
-            'Pacific',
923
-        );
924
-        // Load translations for continents and cities.
925
-        if (! $mo_loaded || $locale !== $locale_loaded) {
926
-            $locale_loaded = $locale ? $locale : get_locale();
927
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
928
-            unload_textdomain('continents-cities');
929
-            load_textdomain('continents-cities', $mofile);
930
-            $mo_loaded = true;
931
-        }
932
-        $zone_data = array();
933
-        foreach (timezone_identifiers_list() as $zone) {
934
-            $zone = explode('/', $zone);
935
-            if (! in_array($zone[0], $continents, true)) {
936
-                continue;
937
-            }
938
-            // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
-            $exists      = array(
940
-                0 => isset($zone[0]) && $zone[0],
941
-                1 => isset($zone[1]) && $zone[1],
942
-                2 => isset($zone[2]) && $zone[2],
943
-            );
944
-            $exists[3]   = $exists[0] && $zone[0] !== 'Etc';
945
-            $exists[4]   = $exists[1] && $exists[3];
946
-            $exists[5]   = $exists[2] && $exists[3];
947
-            // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
948
-            // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
949
-            // disabled because this code is copied from WordPress and is a WordPress domain
950
-            $zone_data[] = array(
951
-                'continent'   => $exists[0] ? $zone[0] : '',
952
-                'city'        => $exists[1] ? $zone[1] : '',
953
-                'subcity'     => $exists[2] ? $zone[2] : '',
954
-                't_continent' => $exists[3]
955
-                    ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
956
-                    : '',
957
-                't_city'      => $exists[4]
958
-                    ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
959
-                    : '',
960
-                't_subcity'   => $exists[5]
961
-                    ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
962
-                    : '',
963
-            );
964
-            // phpcs:enable
965
-        }
966
-        usort($zone_data, '_wp_timezone_choice_usort_callback');
967
-        $structure = array();
968
-        if (empty($selected_zone)) {
969
-            $structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
970
-        }
971
-        foreach ($zone_data as $key => $zone) {
972
-            // Build value in an array to join later
973
-            $value = array($zone['continent']);
974
-            if (empty($zone['city'])) {
975
-                // It's at the continent level (generally won't happen)
976
-                $display = $zone['t_continent'];
977
-            } else {
978
-                // It's inside a continent group
979
-                // Continent optgroup
980
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
981
-                    $label       = $zone['t_continent'];
982
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
983
-                }
984
-                // Add the city to the value
985
-                $value[] = $zone['city'];
986
-                $display = $zone['t_city'];
987
-                if (! empty($zone['subcity'])) {
988
-                    // Add the subcity to the value
989
-                    $value[] = $zone['subcity'];
990
-                    $display .= ' - ' . $zone['t_subcity'];
991
-                }
992
-            }
993
-            // Build the value
994
-            $value       = implode('/', $value);
995
-            $selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
997
-                           . esc_html($display)
998
-                           . '</option>';
999
-            // Close continent optgroup
1000
-            if (! empty($zone['city'])
1001
-                && (
1002
-                    ! isset($zone_data[ $key + 1 ])
1003
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1004
-                )
1005
-            ) {
1006
-                $structure[] = '</optgroup>';
1007
-            }
1008
-        }
1009
-        return implode("\n", $structure);
1010
-    }
897
+	/**
898
+	 * **
899
+	 * Gives a nicely-formatted list of timezone strings.
900
+	 * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
901
+	 *
902
+	 * @since     4.9.40.rc.008
903
+	 * @staticvar bool $mo_loaded
904
+	 * @staticvar string $locale_loaded
905
+	 * @param string $selected_zone Selected timezone.
906
+	 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
907
+	 * @return string
908
+	 */
909
+	public static function wp_timezone_choice($selected_zone, $locale = null)
910
+	{
911
+		static $mo_loaded = false, $locale_loaded = null;
912
+		$continents = array(
913
+			'Africa',
914
+			'America',
915
+			'Antarctica',
916
+			'Arctic',
917
+			'Asia',
918
+			'Atlantic',
919
+			'Australia',
920
+			'Europe',
921
+			'Indian',
922
+			'Pacific',
923
+		);
924
+		// Load translations for continents and cities.
925
+		if (! $mo_loaded || $locale !== $locale_loaded) {
926
+			$locale_loaded = $locale ? $locale : get_locale();
927
+			$mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
928
+			unload_textdomain('continents-cities');
929
+			load_textdomain('continents-cities', $mofile);
930
+			$mo_loaded = true;
931
+		}
932
+		$zone_data = array();
933
+		foreach (timezone_identifiers_list() as $zone) {
934
+			$zone = explode('/', $zone);
935
+			if (! in_array($zone[0], $continents, true)) {
936
+				continue;
937
+			}
938
+			// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
+			$exists      = array(
940
+				0 => isset($zone[0]) && $zone[0],
941
+				1 => isset($zone[1]) && $zone[1],
942
+				2 => isset($zone[2]) && $zone[2],
943
+			);
944
+			$exists[3]   = $exists[0] && $zone[0] !== 'Etc';
945
+			$exists[4]   = $exists[1] && $exists[3];
946
+			$exists[5]   = $exists[2] && $exists[3];
947
+			// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralText
948
+			// phpcs:disable WordPress.WP.I18n.TextDomainMismatch
949
+			// disabled because this code is copied from WordPress and is a WordPress domain
950
+			$zone_data[] = array(
951
+				'continent'   => $exists[0] ? $zone[0] : '',
952
+				'city'        => $exists[1] ? $zone[1] : '',
953
+				'subcity'     => $exists[2] ? $zone[2] : '',
954
+				't_continent' => $exists[3]
955
+					? translate(str_replace('_', ' ', $zone[0]), 'continents-cities')
956
+					: '',
957
+				't_city'      => $exists[4]
958
+					? translate(str_replace('_', ' ', $zone[1]), 'continents-cities')
959
+					: '',
960
+				't_subcity'   => $exists[5]
961
+					? translate(str_replace('_', ' ', $zone[2]), 'continents-cities')
962
+					: '',
963
+			);
964
+			// phpcs:enable
965
+		}
966
+		usort($zone_data, '_wp_timezone_choice_usort_callback');
967
+		$structure = array();
968
+		if (empty($selected_zone)) {
969
+			$structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
970
+		}
971
+		foreach ($zone_data as $key => $zone) {
972
+			// Build value in an array to join later
973
+			$value = array($zone['continent']);
974
+			if (empty($zone['city'])) {
975
+				// It's at the continent level (generally won't happen)
976
+				$display = $zone['t_continent'];
977
+			} else {
978
+				// It's inside a continent group
979
+				// Continent optgroup
980
+				if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
981
+					$label       = $zone['t_continent'];
982
+					$structure[] = '<optgroup label="' . esc_attr($label) . '">';
983
+				}
984
+				// Add the city to the value
985
+				$value[] = $zone['city'];
986
+				$display = $zone['t_city'];
987
+				if (! empty($zone['subcity'])) {
988
+					// Add the subcity to the value
989
+					$value[] = $zone['subcity'];
990
+					$display .= ' - ' . $zone['t_subcity'];
991
+				}
992
+			}
993
+			// Build the value
994
+			$value       = implode('/', $value);
995
+			$selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
+			$structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
997
+						   . esc_html($display)
998
+						   . '</option>';
999
+			// Close continent optgroup
1000
+			if (! empty($zone['city'])
1001
+				&& (
1002
+					! isset($zone_data[ $key + 1 ])
1003
+					|| (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1004
+				)
1005
+			) {
1006
+				$structure[] = '</optgroup>';
1007
+			}
1008
+		}
1009
+		return implode("\n", $structure);
1010
+	}
1011 1011
 
1012 1012
 
1013
-    /**
1014
-     * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1015
-     *
1016
-     * @param int|WP_User $user_id
1017
-     * @return string
1018
-     */
1019
-    public static function get_user_locale($user_id = 0)
1020
-    {
1021
-        if (function_exists('get_user_locale')) {
1022
-            return get_user_locale($user_id);
1023
-        }
1024
-        return get_locale();
1025
-    }
1013
+	/**
1014
+	 * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1015
+	 *
1016
+	 * @param int|WP_User $user_id
1017
+	 * @return string
1018
+	 */
1019
+	public static function get_user_locale($user_id = 0)
1020
+	{
1021
+		if (function_exists('get_user_locale')) {
1022
+			return get_user_locale($user_id);
1023
+		}
1024
+		return get_locale();
1025
+	}
1026 1026
 
1027 1027
 
1028
-    /**
1029
-     * Return the appropriate helper adapter for DTT related things.
1030
-     *
1031
-     * @return HelperInterface
1032
-     * @throws InvalidArgumentException
1033
-     * @throws InvalidDataTypeException
1034
-     * @throws InvalidInterfaceException
1035
-     */
1036
-    private static function getHelperAdapter()
1037
-    {
1038
-        $dtt_helper_fqcn = PHP_VERSION_ID < 50600
1039
-            ? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1040
-            : 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1041
-        return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1042
-    }
1028
+	/**
1029
+	 * Return the appropriate helper adapter for DTT related things.
1030
+	 *
1031
+	 * @return HelperInterface
1032
+	 * @throws InvalidArgumentException
1033
+	 * @throws InvalidDataTypeException
1034
+	 * @throws InvalidInterfaceException
1035
+	 */
1036
+	private static function getHelperAdapter()
1037
+	{
1038
+		$dtt_helper_fqcn = PHP_VERSION_ID < 50600
1039
+			? 'EventEspresso\core\services\helpers\datetime\PhpCompatLessFiveSixHelper'
1040
+			: 'EventEspresso\core\services\helpers\datetime\PhpCompatGreaterFiveSixHelper';
1041
+		return LoaderFactory::getLoader()->getShared($dtt_helper_fqcn);
1042
+	}
1043 1043
 
1044 1044
 
1045
-    /**
1046
-     * Helper function for setting the timezone on a DateTime object.
1047
-     * This is implemented to standardize a workaround for a PHP bug outlined in
1048
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1049
-     * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1050
-     *
1051
-     * @param DateTime     $datetime
1052
-     * @param DateTimeZone $timezone
1053
-     */
1054
-    public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1055
-    {
1056
-        $datetime->setTimezone($timezone);
1057
-        $datetime->getTimestamp();
1058
-    }
1045
+	/**
1046
+	 * Helper function for setting the timezone on a DateTime object.
1047
+	 * This is implemented to standardize a workaround for a PHP bug outlined in
1048
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11407 and
1049
+	 * https://events.codebasehq.com/projects/event-espresso/tickets/11233
1050
+	 *
1051
+	 * @param DateTime     $datetime
1052
+	 * @param DateTimeZone $timezone
1053
+	 */
1054
+	public static function setTimezone(DateTime $datetime, DateTimeZone $timezone)
1055
+	{
1056
+		$datetime->setTimezone($timezone);
1057
+		$datetime->getTimestamp();
1058
+	}
1059 1059
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
133 133
     {
134
-        $gmt_offset =  (int) $gmt_offset;
134
+        $gmt_offset = (int) $gmt_offset;
135 135
         /** @var array[] $abbreviations */
136 136
         $abbreviations = DateTimeZone::listAbbreviations();
137 137
         foreach ($abbreviations as $abbreviation) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      */
327 327
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
328 328
     {
329
-        if (! $DateTime instanceof DateTime) {
329
+        if ( ! $DateTime instanceof DateTime) {
330 330
             throw new EE_Error(
331 331
                 sprintf(
332 332
                     esc_html__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -336,25 +336,25 @@  discard block
 block discarded – undo
336 336
         }
337 337
         switch ($period) {
338 338
             case 'years':
339
-                $value = 'P' . $value . 'Y';
339
+                $value = 'P'.$value.'Y';
340 340
                 break;
341 341
             case 'months':
342
-                $value = 'P' . $value . 'M';
342
+                $value = 'P'.$value.'M';
343 343
                 break;
344 344
             case 'weeks':
345
-                $value = 'P' . $value . 'W';
345
+                $value = 'P'.$value.'W';
346 346
                 break;
347 347
             case 'days':
348
-                $value = 'P' . $value . 'D';
348
+                $value = 'P'.$value.'D';
349 349
                 break;
350 350
             case 'hours':
351
-                $value = 'PT' . $value . 'H';
351
+                $value = 'PT'.$value.'H';
352 352
                 break;
353 353
             case 'minutes':
354
-                $value = 'PT' . $value . 'M';
354
+                $value = 'PT'.$value.'M';
355 355
                 break;
356 356
             case 'seconds':
357
-                $value = 'PT' . $value . 'S';
357
+                $value = 'PT'.$value.'S';
358 358
                 break;
359 359
         }
360 360
         switch ($operand) {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
384 384
     {
385
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
385
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
386 386
             throw new EE_Error(
387 387
                 sprintf(
388 388
                     esc_html__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                 'date' => $date_format['js'],
496 496
                 'time' => $time_format['js'],
497 497
             ),
498
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
498
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
499 499
             'moment_split' => array(
500 500
                 'date' => $date_format['moment'],
501 501
                 'time' => $time_format['moment']
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
          *
519 519
          * @var array
520 520
          */
521
-        $symbols_map          = array(
521
+        $symbols_map = array(
522 522
             // Day
523 523
             // 01
524 524
             'd' => array(
@@ -670,26 +670,26 @@  discard block
 block discarded – undo
670 670
         $escaping             = false;
671 671
         $format_string_length = strlen($format_string);
672 672
         for ($i = 0; $i < $format_string_length; $i++) {
673
-            $char = $format_string[ $i ];
673
+            $char = $format_string[$i];
674 674
             if ($char === '\\') { // PHP date format escaping character
675 675
                 $i++;
676 676
                 if ($escaping) {
677
-                    $jquery_ui_format .= $format_string[ $i ];
678
-                    $moment_format    .= $format_string[ $i ];
677
+                    $jquery_ui_format .= $format_string[$i];
678
+                    $moment_format    .= $format_string[$i];
679 679
                 } else {
680
-                    $jquery_ui_format .= '\'' . $format_string[ $i ];
681
-                    $moment_format    .= $format_string[ $i ];
680
+                    $jquery_ui_format .= '\''.$format_string[$i];
681
+                    $moment_format    .= $format_string[$i];
682 682
                 }
683 683
                 $escaping = true;
684 684
             } else {
685 685
                 if ($escaping) {
686 686
                     $jquery_ui_format .= "'";
687 687
                     $moment_format    .= "'";
688
-                    $escaping         = false;
688
+                    $escaping = false;
689 689
                 }
690
-                if (isset($symbols_map[ $char ])) {
691
-                    $jquery_ui_format .= $symbols_map[ $char ]['js'];
692
-                    $moment_format    .= $symbols_map[ $char ]['moment'];
690
+                if (isset($symbols_map[$char])) {
691
+                    $jquery_ui_format .= $symbols_map[$char]['js'];
692
+                    $moment_format    .= $symbols_map[$char]['moment'];
693 693
                 } else {
694 694
                     $jquery_ui_format .= $char;
695 695
                     $moment_format    .= $char;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
     public static function dates_represent_one_24_hour_date($date_1, $date_2)
747 747
     {
748 748
 
749
-        if ((! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
749
+        if (( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
750 750
             || ($date_1->format(EE_Datetime_Field::mysql_time_format) !== '00:00:00'
751 751
                 || $date_2->format(
752 752
                     EE_Datetime_Field::mysql_time_format
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
             ? $DateTimeZone->getOffset(new DateTime('now')) / HOUR_IN_SECONDS
783 783
             : (float) get_option('gmt_offset');
784 784
         $query_interval = $offset < 0
785
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
786
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
785
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
786
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
787 787
         return $query_interval;
788 788
     }
789 789
 
@@ -800,16 +800,16 @@  discard block
 block discarded – undo
800 800
     public static function get_timezone_string_for_display()
801 801
     {
802 802
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
803
-        if (! empty($pretty_timezone)) {
803
+        if ( ! empty($pretty_timezone)) {
804 804
             return esc_html($pretty_timezone);
805 805
         }
806 806
         $timezone_string = get_option('timezone_string');
807 807
         if ($timezone_string) {
808 808
             static $mo_loaded = false;
809 809
             // Load translations for continents and cities just like wp_timezone_choice does
810
-            if (! $mo_loaded) {
810
+            if ( ! $mo_loaded) {
811 811
                 $locale = get_locale();
812
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
812
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
813 813
                 load_textdomain('continents-cities', $mofile);
814 814
                 $mo_loaded = true;
815 815
             }
@@ -836,10 +836,10 @@  discard block
 block discarded – undo
836 836
         } else {
837 837
             // convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
838 838
             // to minutes, eg 30 or 15, respectively
839
-            $hour_fraction = (float) ('0.' . $parts[1]);
839
+            $hour_fraction = (float) ('0.'.$parts[1]);
840 840
             $parts[1]      = (string) $hour_fraction * 60;
841 841
         }
842
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
842
+        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
843 843
     }
844 844
 
845 845
 
@@ -922,9 +922,9 @@  discard block
 block discarded – undo
922 922
             'Pacific',
923 923
         );
924 924
         // Load translations for continents and cities.
925
-        if (! $mo_loaded || $locale !== $locale_loaded) {
925
+        if ( ! $mo_loaded || $locale !== $locale_loaded) {
926 926
             $locale_loaded = $locale ? $locale : get_locale();
927
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
927
+            $mofile        = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
928 928
             unload_textdomain('continents-cities');
929 929
             load_textdomain('continents-cities', $mofile);
930 930
             $mo_loaded = true;
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
         $zone_data = array();
933 933
         foreach (timezone_identifiers_list() as $zone) {
934 934
             $zone = explode('/', $zone);
935
-            if (! in_array($zone[0], $continents, true)) {
935
+            if ( ! in_array($zone[0], $continents, true)) {
936 936
                 continue;
937 937
             }
938 938
             // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
939
-            $exists      = array(
939
+            $exists = array(
940 940
                 0 => isset($zone[0]) && $zone[0],
941 941
                 1 => isset($zone[1]) && $zone[1],
942 942
                 2 => isset($zone[2]) && $zone[2],
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
         usort($zone_data, '_wp_timezone_choice_usort_callback');
967 967
         $structure = array();
968 968
         if (empty($selected_zone)) {
969
-            $structure[] = '<option selected="selected" value="">' . __('Select a city', 'event_espresso') . '</option>';
969
+            $structure[] = '<option selected="selected" value="">'.__('Select a city', 'event_espresso').'</option>';
970 970
         }
971 971
         foreach ($zone_data as $key => $zone) {
972 972
             // Build value in an array to join later
@@ -977,30 +977,30 @@  discard block
 block discarded – undo
977 977
             } else {
978 978
                 // It's inside a continent group
979 979
                 // Continent optgroup
980
-                if (! isset($zone_data[ $key - 1 ]) || $zone_data[ $key - 1 ]['continent'] !== $zone['continent']) {
980
+                if ( ! isset($zone_data[$key - 1]) || $zone_data[$key - 1]['continent'] !== $zone['continent']) {
981 981
                     $label       = $zone['t_continent'];
982
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
982
+                    $structure[] = '<optgroup label="'.esc_attr($label).'">';
983 983
                 }
984 984
                 // Add the city to the value
985 985
                 $value[] = $zone['city'];
986 986
                 $display = $zone['t_city'];
987
-                if (! empty($zone['subcity'])) {
987
+                if ( ! empty($zone['subcity'])) {
988 988
                     // Add the subcity to the value
989 989
                     $value[] = $zone['subcity'];
990
-                    $display .= ' - ' . $zone['t_subcity'];
990
+                    $display .= ' - '.$zone['t_subcity'];
991 991
                 }
992 992
             }
993 993
             // Build the value
994 994
             $value       = implode('/', $value);
995 995
             $selected    = $value === $selected_zone ? ' selected="selected"' : '';
996
-            $structure[] = '<option value="' . esc_attr($value) . '"' . $selected . '>'
996
+            $structure[] = '<option value="'.esc_attr($value).'"'.$selected.'>'
997 997
                            . esc_html($display)
998 998
                            . '</option>';
999 999
             // Close continent optgroup
1000
-            if (! empty($zone['city'])
1000
+            if ( ! empty($zone['city'])
1001 1001
                 && (
1002
-                    ! isset($zone_data[ $key + 1 ])
1003
-                    || (isset($zone_data[ $key + 1 ]) && $zone_data[ $key + 1 ]['continent'] !== $zone['continent'])
1002
+                    ! isset($zone_data[$key + 1])
1003
+                    || (isset($zone_data[$key + 1]) && $zone_data[$key + 1]['continent'] !== $zone['continent'])
1004 1004
                 )
1005 1005
             ) {
1006 1006
                 $structure[] = '</optgroup>';
Please login to merge, or discard this patch.
core/domain/entities/shortcodes/EspressoEventAttendees.php 2 patches
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -31,338 +31,338 @@
 block discarded – undo
31 31
 class EspressoEventAttendees extends EspressoShortcode
32 32
 {
33 33
 
34
-    private $query_params = array(
35
-        0 => array(),
36
-    );
34
+	private $query_params = array(
35
+		0 => array(),
36
+	);
37 37
 
38
-    private $template_args = array(
39
-        'contacts' => array(),
40
-        'event'    => null,
41
-        'datetime' => null,
42
-        'ticket'   => null,
43
-    );
38
+	private $template_args = array(
39
+		'contacts' => array(),
40
+		'event'    => null,
41
+		'datetime' => null,
42
+		'ticket'   => null,
43
+	);
44 44
 
45
-    /**
46
-     * the actual shortcode tag that gets registered with WordPress
47
-     *
48
-     * @return string
49
-     */
50
-    public function getTag()
51
-    {
52
-        return 'ESPRESSO_EVENT_ATTENDEES';
53
-    }
45
+	/**
46
+	 * the actual shortcode tag that gets registered with WordPress
47
+	 *
48
+	 * @return string
49
+	 */
50
+	public function getTag()
51
+	{
52
+		return 'ESPRESSO_EVENT_ATTENDEES';
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * the time in seconds to cache the results of the processShortcode() method
58
-     * 0 means the processShortcode() results will NOT be cached at all
59
-     *
60
-     * @return int
61
-     */
62
-    public function cacheExpiration()
63
-    {
64
-        return 0;
65
-    }
56
+	/**
57
+	 * the time in seconds to cache the results of the processShortcode() method
58
+	 * 0 means the processShortcode() results will NOT be cached at all
59
+	 *
60
+	 * @return int
61
+	 */
62
+	public function cacheExpiration()
63
+	{
64
+		return 0;
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * a place for adding any initialization code that needs to run prior to wp_header().
70
-     * this may be required for shortcodes that utilize a corresponding module,
71
-     * and need to enqueue assets for that module
72
-     *
73
-     * @return void
74
-     */
75
-    public function initializeShortcode()
76
-    {
77
-        $this->shortcodeHasBeenInitialized();
78
-    }
68
+	/**
69
+	 * a place for adding any initialization code that needs to run prior to wp_header().
70
+	 * this may be required for shortcodes that utilize a corresponding module,
71
+	 * and need to enqueue assets for that module
72
+	 *
73
+	 * @return void
74
+	 */
75
+	public function initializeShortcode()
76
+	{
77
+		$this->shortcodeHasBeenInitialized();
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
-     *  [ESPRESSO_EVENT_ATTENDEES]
84
-     *  - defaults to attendees for earliest active event, or earliest upcoming event.
85
-     *  [ESPRESSO_EVENT_ATTENDEES event_id=123]
86
-     *  - attendees for specific event.
87
-     *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245]
88
-     *  - attendees for a specific datetime.
89
-     *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123]
90
-     *  - attendees for a specific ticket.
91
-     *  [ESPRESSO_EVENT_ATTENDEES status=all]
92
-     *  - specific registration status (use status id) or all for all attendees regardless of status.
93
-     *  Note default is to only return approved attendees
94
-     *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true]
95
-     *  - default is to not return gravatar.  Otherwise if this is set then return gravatar for email address given.
96
-     *  [ESPRESSO_EVENT_ATTENDEES display_on_archives=true]
97
-     *  - default is to not display attendees list on archive pages.
98
-     * Note: because of the relationship between event_id, ticket_id, and datetime_id:
99
-     * If more than one of those params is included, then preference is given to the following:
100
-     *  - event_id is used whenever its present and any others are ignored.
101
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
102
-     *  - otherwise ticket_id is used if present.
103
-     *
104
-     * @param array $attributes
105
-     * @return string
106
-     * @throws EE_Error
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     * @throws InvalidArgumentException
110
-     * @throws DomainException
111
-     */
112
-    public function processShortcode($attributes = array())
113
-    {
114
-        // grab attributes and merge with defaults
115
-        $attributes = $this->getAttributes((array) $attributes);
116
-        $attributes['limit'] = (int) $attributes['limit'];
117
-        $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN);
118
-        // don't display on archives unless 'display_on_archives' is true
119
-        if ($attributes['limit'] === 0 || (! $display_on_archives && is_archive())) {
120
-            return '';
121
-        }
122
-        try {
123
-            $this->setBaseTemplateArguments($attributes);
124
-            $this->validateEntities($attributes);
125
-            $this->setBaseQueryParams();
126
-        } catch (EntityNotFoundException $e) {
127
-            if (WP_DEBUG) {
128
-                return '<div class="important-notice ee-error">'
129
-                       . $e->getMessage()
130
-                       . '</div>';
131
-            }
132
-            return '';
133
-        }
134
-        $this->setAdditionalQueryParams($attributes);
135
-        // get contacts!
136
-        $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
137
-        // all set let's load up the template and return.
138
-        return EEH_Template::locate_template(
139
-            'loop-espresso_event_attendees.php',
140
-            $this->template_args
141
-        );
142
-    }
81
+	/**
82
+	 * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event.
83
+	 *  [ESPRESSO_EVENT_ATTENDEES]
84
+	 *  - defaults to attendees for earliest active event, or earliest upcoming event.
85
+	 *  [ESPRESSO_EVENT_ATTENDEES event_id=123]
86
+	 *  - attendees for specific event.
87
+	 *  [ESPRESSO_EVENT_ATTENDEES datetime_id=245]
88
+	 *  - attendees for a specific datetime.
89
+	 *  [ESPRESSO_EVENT_ATTENDEES ticket_id=123]
90
+	 *  - attendees for a specific ticket.
91
+	 *  [ESPRESSO_EVENT_ATTENDEES status=all]
92
+	 *  - specific registration status (use status id) or all for all attendees regardless of status.
93
+	 *  Note default is to only return approved attendees
94
+	 *  [ESPRESSO_EVENT_ATTENDEES show_gravatar=true]
95
+	 *  - default is to not return gravatar.  Otherwise if this is set then return gravatar for email address given.
96
+	 *  [ESPRESSO_EVENT_ATTENDEES display_on_archives=true]
97
+	 *  - default is to not display attendees list on archive pages.
98
+	 * Note: because of the relationship between event_id, ticket_id, and datetime_id:
99
+	 * If more than one of those params is included, then preference is given to the following:
100
+	 *  - event_id is used whenever its present and any others are ignored.
101
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
102
+	 *  - otherwise ticket_id is used if present.
103
+	 *
104
+	 * @param array $attributes
105
+	 * @return string
106
+	 * @throws EE_Error
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 * @throws InvalidArgumentException
110
+	 * @throws DomainException
111
+	 */
112
+	public function processShortcode($attributes = array())
113
+	{
114
+		// grab attributes and merge with defaults
115
+		$attributes = $this->getAttributes((array) $attributes);
116
+		$attributes['limit'] = (int) $attributes['limit'];
117
+		$display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN);
118
+		// don't display on archives unless 'display_on_archives' is true
119
+		if ($attributes['limit'] === 0 || (! $display_on_archives && is_archive())) {
120
+			return '';
121
+		}
122
+		try {
123
+			$this->setBaseTemplateArguments($attributes);
124
+			$this->validateEntities($attributes);
125
+			$this->setBaseQueryParams();
126
+		} catch (EntityNotFoundException $e) {
127
+			if (WP_DEBUG) {
128
+				return '<div class="important-notice ee-error">'
129
+					   . $e->getMessage()
130
+					   . '</div>';
131
+			}
132
+			return '';
133
+		}
134
+		$this->setAdditionalQueryParams($attributes);
135
+		// get contacts!
136
+		$this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params);
137
+		// all set let's load up the template and return.
138
+		return EEH_Template::locate_template(
139
+			'loop-espresso_event_attendees.php',
140
+			$this->template_args
141
+		);
142
+	}
143 143
 
144 144
 
145
-    /**
146
-     * merge incoming attributes with filtered defaults
147
-     *
148
-     * @param array $attributes
149
-     * @return array
150
-     */
151
-    private function getAttributes(array $attributes)
152
-    {
153
-        return (array) apply_filters(
154
-            'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
155
-            $attributes + array(
156
-                'event_id'            => null,
157
-                'datetime_id'         => null,
158
-                'ticket_id'           => null,
159
-                'status'              => EEM_Registration::status_id_approved,
160
-                'show_gravatar'       => false,
161
-                'display_on_archives' => false,
162
-                'limit'               => 10,
163
-            )
164
-        );
165
-    }
145
+	/**
146
+	 * merge incoming attributes with filtered defaults
147
+	 *
148
+	 * @param array $attributes
149
+	 * @return array
150
+	 */
151
+	private function getAttributes(array $attributes)
152
+	{
153
+		return (array) apply_filters(
154
+			'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts',
155
+			$attributes + array(
156
+				'event_id'            => null,
157
+				'datetime_id'         => null,
158
+				'ticket_id'           => null,
159
+				'status'              => EEM_Registration::status_id_approved,
160
+				'show_gravatar'       => false,
161
+				'display_on_archives' => false,
162
+				'limit'               => 10,
163
+			)
164
+		);
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * Set all the base template arguments from the incoming attributes.
170
-     * * Note: because of the relationship between event_id, ticket_id, and datetime_id:
171
-     * If more than one of those params is included, then preference is given to the following:
172
-     *  - event_id is used whenever its present and any others are ignored.
173
-     *  - if no event_id then datetime is used whenever its present and any others are ignored.
174
-     *  - otherwise ticket_id is used if present.
175
-     *
176
-     * @param array $attributes
177
-     * @throws EE_Error
178
-     * @throws InvalidDataTypeException
179
-     * @throws InvalidInterfaceException
180
-     * @throws InvalidArgumentException
181
-     */
182
-    private function setBaseTemplateArguments(array $attributes)
183
-    {
184
-        $this->template_args['show_gravatar'] = $attributes['show_gravatar'];
185
-        $this->template_args['event'] = $this->getEvent($attributes);
186
-        $this->template_args['datetime'] = empty($attributes['event_id'])
187
-            ? $this->getDatetime($attributes)
188
-            : null;
189
-        $this->template_args['ticket'] = empty($attributes['datetime_id']) && empty($attributes['event_id'])
190
-            ? $this->getTicket($attributes)
191
-            : null;
192
-    }
168
+	/**
169
+	 * Set all the base template arguments from the incoming attributes.
170
+	 * * Note: because of the relationship between event_id, ticket_id, and datetime_id:
171
+	 * If more than one of those params is included, then preference is given to the following:
172
+	 *  - event_id is used whenever its present and any others are ignored.
173
+	 *  - if no event_id then datetime is used whenever its present and any others are ignored.
174
+	 *  - otherwise ticket_id is used if present.
175
+	 *
176
+	 * @param array $attributes
177
+	 * @throws EE_Error
178
+	 * @throws InvalidDataTypeException
179
+	 * @throws InvalidInterfaceException
180
+	 * @throws InvalidArgumentException
181
+	 */
182
+	private function setBaseTemplateArguments(array $attributes)
183
+	{
184
+		$this->template_args['show_gravatar'] = $attributes['show_gravatar'];
185
+		$this->template_args['event'] = $this->getEvent($attributes);
186
+		$this->template_args['datetime'] = empty($attributes['event_id'])
187
+			? $this->getDatetime($attributes)
188
+			: null;
189
+		$this->template_args['ticket'] = empty($attributes['datetime_id']) && empty($attributes['event_id'])
190
+			? $this->getTicket($attributes)
191
+			: null;
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * Validates the presence of entities for the given attribute values.
197
-     *
198
-     * @param array $attributes
199
-     * @throws EntityNotFoundException
200
-     */
201
-    private function validateEntities(array $attributes)
202
-    {
203
-        if (! $this->template_args['event'] instanceof EE_Event
204
-            || (
205
-                empty($attributes['event_id'])
206
-                && $attributes['datetime_id']
207
-                && ! $this->template_args['datetime'] instanceof EE_Datetime
208
-            )
209
-            || (
210
-                empty($attributes['event_id'])
211
-                && empty($attributes['datetime_id'])
212
-                && $attributes['ticket_id']
213
-                && ! $this->template_args['ticket'] instanceof EE_Ticket
214
-            )
215
-        ) {
216
-            throw new EntityNotFoundException(
217
-                '',
218
-                '',
219
-                esc_html__(
220
-                    'The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
221
-                    'event_espresso'
222
-                )
223
-            );
224
-        }
225
-    }
195
+	/**
196
+	 * Validates the presence of entities for the given attribute values.
197
+	 *
198
+	 * @param array $attributes
199
+	 * @throws EntityNotFoundException
200
+	 */
201
+	private function validateEntities(array $attributes)
202
+	{
203
+		if (! $this->template_args['event'] instanceof EE_Event
204
+			|| (
205
+				empty($attributes['event_id'])
206
+				&& $attributes['datetime_id']
207
+				&& ! $this->template_args['datetime'] instanceof EE_Datetime
208
+			)
209
+			|| (
210
+				empty($attributes['event_id'])
211
+				&& empty($attributes['datetime_id'])
212
+				&& $attributes['ticket_id']
213
+				&& ! $this->template_args['ticket'] instanceof EE_Ticket
214
+			)
215
+		) {
216
+			throw new EntityNotFoundException(
217
+				'',
218
+				'',
219
+				esc_html__(
220
+					'The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly.  Please double check the arguments you used for any typos.  In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.',
221
+					'event_espresso'
222
+				)
223
+			);
224
+		}
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * Sets the query params for the base query elements.
230
-     */
231
-    private function setBaseQueryParams()
232
-    {
233
-        switch (true) {
234
-            case $this->template_args['datetime'] instanceof EE_Datetime:
235
-                $this->query_params = array(
236
-                    0                          => array(
237
-                        'Registration.Ticket.Datetime.DTT_ID' => $this->template_args['datetime']->ID(),
238
-                    ),
239
-                    'default_where_conditions' => 'this_model_only',
240
-                );
241
-                break;
242
-            case $this->template_args['ticket'] instanceof EE_Ticket:
243
-                $this->query_params[0] = array(
244
-                    'Registration.TKT_ID' => $this->template_args['ticket']->ID(),
245
-                );
246
-                break;
247
-            case $this->template_args['event'] instanceof EE_Event:
248
-                $this->query_params[0] = array(
249
-                    'Registration.EVT_ID' => $this->template_args['event']->ID(),
250
-                );
251
-                break;
252
-        }
253
-    }
228
+	/**
229
+	 * Sets the query params for the base query elements.
230
+	 */
231
+	private function setBaseQueryParams()
232
+	{
233
+		switch (true) {
234
+			case $this->template_args['datetime'] instanceof EE_Datetime:
235
+				$this->query_params = array(
236
+					0                          => array(
237
+						'Registration.Ticket.Datetime.DTT_ID' => $this->template_args['datetime']->ID(),
238
+					),
239
+					'default_where_conditions' => 'this_model_only',
240
+				);
241
+				break;
242
+			case $this->template_args['ticket'] instanceof EE_Ticket:
243
+				$this->query_params[0] = array(
244
+					'Registration.TKT_ID' => $this->template_args['ticket']->ID(),
245
+				);
246
+				break;
247
+			case $this->template_args['event'] instanceof EE_Event:
248
+				$this->query_params[0] = array(
249
+					'Registration.EVT_ID' => $this->template_args['event']->ID(),
250
+				);
251
+				break;
252
+		}
253
+	}
254 254
 
255 255
 
256
-    /**
257
-     * @param array $attributes
258
-     * @return EE_Event|null
259
-     * @throws EE_Error
260
-     * @throws InvalidDataTypeException
261
-     * @throws InvalidInterfaceException
262
-     * @throws InvalidArgumentException
263
-     */
264
-    private function getEvent(array $attributes)
265
-    {
266
-        switch (true) {
267
-            case ! empty($attributes['event_id']):
268
-                $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
269
-                break;
270
-            case ! empty($attributes['datetime_id']):
271
-                $event = EEM_Event::instance()->get_one(array(
272
-                    array(
273
-                        'Datetime.DTT_ID' => $attributes['datetime_id'],
274
-                    ),
275
-                ));
276
-                break;
277
-            case ! empty($attributes['ticket_id']):
278
-                $event = EEM_Event::instance()->get_one(array(
279
-                    array(
280
-                        'Datetime.Ticket.TKT_ID' => $attributes['ticket_id'],
281
-                    ),
282
-                    'default_where_conditions' => 'none'
283
-                ));
284
-                break;
285
-            case is_espresso_event():
286
-                $event = EEH_Event_View::get_event();
287
-                break;
288
-            default:
289
-                // one last shot...
290
-                // try getting the earliest active event
291
-                $events = EEM_Event::instance()->get_active_events(array(
292
-                    'limit'    => 1,
293
-                    'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
294
-                ));
295
-                //  if none then get the next upcoming
296
-                $events = empty($events)
297
-                    ? EEM_Event::instance()->get_upcoming_events(array(
298
-                        'limit'    => 1,
299
-                        'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
300
-                    ))
301
-                    : $events;
302
-                $event = reset($events);
303
-        }
256
+	/**
257
+	 * @param array $attributes
258
+	 * @return EE_Event|null
259
+	 * @throws EE_Error
260
+	 * @throws InvalidDataTypeException
261
+	 * @throws InvalidInterfaceException
262
+	 * @throws InvalidArgumentException
263
+	 */
264
+	private function getEvent(array $attributes)
265
+	{
266
+		switch (true) {
267
+			case ! empty($attributes['event_id']):
268
+				$event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']);
269
+				break;
270
+			case ! empty($attributes['datetime_id']):
271
+				$event = EEM_Event::instance()->get_one(array(
272
+					array(
273
+						'Datetime.DTT_ID' => $attributes['datetime_id'],
274
+					),
275
+				));
276
+				break;
277
+			case ! empty($attributes['ticket_id']):
278
+				$event = EEM_Event::instance()->get_one(array(
279
+					array(
280
+						'Datetime.Ticket.TKT_ID' => $attributes['ticket_id'],
281
+					),
282
+					'default_where_conditions' => 'none'
283
+				));
284
+				break;
285
+			case is_espresso_event():
286
+				$event = EEH_Event_View::get_event();
287
+				break;
288
+			default:
289
+				// one last shot...
290
+				// try getting the earliest active event
291
+				$events = EEM_Event::instance()->get_active_events(array(
292
+					'limit'    => 1,
293
+					'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
294
+				));
295
+				//  if none then get the next upcoming
296
+				$events = empty($events)
297
+					? EEM_Event::instance()->get_upcoming_events(array(
298
+						'limit'    => 1,
299
+						'order_by' => array('Datetime.DTT_EVT_start' => 'ASC'),
300
+					))
301
+					: $events;
302
+				$event = reset($events);
303
+		}
304 304
 
305
-        return $event instanceof EE_Event ? $event : null;
306
-    }
305
+		return $event instanceof EE_Event ? $event : null;
306
+	}
307 307
 
308 308
 
309
-    /**
310
-     * @param array $attributes
311
-     * @return EE_Datetime|null
312
-     * @throws EE_Error
313
-     * @throws InvalidDataTypeException
314
-     * @throws InvalidInterfaceException
315
-     * @throws InvalidArgumentException
316
-     */
317
-    private function getDatetime(array $attributes)
318
-    {
319
-        if (! empty($attributes['datetime_id'])) {
320
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
321
-            if ($datetime instanceof EE_Datetime) {
322
-                return $datetime;
323
-            }
324
-        }
325
-        return null;
326
-    }
309
+	/**
310
+	 * @param array $attributes
311
+	 * @return EE_Datetime|null
312
+	 * @throws EE_Error
313
+	 * @throws InvalidDataTypeException
314
+	 * @throws InvalidInterfaceException
315
+	 * @throws InvalidArgumentException
316
+	 */
317
+	private function getDatetime(array $attributes)
318
+	{
319
+		if (! empty($attributes['datetime_id'])) {
320
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
321
+			if ($datetime instanceof EE_Datetime) {
322
+				return $datetime;
323
+			}
324
+		}
325
+		return null;
326
+	}
327 327
 
328 328
 
329
-    /**
330
-     * @param array $attributes
331
-     * @return \EE_Base_Class|EE_Ticket|null
332
-     * @throws EE_Error
333
-     * @throws InvalidDataTypeException
334
-     * @throws InvalidInterfaceException
335
-     * @throws InvalidArgumentException
336
-     */
337
-    private function getTicket(array $attributes)
338
-    {
339
-        if (! empty($attributes['ticket_id'])) {
340
-            $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
341
-            if ($ticket instanceof EE_Ticket) {
342
-                return $ticket;
343
-            }
344
-        }
345
-        return null;
346
-    }
329
+	/**
330
+	 * @param array $attributes
331
+	 * @return \EE_Base_Class|EE_Ticket|null
332
+	 * @throws EE_Error
333
+	 * @throws InvalidDataTypeException
334
+	 * @throws InvalidInterfaceException
335
+	 * @throws InvalidArgumentException
336
+	 */
337
+	private function getTicket(array $attributes)
338
+	{
339
+		if (! empty($attributes['ticket_id'])) {
340
+			$ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
341
+			if ($ticket instanceof EE_Ticket) {
342
+				return $ticket;
343
+			}
344
+		}
345
+		return null;
346
+	}
347 347
 
348 348
 
349
-    /**
350
-     * @param array $attributes
351
-     * @throws EE_Error
352
-     */
353
-    private function setAdditionalQueryParams(array $attributes)
354
-    {
355
-        $reg_status_array = EEM_Registration::reg_status_array();
356
-        if (isset($reg_status_array[ $attributes['status'] ])) {
357
-            $this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
358
-        }
359
-        if (absint($attributes['limit'])) {
360
-            $this->query_params['limit'] = $attributes['limit'];
361
-        }
362
-        $this->query_params['group_by'] = array('ATT_ID');
363
-        $this->query_params['order_by'] = (array) apply_filters(
364
-            'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
365
-            array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
366
-        );
367
-    }
349
+	/**
350
+	 * @param array $attributes
351
+	 * @throws EE_Error
352
+	 */
353
+	private function setAdditionalQueryParams(array $attributes)
354
+	{
355
+		$reg_status_array = EEM_Registration::reg_status_array();
356
+		if (isset($reg_status_array[ $attributes['status'] ])) {
357
+			$this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
358
+		}
359
+		if (absint($attributes['limit'])) {
360
+			$this->query_params['limit'] = $attributes['limit'];
361
+		}
362
+		$this->query_params['group_by'] = array('ATT_ID');
363
+		$this->query_params['order_by'] = (array) apply_filters(
364
+			'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by',
365
+			array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')
366
+		);
367
+	}
368 368
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $attributes['limit'] = (int) $attributes['limit'];
117 117
         $display_on_archives = filter_var($attributes['display_on_archives'], FILTER_VALIDATE_BOOLEAN);
118 118
         // don't display on archives unless 'display_on_archives' is true
119
-        if ($attributes['limit'] === 0 || (! $display_on_archives && is_archive())) {
119
+        if ($attributes['limit'] === 0 || ( ! $display_on_archives && is_archive())) {
120 120
             return '';
121 121
         }
122 122
         try {
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     private function validateEntities(array $attributes)
202 202
     {
203
-        if (! $this->template_args['event'] instanceof EE_Event
203
+        if ( ! $this->template_args['event'] instanceof EE_Event
204 204
             || (
205 205
                 empty($attributes['event_id'])
206 206
                 && $attributes['datetime_id']
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      */
317 317
     private function getDatetime(array $attributes)
318 318
     {
319
-        if (! empty($attributes['datetime_id'])) {
319
+        if ( ! empty($attributes['datetime_id'])) {
320 320
             $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']);
321 321
             if ($datetime instanceof EE_Datetime) {
322 322
                 return $datetime;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
      */
337 337
     private function getTicket(array $attributes)
338 338
     {
339
-        if (! empty($attributes['ticket_id'])) {
339
+        if ( ! empty($attributes['ticket_id'])) {
340 340
             $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']);
341 341
             if ($ticket instanceof EE_Ticket) {
342 342
                 return $ticket;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     private function setAdditionalQueryParams(array $attributes)
354 354
     {
355 355
         $reg_status_array = EEM_Registration::reg_status_array();
356
-        if (isset($reg_status_array[ $attributes['status'] ])) {
356
+        if (isset($reg_status_array[$attributes['status']])) {
357 357
             $this->query_params[0]['Registration.STS_ID'] = $attributes['status'];
358 358
         }
359 359
         if (absint($attributes['limit'])) {
Please login to merge, or discard this patch.
core/services/collections/Collection.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
195 195
      *
196 196
      * @param mixed $identifier
197
-     * @return mixed
197
+     * @return boolean
198 198
      */
199 199
     public function get($identifier)
200 200
     {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * setCurrentUsingObject
310 310
      * advances pointer to the provided object
311 311
      *
312
-     * @param $object
312
+     * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object
313 313
      * @return boolean
314 314
      */
315 315
     public function setCurrentUsingObject($object)
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      *
348 348
      * @see http://stackoverflow.com/a/8736013
349 349
      * @param $object
350
-     * @return boolean|int|string
350
+     * @return integer
351 351
      */
352 352
     public function indexOf($object)
353 353
     {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function setCollectionInterface($collection_interface)
68 68
     {
69
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
69
+        if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) {
70 70
             throw new InvalidInterfaceException($collection_interface);
71 71
         }
72 72
         $this->collection_interface = $collection_interface;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
     protected function setCollectionIdentifier()
112 112
     {
113 113
         // hash a few collection details
114
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
114
+        $identifier = md5(spl_object_hash($this).$this->collection_interface.time());
115 115
         // grab a few characters from the start, middle, and end of the hash
116 116
         $id = array();
117 117
         for ($x = 0; $x < 19; $x += 9) {
118 118
             $id[] = substr($identifier, $x, 3);
119 119
         }
120
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
120
+        $this->collection_identifier = $this->collection_name.'-'.strtoupper(implode('-', $id));
121 121
     }
122 122
 
123 123
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function add($object, $identifier = null)
137 137
     {
138
-        if (! $object instanceof $this->collection_interface) {
138
+        if ( ! $object instanceof $this->collection_interface) {
139 139
             throw new InvalidEntityException($object, $this->collection_interface);
140 140
         }
141 141
         if ($this->contains($object)) {
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public function indexOf($object)
353 353
     {
354
-        if (! $this->contains($object)) {
354
+        if ( ! $this->contains($object)) {
355 355
             return false;
356 356
         }
357 357
         foreach ($this as $index => $obj) {
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
             $remaining_objects = $this->slice($index, $this->count() - $index);
421 421
             foreach ($remaining_objects as $key => $remaining_object) {
422 422
                 // we need to grab the identifiers for each object and use them as keys
423
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
423
+                $remaining_objects[$remaining_object->getInfo()] = $remaining_object;
424 424
                 // and then remove the object from the current tracking array
425
-                unset($remaining_objects[ $key ]);
425
+                unset($remaining_objects[$key]);
426 426
                 // and then remove it from the Collection
427 427
                 $this->detach($remaining_object);
428 428
             }
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
      */
447 447
     public function insertAt($objects, $index)
448 448
     {
449
-        if (! is_array($objects)) {
449
+        if ( ! is_array($objects)) {
450 450
             $objects = array($objects);
451 451
         }
452 452
         // check to ensure that objects don't already exist in the collection
453 453
         foreach ($objects as $key => $object) {
454 454
             if ($this->contains($object)) {
455
-                unset($objects[ $key ]);
455
+                unset($objects[$key]);
456 456
             }
457 457
         }
458 458
         // do we have any objects left?
459
-        if (! $objects) {
459
+        if ( ! $objects) {
460 460
             return;
461 461
         }
462 462
         // detach any objects at or past this index
Please login to merge, or discard this patch.
Indentation   +500 added lines, -500 removed lines patch added patch discarded remove patch
@@ -19,504 +19,504 @@
 block discarded – undo
19 19
 class Collection extends SplObjectStorage implements CollectionInterface
20 20
 {
21 21
 
22
-    /**
23
-     * a unique string for identifying this collection
24
-     *
25
-     * @type string $collection_identifier
26
-     */
27
-    protected $collection_identifier;
28
-
29
-
30
-    /**
31
-     * an interface (or class) name to be used for restricting the type of objects added to the storage
32
-     * this should be set from within the child class constructor
33
-     *
34
-     * @type string $interface
35
-     */
36
-    protected $collection_interface;
37
-
38
-    /**
39
-     * a short dash separated string describing the contents of this collection
40
-     * used as the base for the $collection_identifier
41
-     * defaults to the class short name if not set
42
-     *
43
-     * @type string $collection_identifier
44
-     */
45
-    protected $collection_name;
46
-
47
-
48
-    /**
49
-     * Collection constructor
50
-     *
51
-     * @param string $collection_interface
52
-     * @param string $collection_name
53
-     * @throws InvalidInterfaceException
54
-     */
55
-    public function __construct($collection_interface, $collection_name = '')
56
-    {
57
-        $this->setCollectionInterface($collection_interface);
58
-        $this->setCollectionName($collection_name);
59
-        $this->setCollectionIdentifier();
60
-    }
61
-
62
-
63
-    /**
64
-     * setCollectionInterface
65
-     *
66
-     * @param  string $collection_interface
67
-     * @throws InvalidInterfaceException
68
-     */
69
-    protected function setCollectionInterface($collection_interface)
70
-    {
71
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
72
-            throw new InvalidInterfaceException($collection_interface);
73
-        }
74
-        $this->collection_interface = $collection_interface;
75
-    }
76
-
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    public function collectionName()
82
-    {
83
-        return $this->collection_name;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param string $collection_name
89
-     */
90
-    protected function setCollectionName($collection_name)
91
-    {
92
-        $this->collection_name = ! empty($collection_name)
93
-            ? sanitize_key($collection_name)
94
-            : basename(str_replace('\\', '/', get_class($this)));
95
-    }
96
-
97
-
98
-    /**
99
-     * @return string
100
-     */
101
-    public function collectionIdentifier()
102
-    {
103
-        return $this->collection_identifier;
104
-    }
105
-
106
-
107
-    /**
108
-     * creates a very readable unique 9 character identifier like:  CF2-532-DAC
109
-     * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
110
-     *
111
-     * @return void
112
-     */
113
-    protected function setCollectionIdentifier()
114
-    {
115
-        // hash a few collection details
116
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
117
-        // grab a few characters from the start, middle, and end of the hash
118
-        $id = array();
119
-        for ($x = 0; $x < 19; $x += 9) {
120
-            $id[] = substr($identifier, $x, 3);
121
-        }
122
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
123
-    }
124
-
125
-
126
-    /**
127
-     * add
128
-     * attaches an object to the Collection
129
-     * and sets any supplied data associated with the current iterator entry
130
-     * by calling EE_Object_Collection::set_identifier()
131
-     *
132
-     * @param        $object
133
-     * @param  mixed $identifier
134
-     * @return bool
135
-     * @throws InvalidEntityException
136
-     * @throws DuplicateCollectionIdentifierException
137
-     */
138
-    public function add($object, $identifier = null)
139
-    {
140
-        if (! $object instanceof $this->collection_interface) {
141
-            throw new InvalidEntityException($object, $this->collection_interface);
142
-        }
143
-        if ($this->contains($object)) {
144
-            throw new DuplicateCollectionIdentifierException($identifier);
145
-        }
146
-        $this->attach($object);
147
-        $this->setIdentifier($object, $identifier);
148
-        return $this->contains($object);
149
-    }
150
-
151
-
152
-    /**
153
-     * getIdentifier
154
-     * if no $identifier is supplied, then the spl_object_hash() is used
155
-     *
156
-     * @param        $object
157
-     * @param  mixed $identifier
158
-     * @return bool
159
-     */
160
-    public function getIdentifier($object, $identifier = null)
161
-    {
162
-        return ! empty($identifier)
163
-            ? $identifier
164
-            : spl_object_hash($object);
165
-    }
166
-
167
-
168
-    /**
169
-     * setIdentifier
170
-     * Sets the data associated with an object in the Collection
171
-     * if no $identifier is supplied, then the spl_object_hash() is used
172
-     *
173
-     * @param        $object
174
-     * @param  mixed $identifier
175
-     * @return bool
176
-     */
177
-    public function setIdentifier($object, $identifier = null)
178
-    {
179
-        $identifier = $this->getIdentifier($object, $identifier);
180
-        $this->rewind();
181
-        while ($this->valid()) {
182
-            if ($object === $this->current()) {
183
-                $this->setInfo($identifier);
184
-                $this->rewind();
185
-                return true;
186
-            }
187
-            $this->next();
188
-        }
189
-        return false;
190
-    }
191
-
192
-
193
-    /**
194
-     * get
195
-     * finds and returns an object in the Collection based on the identifier that was set using addObject()
196
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
197
-     *
198
-     * @param mixed $identifier
199
-     * @return mixed
200
-     */
201
-    public function get($identifier)
202
-    {
203
-        $this->rewind();
204
-        while ($this->valid()) {
205
-            if ($identifier === $this->getInfo()) {
206
-                $object = $this->current();
207
-                $this->rewind();
208
-                return $object;
209
-            }
210
-            $this->next();
211
-        }
212
-        return null;
213
-    }
214
-
215
-
216
-    /**
217
-     * has
218
-     * returns TRUE or FALSE
219
-     * depending on whether the object is within the Collection
220
-     * based on the supplied $identifier
221
-     *
222
-     * @param  mixed $identifier
223
-     * @return bool
224
-     */
225
-    public function has($identifier)
226
-    {
227
-        $this->rewind();
228
-        while ($this->valid()) {
229
-            if ($identifier === $this->getInfo()) {
230
-                $this->rewind();
231
-                return true;
232
-            }
233
-            $this->next();
234
-        }
235
-        return false;
236
-    }
237
-
238
-
239
-    /**
240
-     * hasObject
241
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
242
-     *
243
-     * @param $object
244
-     * @return bool
245
-     */
246
-    public function hasObject($object)
247
-    {
248
-        return $this->contains($object);
249
-    }
250
-
251
-
252
-    /**
253
-     * hasObjects
254
-     * returns true if there are objects within the Collection, and false if it is empty
255
-     *
256
-     * @return bool
257
-     */
258
-    public function hasObjects()
259
-    {
260
-        return $this->count() !== 0;
261
-    }
262
-
263
-
264
-    /**
265
-     * isEmpty
266
-     * returns true if there are no objects within the Collection, and false if there are
267
-     *
268
-     * @return bool
269
-     */
270
-    public function isEmpty()
271
-    {
272
-        return $this->count() === 0;
273
-    }
274
-
275
-
276
-    /**
277
-     * remove
278
-     * detaches an object from the Collection
279
-     *
280
-     * @param $object
281
-     * @return bool
282
-     */
283
-    public function remove($object)
284
-    {
285
-        $this->detach($object);
286
-        return true;
287
-    }
288
-
289
-
290
-    /**
291
-     * setCurrent
292
-     * advances pointer to the object whose identifier matches that which was provided
293
-     *
294
-     * @param mixed $identifier
295
-     * @return boolean
296
-     */
297
-    public function setCurrent($identifier)
298
-    {
299
-        $this->rewind();
300
-        while ($this->valid()) {
301
-            if ($identifier === $this->getInfo()) {
302
-                return true;
303
-            }
304
-            $this->next();
305
-        }
306
-        return false;
307
-    }
308
-
309
-
310
-    /**
311
-     * setCurrentUsingObject
312
-     * advances pointer to the provided object
313
-     *
314
-     * @param $object
315
-     * @return boolean
316
-     */
317
-    public function setCurrentUsingObject($object)
318
-    {
319
-        $this->rewind();
320
-        while ($this->valid()) {
321
-            if ($this->current() === $object) {
322
-                return true;
323
-            }
324
-            $this->next();
325
-        }
326
-        return false;
327
-    }
328
-
329
-
330
-    /**
331
-     * Returns the object occupying the index before the current object,
332
-     * unless this is already the first object, in which case it just returns the first object
333
-     *
334
-     * @return mixed
335
-     */
336
-    public function previous()
337
-    {
338
-        $index = $this->indexOf($this->current());
339
-        if ($index === 0) {
340
-            return $this->current();
341
-        }
342
-        $index--;
343
-        return $this->objectAtIndex($index);
344
-    }
345
-
346
-
347
-    /**
348
-     * Returns the index of a given object, or false if not found
349
-     *
350
-     * @see http://stackoverflow.com/a/8736013
351
-     * @param $object
352
-     * @return boolean|int|string
353
-     */
354
-    public function indexOf($object)
355
-    {
356
-        if (! $this->contains($object)) {
357
-            return false;
358
-        }
359
-        foreach ($this as $index => $obj) {
360
-            if ($obj === $object) {
361
-                return $index;
362
-            }
363
-        }
364
-        return false;
365
-    }
366
-
367
-
368
-    /**
369
-     * Returns the object at the given index
370
-     *
371
-     * @see http://stackoverflow.com/a/8736013
372
-     * @param int $index
373
-     * @return mixed
374
-     */
375
-    public function objectAtIndex($index)
376
-    {
377
-        $iterator = new LimitIterator($this, $index, 1);
378
-        $iterator->rewind();
379
-        return $iterator->current();
380
-    }
381
-
382
-
383
-    /**
384
-     * Returns the sequence of objects as specified by the offset and length
385
-     *
386
-     * @see http://stackoverflow.com/a/8736013
387
-     * @param int $offset
388
-     * @param int $length
389
-     * @return array
390
-     */
391
-    public function slice($offset, $length)
392
-    {
393
-        $slice = array();
394
-        $iterator = new LimitIterator($this, $offset, $length);
395
-        foreach ($iterator as $object) {
396
-            $slice[] = $object;
397
-        }
398
-        return $slice;
399
-    }
400
-
401
-
402
-    /**
403
-     * Inserts an object at a certain point
404
-     *
405
-     * @see http://stackoverflow.com/a/8736013
406
-     * @param mixed $object A single object
407
-     * @param int   $index
408
-     * @param mixed $identifier
409
-     * @return bool
410
-     * @throws DuplicateCollectionIdentifierException
411
-     * @throws InvalidEntityException
412
-     */
413
-    public function insertObjectAt($object, $index, $identifier = null)
414
-    {
415
-        // check to ensure that objects don't already exist in the collection
416
-        if ($this->has($identifier)) {
417
-            throw new DuplicateCollectionIdentifierException($identifier);
418
-        }
419
-        // detach any objects at or past this index
420
-        $remaining_objects = array();
421
-        if ($index < $this->count()) {
422
-            $remaining_objects = $this->slice($index, $this->count() - $index);
423
-            foreach ($remaining_objects as $key => $remaining_object) {
424
-                // we need to grab the identifiers for each object and use them as keys
425
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
426
-                // and then remove the object from the current tracking array
427
-                unset($remaining_objects[ $key ]);
428
-                // and then remove it from the Collection
429
-                $this->detach($remaining_object);
430
-            }
431
-        }
432
-        // add the new object we're splicing in
433
-        $this->add($object, $identifier);
434
-        // attach the objects we previously detached
435
-        foreach ($remaining_objects as $key => $remaining_object) {
436
-            $this->add($remaining_object, $key);
437
-        }
438
-        return $this->contains($object);
439
-    }
440
-
441
-
442
-    /**
443
-     * Inserts an object (or an array of objects) at a certain point
444
-     *
445
-     * @see http://stackoverflow.com/a/8736013
446
-     * @param mixed $objects A single object or an array of objects
447
-     * @param int   $index
448
-     */
449
-    public function insertAt($objects, $index)
450
-    {
451
-        if (! is_array($objects)) {
452
-            $objects = array($objects);
453
-        }
454
-        // check to ensure that objects don't already exist in the collection
455
-        foreach ($objects as $key => $object) {
456
-            if ($this->contains($object)) {
457
-                unset($objects[ $key ]);
458
-            }
459
-        }
460
-        // do we have any objects left?
461
-        if (! $objects) {
462
-            return;
463
-        }
464
-        // detach any objects at or past this index
465
-        $remaining = array();
466
-        if ($index < $this->count()) {
467
-            $remaining = $this->slice($index, $this->count() - $index);
468
-            foreach ($remaining as $object) {
469
-                $this->detach($object);
470
-            }
471
-        }
472
-        // add the new objects we're splicing in
473
-        foreach ($objects as $object) {
474
-            $this->attach($object);
475
-        }
476
-        // attach the objects we previously detached
477
-        foreach ($remaining as $object) {
478
-            $this->attach($object);
479
-        }
480
-    }
481
-
482
-
483
-    /**
484
-     * Removes the object at the given index
485
-     *
486
-     * @see http://stackoverflow.com/a/8736013
487
-     * @param int $index
488
-     */
489
-    public function removeAt($index)
490
-    {
491
-        $this->detach($this->objectAtIndex($index));
492
-    }
493
-
494
-
495
-    /**
496
-     * detaches ALL objects from the Collection
497
-     */
498
-    public function detachAll()
499
-    {
500
-        $this->rewind();
501
-        while ($this->valid()) {
502
-            $object = $this->current();
503
-            $this->next();
504
-            $this->detach($object);
505
-        }
506
-    }
507
-
508
-
509
-    /**
510
-     * unsets and detaches ALL objects from the Collection
511
-     */
512
-    public function trashAndDetachAll()
513
-    {
514
-        $this->rewind();
515
-        while ($this->valid()) {
516
-            $object = $this->current();
517
-            $this->next();
518
-            $this->detach($object);
519
-            unset($object);
520
-        }
521
-    }
22
+	/**
23
+	 * a unique string for identifying this collection
24
+	 *
25
+	 * @type string $collection_identifier
26
+	 */
27
+	protected $collection_identifier;
28
+
29
+
30
+	/**
31
+	 * an interface (or class) name to be used for restricting the type of objects added to the storage
32
+	 * this should be set from within the child class constructor
33
+	 *
34
+	 * @type string $interface
35
+	 */
36
+	protected $collection_interface;
37
+
38
+	/**
39
+	 * a short dash separated string describing the contents of this collection
40
+	 * used as the base for the $collection_identifier
41
+	 * defaults to the class short name if not set
42
+	 *
43
+	 * @type string $collection_identifier
44
+	 */
45
+	protected $collection_name;
46
+
47
+
48
+	/**
49
+	 * Collection constructor
50
+	 *
51
+	 * @param string $collection_interface
52
+	 * @param string $collection_name
53
+	 * @throws InvalidInterfaceException
54
+	 */
55
+	public function __construct($collection_interface, $collection_name = '')
56
+	{
57
+		$this->setCollectionInterface($collection_interface);
58
+		$this->setCollectionName($collection_name);
59
+		$this->setCollectionIdentifier();
60
+	}
61
+
62
+
63
+	/**
64
+	 * setCollectionInterface
65
+	 *
66
+	 * @param  string $collection_interface
67
+	 * @throws InvalidInterfaceException
68
+	 */
69
+	protected function setCollectionInterface($collection_interface)
70
+	{
71
+		if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
72
+			throw new InvalidInterfaceException($collection_interface);
73
+		}
74
+		$this->collection_interface = $collection_interface;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	public function collectionName()
82
+	{
83
+		return $this->collection_name;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param string $collection_name
89
+	 */
90
+	protected function setCollectionName($collection_name)
91
+	{
92
+		$this->collection_name = ! empty($collection_name)
93
+			? sanitize_key($collection_name)
94
+			: basename(str_replace('\\', '/', get_class($this)));
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return string
100
+	 */
101
+	public function collectionIdentifier()
102
+	{
103
+		return $this->collection_identifier;
104
+	}
105
+
106
+
107
+	/**
108
+	 * creates a very readable unique 9 character identifier like:  CF2-532-DAC
109
+	 * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
110
+	 *
111
+	 * @return void
112
+	 */
113
+	protected function setCollectionIdentifier()
114
+	{
115
+		// hash a few collection details
116
+		$identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
117
+		// grab a few characters from the start, middle, and end of the hash
118
+		$id = array();
119
+		for ($x = 0; $x < 19; $x += 9) {
120
+			$id[] = substr($identifier, $x, 3);
121
+		}
122
+		$this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
123
+	}
124
+
125
+
126
+	/**
127
+	 * add
128
+	 * attaches an object to the Collection
129
+	 * and sets any supplied data associated with the current iterator entry
130
+	 * by calling EE_Object_Collection::set_identifier()
131
+	 *
132
+	 * @param        $object
133
+	 * @param  mixed $identifier
134
+	 * @return bool
135
+	 * @throws InvalidEntityException
136
+	 * @throws DuplicateCollectionIdentifierException
137
+	 */
138
+	public function add($object, $identifier = null)
139
+	{
140
+		if (! $object instanceof $this->collection_interface) {
141
+			throw new InvalidEntityException($object, $this->collection_interface);
142
+		}
143
+		if ($this->contains($object)) {
144
+			throw new DuplicateCollectionIdentifierException($identifier);
145
+		}
146
+		$this->attach($object);
147
+		$this->setIdentifier($object, $identifier);
148
+		return $this->contains($object);
149
+	}
150
+
151
+
152
+	/**
153
+	 * getIdentifier
154
+	 * if no $identifier is supplied, then the spl_object_hash() is used
155
+	 *
156
+	 * @param        $object
157
+	 * @param  mixed $identifier
158
+	 * @return bool
159
+	 */
160
+	public function getIdentifier($object, $identifier = null)
161
+	{
162
+		return ! empty($identifier)
163
+			? $identifier
164
+			: spl_object_hash($object);
165
+	}
166
+
167
+
168
+	/**
169
+	 * setIdentifier
170
+	 * Sets the data associated with an object in the Collection
171
+	 * if no $identifier is supplied, then the spl_object_hash() is used
172
+	 *
173
+	 * @param        $object
174
+	 * @param  mixed $identifier
175
+	 * @return bool
176
+	 */
177
+	public function setIdentifier($object, $identifier = null)
178
+	{
179
+		$identifier = $this->getIdentifier($object, $identifier);
180
+		$this->rewind();
181
+		while ($this->valid()) {
182
+			if ($object === $this->current()) {
183
+				$this->setInfo($identifier);
184
+				$this->rewind();
185
+				return true;
186
+			}
187
+			$this->next();
188
+		}
189
+		return false;
190
+	}
191
+
192
+
193
+	/**
194
+	 * get
195
+	 * finds and returns an object in the Collection based on the identifier that was set using addObject()
196
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
197
+	 *
198
+	 * @param mixed $identifier
199
+	 * @return mixed
200
+	 */
201
+	public function get($identifier)
202
+	{
203
+		$this->rewind();
204
+		while ($this->valid()) {
205
+			if ($identifier === $this->getInfo()) {
206
+				$object = $this->current();
207
+				$this->rewind();
208
+				return $object;
209
+			}
210
+			$this->next();
211
+		}
212
+		return null;
213
+	}
214
+
215
+
216
+	/**
217
+	 * has
218
+	 * returns TRUE or FALSE
219
+	 * depending on whether the object is within the Collection
220
+	 * based on the supplied $identifier
221
+	 *
222
+	 * @param  mixed $identifier
223
+	 * @return bool
224
+	 */
225
+	public function has($identifier)
226
+	{
227
+		$this->rewind();
228
+		while ($this->valid()) {
229
+			if ($identifier === $this->getInfo()) {
230
+				$this->rewind();
231
+				return true;
232
+			}
233
+			$this->next();
234
+		}
235
+		return false;
236
+	}
237
+
238
+
239
+	/**
240
+	 * hasObject
241
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
242
+	 *
243
+	 * @param $object
244
+	 * @return bool
245
+	 */
246
+	public function hasObject($object)
247
+	{
248
+		return $this->contains($object);
249
+	}
250
+
251
+
252
+	/**
253
+	 * hasObjects
254
+	 * returns true if there are objects within the Collection, and false if it is empty
255
+	 *
256
+	 * @return bool
257
+	 */
258
+	public function hasObjects()
259
+	{
260
+		return $this->count() !== 0;
261
+	}
262
+
263
+
264
+	/**
265
+	 * isEmpty
266
+	 * returns true if there are no objects within the Collection, and false if there are
267
+	 *
268
+	 * @return bool
269
+	 */
270
+	public function isEmpty()
271
+	{
272
+		return $this->count() === 0;
273
+	}
274
+
275
+
276
+	/**
277
+	 * remove
278
+	 * detaches an object from the Collection
279
+	 *
280
+	 * @param $object
281
+	 * @return bool
282
+	 */
283
+	public function remove($object)
284
+	{
285
+		$this->detach($object);
286
+		return true;
287
+	}
288
+
289
+
290
+	/**
291
+	 * setCurrent
292
+	 * advances pointer to the object whose identifier matches that which was provided
293
+	 *
294
+	 * @param mixed $identifier
295
+	 * @return boolean
296
+	 */
297
+	public function setCurrent($identifier)
298
+	{
299
+		$this->rewind();
300
+		while ($this->valid()) {
301
+			if ($identifier === $this->getInfo()) {
302
+				return true;
303
+			}
304
+			$this->next();
305
+		}
306
+		return false;
307
+	}
308
+
309
+
310
+	/**
311
+	 * setCurrentUsingObject
312
+	 * advances pointer to the provided object
313
+	 *
314
+	 * @param $object
315
+	 * @return boolean
316
+	 */
317
+	public function setCurrentUsingObject($object)
318
+	{
319
+		$this->rewind();
320
+		while ($this->valid()) {
321
+			if ($this->current() === $object) {
322
+				return true;
323
+			}
324
+			$this->next();
325
+		}
326
+		return false;
327
+	}
328
+
329
+
330
+	/**
331
+	 * Returns the object occupying the index before the current object,
332
+	 * unless this is already the first object, in which case it just returns the first object
333
+	 *
334
+	 * @return mixed
335
+	 */
336
+	public function previous()
337
+	{
338
+		$index = $this->indexOf($this->current());
339
+		if ($index === 0) {
340
+			return $this->current();
341
+		}
342
+		$index--;
343
+		return $this->objectAtIndex($index);
344
+	}
345
+
346
+
347
+	/**
348
+	 * Returns the index of a given object, or false if not found
349
+	 *
350
+	 * @see http://stackoverflow.com/a/8736013
351
+	 * @param $object
352
+	 * @return boolean|int|string
353
+	 */
354
+	public function indexOf($object)
355
+	{
356
+		if (! $this->contains($object)) {
357
+			return false;
358
+		}
359
+		foreach ($this as $index => $obj) {
360
+			if ($obj === $object) {
361
+				return $index;
362
+			}
363
+		}
364
+		return false;
365
+	}
366
+
367
+
368
+	/**
369
+	 * Returns the object at the given index
370
+	 *
371
+	 * @see http://stackoverflow.com/a/8736013
372
+	 * @param int $index
373
+	 * @return mixed
374
+	 */
375
+	public function objectAtIndex($index)
376
+	{
377
+		$iterator = new LimitIterator($this, $index, 1);
378
+		$iterator->rewind();
379
+		return $iterator->current();
380
+	}
381
+
382
+
383
+	/**
384
+	 * Returns the sequence of objects as specified by the offset and length
385
+	 *
386
+	 * @see http://stackoverflow.com/a/8736013
387
+	 * @param int $offset
388
+	 * @param int $length
389
+	 * @return array
390
+	 */
391
+	public function slice($offset, $length)
392
+	{
393
+		$slice = array();
394
+		$iterator = new LimitIterator($this, $offset, $length);
395
+		foreach ($iterator as $object) {
396
+			$slice[] = $object;
397
+		}
398
+		return $slice;
399
+	}
400
+
401
+
402
+	/**
403
+	 * Inserts an object at a certain point
404
+	 *
405
+	 * @see http://stackoverflow.com/a/8736013
406
+	 * @param mixed $object A single object
407
+	 * @param int   $index
408
+	 * @param mixed $identifier
409
+	 * @return bool
410
+	 * @throws DuplicateCollectionIdentifierException
411
+	 * @throws InvalidEntityException
412
+	 */
413
+	public function insertObjectAt($object, $index, $identifier = null)
414
+	{
415
+		// check to ensure that objects don't already exist in the collection
416
+		if ($this->has($identifier)) {
417
+			throw new DuplicateCollectionIdentifierException($identifier);
418
+		}
419
+		// detach any objects at or past this index
420
+		$remaining_objects = array();
421
+		if ($index < $this->count()) {
422
+			$remaining_objects = $this->slice($index, $this->count() - $index);
423
+			foreach ($remaining_objects as $key => $remaining_object) {
424
+				// we need to grab the identifiers for each object and use them as keys
425
+				$remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
426
+				// and then remove the object from the current tracking array
427
+				unset($remaining_objects[ $key ]);
428
+				// and then remove it from the Collection
429
+				$this->detach($remaining_object);
430
+			}
431
+		}
432
+		// add the new object we're splicing in
433
+		$this->add($object, $identifier);
434
+		// attach the objects we previously detached
435
+		foreach ($remaining_objects as $key => $remaining_object) {
436
+			$this->add($remaining_object, $key);
437
+		}
438
+		return $this->contains($object);
439
+	}
440
+
441
+
442
+	/**
443
+	 * Inserts an object (or an array of objects) at a certain point
444
+	 *
445
+	 * @see http://stackoverflow.com/a/8736013
446
+	 * @param mixed $objects A single object or an array of objects
447
+	 * @param int   $index
448
+	 */
449
+	public function insertAt($objects, $index)
450
+	{
451
+		if (! is_array($objects)) {
452
+			$objects = array($objects);
453
+		}
454
+		// check to ensure that objects don't already exist in the collection
455
+		foreach ($objects as $key => $object) {
456
+			if ($this->contains($object)) {
457
+				unset($objects[ $key ]);
458
+			}
459
+		}
460
+		// do we have any objects left?
461
+		if (! $objects) {
462
+			return;
463
+		}
464
+		// detach any objects at or past this index
465
+		$remaining = array();
466
+		if ($index < $this->count()) {
467
+			$remaining = $this->slice($index, $this->count() - $index);
468
+			foreach ($remaining as $object) {
469
+				$this->detach($object);
470
+			}
471
+		}
472
+		// add the new objects we're splicing in
473
+		foreach ($objects as $object) {
474
+			$this->attach($object);
475
+		}
476
+		// attach the objects we previously detached
477
+		foreach ($remaining as $object) {
478
+			$this->attach($object);
479
+		}
480
+	}
481
+
482
+
483
+	/**
484
+	 * Removes the object at the given index
485
+	 *
486
+	 * @see http://stackoverflow.com/a/8736013
487
+	 * @param int $index
488
+	 */
489
+	public function removeAt($index)
490
+	{
491
+		$this->detach($this->objectAtIndex($index));
492
+	}
493
+
494
+
495
+	/**
496
+	 * detaches ALL objects from the Collection
497
+	 */
498
+	public function detachAll()
499
+	{
500
+		$this->rewind();
501
+		while ($this->valid()) {
502
+			$object = $this->current();
503
+			$this->next();
504
+			$this->detach($object);
505
+		}
506
+	}
507
+
508
+
509
+	/**
510
+	 * unsets and detaches ALL objects from the Collection
511
+	 */
512
+	public function trashAndDetachAll()
513
+	{
514
+		$this->rewind();
515
+		while ($this->valid()) {
516
+			$object = $this->current();
517
+			$this->next();
518
+			$this->detach($object);
519
+			unset($object);
520
+		}
521
+	}
522 522
 }
Please login to merge, or discard this patch.
core/services/collections/CollectionLoader.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@
 block discarded – undo
175 175
 
176 176
     /**
177 177
      * @param        $entity
178
-     * @param  mixed $identifier
178
+     * @param  string $identifier
179 179
      * @return string
180 180
      * @throws InvalidEntityException
181 181
      * @throws DuplicateCollectionIdentifierException
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -29,295 +29,295 @@
 block discarded – undo
29 29
 class CollectionLoader
30 30
 {
31 31
 
32
-    /**
33
-     * possible return value when adding entities to a collection.
34
-     * denotes that the entity was NOT ADDED to the collection
35
-     */
36
-    const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
32
+	/**
33
+	 * possible return value when adding entities to a collection.
34
+	 * denotes that the entity was NOT ADDED to the collection
35
+	 */
36
+	const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
37 37
 
38
-    /**
39
-     * possible return value when adding entities to a collection.
40
-     * denotes that the entity was SUCCESSFULLY ADDED to the collection
41
-     */
42
-    const ENTITY_ADDED = 'entity-added-to-collection';
38
+	/**
39
+	 * possible return value when adding entities to a collection.
40
+	 * denotes that the entity was SUCCESSFULLY ADDED to the collection
41
+	 */
42
+	const ENTITY_ADDED = 'entity-added-to-collection';
43 43
 
44
-    /**
45
-     * possible return value when adding entities to a collection.
46
-     * denotes that the entity was ALREADY ADDED to the collection,
47
-     * and therefore could not be added again.
48
-     */
49
-    const ENTITY_EXISTS = 'entity-already-in-collection';
44
+	/**
45
+	 * possible return value when adding entities to a collection.
46
+	 * denotes that the entity was ALREADY ADDED to the collection,
47
+	 * and therefore could not be added again.
48
+	 */
49
+	const ENTITY_EXISTS = 'entity-already-in-collection';
50 50
 
51 51
 
52
-    /**
53
-     * @var CollectionDetailsInterface $collection_details
54
-     */
55
-    protected $collection_details;
52
+	/**
53
+	 * @var CollectionDetailsInterface $collection_details
54
+	 */
55
+	protected $collection_details;
56 56
 
57
-    /**
58
-     * @var CollectionInterface $collection
59
-     */
60
-    protected $collection;
57
+	/**
58
+	 * @var CollectionInterface $collection
59
+	 */
60
+	protected $collection;
61 61
 
62
-    /**
63
-     * @var FactoryInterface $entity_factory
64
-     */
65
-    protected $entity_factory;
62
+	/**
63
+	 * @var FactoryInterface $entity_factory
64
+	 */
65
+	protected $entity_factory;
66 66
 
67
-    /**
68
-     * @var FileLocator $file_locator
69
-     */
70
-    protected $file_locator;
67
+	/**
68
+	 * @var FileLocator $file_locator
69
+	 */
70
+	protected $file_locator;
71 71
 
72 72
 
73
-    /**
74
-     * CollectionLoader constructor.
75
-     *
76
-     * @param CollectionDetailsInterface $collection_details
77
-     * @param CollectionInterface        $collection
78
-     * @param LocatorInterface           $file_locator
79
-     * @param FactoryInterface|null      $entity_factory
80
-     * @throws CollectionLoaderException
81
-     */
82
-    public function __construct(
83
-        CollectionDetailsInterface $collection_details,
84
-        CollectionInterface $collection = null,
85
-        LocatorInterface $file_locator = null,
86
-        FactoryInterface $entity_factory = null
87
-    ) {
88
-        try {
89
-            $this->collection_details = $collection_details;
90
-            if (! $collection instanceof CollectionInterface) {
91
-                $collection = new Collection($this->collection_details->getCollectionInterface());
92
-            }
93
-            $this->collection = $collection;
94
-            $this->file_locator = $file_locator;
95
-            $this->entity_factory = $entity_factory;
96
-            $this->loadAllFromFilepaths();
97
-            $this->loadFromFQCNs();
98
-        } catch (Exception $exception) {
99
-            throw new CollectionLoaderException($exception);
100
-        }
101
-    }
73
+	/**
74
+	 * CollectionLoader constructor.
75
+	 *
76
+	 * @param CollectionDetailsInterface $collection_details
77
+	 * @param CollectionInterface        $collection
78
+	 * @param LocatorInterface           $file_locator
79
+	 * @param FactoryInterface|null      $entity_factory
80
+	 * @throws CollectionLoaderException
81
+	 */
82
+	public function __construct(
83
+		CollectionDetailsInterface $collection_details,
84
+		CollectionInterface $collection = null,
85
+		LocatorInterface $file_locator = null,
86
+		FactoryInterface $entity_factory = null
87
+	) {
88
+		try {
89
+			$this->collection_details = $collection_details;
90
+			if (! $collection instanceof CollectionInterface) {
91
+				$collection = new Collection($this->collection_details->getCollectionInterface());
92
+			}
93
+			$this->collection = $collection;
94
+			$this->file_locator = $file_locator;
95
+			$this->entity_factory = $entity_factory;
96
+			$this->loadAllFromFilepaths();
97
+			$this->loadFromFQCNs();
98
+		} catch (Exception $exception) {
99
+			throw new CollectionLoaderException($exception);
100
+		}
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * @return CollectionInterface
106
-     */
107
-    public function getCollection()
108
-    {
109
-        return $this->collection;
110
-    }
104
+	/**
105
+	 * @return CollectionInterface
106
+	 */
107
+	public function getCollection()
108
+	{
109
+		return $this->collection;
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws InvalidClassException
115
-     * @throws InvalidFilePathException
116
-     * @throws InvalidDataTypeException
117
-     * @throws InvalidEntityException
118
-     * @throws DuplicateCollectionIdentifierException
119
-     */
120
-    protected function loadAllFromFilepaths()
121
-    {
122
-        if (! $this->file_locator instanceof FileLocator) {
123
-            $this->file_locator = new FileLocator();
124
-        }
125
-        $this->file_locator->setFileMask($this->collection_details->getFileMask());
126
-        // find all of the files that match the file mask in the specified folder
127
-        $this->file_locator->locate($this->collection_details->getCollectionPaths());
128
-        // filter the results
129
-        $filepaths = (array) apply_filters(
130
-            'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
131
-            $this->file_locator->getFilePaths(),
132
-            $this->collection_details->collectionName(),
133
-            $this->collection_details
134
-        );
135
-        if (empty($filepaths)) {
136
-            return;
137
-        }
138
-        foreach ($filepaths as $filepath) {
139
-            $this->loadClassFromFilepath($filepath);
140
-        }
141
-    }
113
+	/**
114
+	 * @throws InvalidClassException
115
+	 * @throws InvalidFilePathException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws InvalidEntityException
118
+	 * @throws DuplicateCollectionIdentifierException
119
+	 */
120
+	protected function loadAllFromFilepaths()
121
+	{
122
+		if (! $this->file_locator instanceof FileLocator) {
123
+			$this->file_locator = new FileLocator();
124
+		}
125
+		$this->file_locator->setFileMask($this->collection_details->getFileMask());
126
+		// find all of the files that match the file mask in the specified folder
127
+		$this->file_locator->locate($this->collection_details->getCollectionPaths());
128
+		// filter the results
129
+		$filepaths = (array) apply_filters(
130
+			'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
131
+			$this->file_locator->getFilePaths(),
132
+			$this->collection_details->collectionName(),
133
+			$this->collection_details
134
+		);
135
+		if (empty($filepaths)) {
136
+			return;
137
+		}
138
+		foreach ($filepaths as $filepath) {
139
+			$this->loadClassFromFilepath($filepath);
140
+		}
141
+	}
142 142
 
143 143
 
144
-    /**
145
-     * @param  string $filepath
146
-     * @return string
147
-     * @throws InvalidEntityException
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidFilePathException
150
-     * @throws InvalidClassException
151
-     * @throws DuplicateCollectionIdentifierException
152
-     */
153
-    protected function loadClassFromFilepath($filepath)
154
-    {
155
-        if (! is_string($filepath)) {
156
-            throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157
-        }
158
-        if (! is_readable($filepath)) {
159
-            throw new InvalidFilePathException($filepath);
160
-        }
161
-        require_once $filepath;
162
-        // extract filename from path
163
-        $file_name = basename($filepath);
164
-        // now remove any file extensions
165
-        $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
-        if (! class_exists($class_name)) {
167
-            throw new InvalidClassException($class_name);
168
-        }
169
-        $entity = $this->entity_factory instanceof FactoryInterface
170
-            ? call_user_func(array($this->entity_factory, 'create'), $class_name)
171
-            : new $class_name();
172
-        return $this->addEntityToCollection($entity, $file_name);
173
-    }
144
+	/**
145
+	 * @param  string $filepath
146
+	 * @return string
147
+	 * @throws InvalidEntityException
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidFilePathException
150
+	 * @throws InvalidClassException
151
+	 * @throws DuplicateCollectionIdentifierException
152
+	 */
153
+	protected function loadClassFromFilepath($filepath)
154
+	{
155
+		if (! is_string($filepath)) {
156
+			throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157
+		}
158
+		if (! is_readable($filepath)) {
159
+			throw new InvalidFilePathException($filepath);
160
+		}
161
+		require_once $filepath;
162
+		// extract filename from path
163
+		$file_name = basename($filepath);
164
+		// now remove any file extensions
165
+		$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
+		if (! class_exists($class_name)) {
167
+			throw new InvalidClassException($class_name);
168
+		}
169
+		$entity = $this->entity_factory instanceof FactoryInterface
170
+			? call_user_func(array($this->entity_factory, 'create'), $class_name)
171
+			: new $class_name();
172
+		return $this->addEntityToCollection($entity, $file_name);
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * @param        $entity
178
-     * @param  mixed $identifier
179
-     * @return string
180
-     * @throws InvalidEntityException
181
-     * @throws DuplicateCollectionIdentifierException
182
-     */
183
-    protected function addEntityToCollection($entity, $identifier)
184
-    {
185
-        do_action(
186
-            'FHEE__CollectionLoader__addEntityToCollection__entity',
187
-            $entity,
188
-            $this->collection_details->collectionName(),
189
-            $this->collection_details
190
-        );
191
-        $identifier = $this->setIdentifier($entity, $identifier);
192
-        if ($this->collection->has($identifier)) {
193
-            do_action(
194
-                'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
195
-                $this,
196
-                $this->collection_details->collectionName(),
197
-                $this->collection_details
198
-            );
199
-            return CollectionLoader::ENTITY_EXISTS;
200
-        }
201
-        if ($this->collection->add($entity, $identifier)) {
202
-            do_action(
203
-                'FHEE__CollectionLoader__addEntityToCollection__entity_added',
204
-                $this,
205
-                $this->collection_details->collectionName(),
206
-                $this->collection_details
207
-            );
208
-            return CollectionLoader::ENTITY_ADDED;
209
-        }
210
-        do_action(
211
-            'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
212
-            $this,
213
-            $this->collection_details->collectionName(),
214
-            $this->collection_details
215
-        );
216
-        return CollectionLoader::ENTITY_NOT_ADDED;
217
-    }
176
+	/**
177
+	 * @param        $entity
178
+	 * @param  mixed $identifier
179
+	 * @return string
180
+	 * @throws InvalidEntityException
181
+	 * @throws DuplicateCollectionIdentifierException
182
+	 */
183
+	protected function addEntityToCollection($entity, $identifier)
184
+	{
185
+		do_action(
186
+			'FHEE__CollectionLoader__addEntityToCollection__entity',
187
+			$entity,
188
+			$this->collection_details->collectionName(),
189
+			$this->collection_details
190
+		);
191
+		$identifier = $this->setIdentifier($entity, $identifier);
192
+		if ($this->collection->has($identifier)) {
193
+			do_action(
194
+				'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
195
+				$this,
196
+				$this->collection_details->collectionName(),
197
+				$this->collection_details
198
+			);
199
+			return CollectionLoader::ENTITY_EXISTS;
200
+		}
201
+		if ($this->collection->add($entity, $identifier)) {
202
+			do_action(
203
+				'FHEE__CollectionLoader__addEntityToCollection__entity_added',
204
+				$this,
205
+				$this->collection_details->collectionName(),
206
+				$this->collection_details
207
+			);
208
+			return CollectionLoader::ENTITY_ADDED;
209
+		}
210
+		do_action(
211
+			'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
212
+			$this,
213
+			$this->collection_details->collectionName(),
214
+			$this->collection_details
215
+		);
216
+		return CollectionLoader::ENTITY_NOT_ADDED;
217
+	}
218 218
 
219 219
 
220
-    /**
221
-     * @param        $entity
222
-     * @param  mixed $identifier
223
-     * @return string
224
-     * @throws InvalidEntityException
225
-     */
226
-    protected function setIdentifier($entity, $identifier)
227
-    {
228
-        switch ($this->collection_details->identifierType()) {
229
-            // every unique object gets added to the collection, but not duplicates of the exact same object
230
-            case CollectionDetails::ID_OBJECT_HASH:
231
-                $identifier = spl_object_hash($entity);
232
-                break;
233
-            // only one entity per class can be added to collection, like a singleton
234
-            case CollectionDetails::ID_CLASS_NAME:
235
-                $identifier = get_class($entity);
236
-                break;
237
-            // objects added to the collection based on entity callback, so the entity itself decides
238
-            case CollectionDetails::ID_CALLBACK_METHOD:
239
-                $identifier_callback = $this->collection_details->identifierCallback();
240
-                if (! method_exists($entity, $identifier_callback)) {
241
-                    throw new InvalidEntityException(
242
-                        $entity,
243
-                        $this->collection_details->getCollectionInterface(),
244
-                        sprintf(
245
-                            __(
246
-                                'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
220
+	/**
221
+	 * @param        $entity
222
+	 * @param  mixed $identifier
223
+	 * @return string
224
+	 * @throws InvalidEntityException
225
+	 */
226
+	protected function setIdentifier($entity, $identifier)
227
+	{
228
+		switch ($this->collection_details->identifierType()) {
229
+			// every unique object gets added to the collection, but not duplicates of the exact same object
230
+			case CollectionDetails::ID_OBJECT_HASH:
231
+				$identifier = spl_object_hash($entity);
232
+				break;
233
+			// only one entity per class can be added to collection, like a singleton
234
+			case CollectionDetails::ID_CLASS_NAME:
235
+				$identifier = get_class($entity);
236
+				break;
237
+			// objects added to the collection based on entity callback, so the entity itself decides
238
+			case CollectionDetails::ID_CALLBACK_METHOD:
239
+				$identifier_callback = $this->collection_details->identifierCallback();
240
+				if (! method_exists($entity, $identifier_callback)) {
241
+					throw new InvalidEntityException(
242
+						$entity,
243
+						$this->collection_details->getCollectionInterface(),
244
+						sprintf(
245
+							__(
246
+								'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
247 247
                                 of "%2$s", but does not contain this method.',
248
-                                'event_espresso'
249
-                            ),
250
-                            $identifier_callback,
251
-                            get_class($entity)
252
-                        )
253
-                    );
254
-                }
255
-                $identifier = $entity->{$identifier_callback}();
256
-                break;
257
-        }
258
-        return apply_filters(
259
-            'FHEE__CollectionLoader__addEntityToCollection__identifier',
260
-            $identifier,
261
-            $this->collection_details->collectionName(),
262
-            $this->collection_details
263
-        );
264
-    }
248
+								'event_espresso'
249
+							),
250
+							$identifier_callback,
251
+							get_class($entity)
252
+						)
253
+					);
254
+				}
255
+				$identifier = $entity->{$identifier_callback}();
256
+				break;
257
+		}
258
+		return apply_filters(
259
+			'FHEE__CollectionLoader__addEntityToCollection__identifier',
260
+			$identifier,
261
+			$this->collection_details->collectionName(),
262
+			$this->collection_details
263
+		);
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * @throws ReflectionException
269
-     * @throws InvalidArgumentException
270
-     * @throws InvalidInterfaceException
271
-     * @throws EE_Error
272
-     * @throws InvalidClassException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidEntityException
275
-     * @throws DuplicateCollectionIdentifierException
276
-     */
277
-    protected function loadFromFQCNs()
278
-    {
279
-        $FQCNs = $this->collection_details->getCollectionFQCNs();
280
-        $FQCNs = (array) apply_filters(
281
-            'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
282
-            $FQCNs,
283
-            $this->collection_details->collectionName(),
284
-            $this->collection_details
285
-        );
286
-        foreach ($FQCNs as $FQCN) {
287
-            $this->loadClassFromFQCN($FQCN);
288
-        }
289
-    }
267
+	/**
268
+	 * @throws ReflectionException
269
+	 * @throws InvalidArgumentException
270
+	 * @throws InvalidInterfaceException
271
+	 * @throws EE_Error
272
+	 * @throws InvalidClassException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidEntityException
275
+	 * @throws DuplicateCollectionIdentifierException
276
+	 */
277
+	protected function loadFromFQCNs()
278
+	{
279
+		$FQCNs = $this->collection_details->getCollectionFQCNs();
280
+		$FQCNs = (array) apply_filters(
281
+			'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
282
+			$FQCNs,
283
+			$this->collection_details->collectionName(),
284
+			$this->collection_details
285
+		);
286
+		foreach ($FQCNs as $FQCN) {
287
+			$this->loadClassFromFQCN($FQCN);
288
+		}
289
+	}
290 290
 
291 291
 
292
-    /**
293
-     * @param  string $FQCN Fully Qualified Class Name
294
-     * @return string
295
-     * @throws InvalidArgumentException
296
-     * @throws InvalidInterfaceException
297
-     * @throws ReflectionException
298
-     * @throws EE_Error
299
-     * @throws InvalidEntityException
300
-     * @throws InvalidDataTypeException
301
-     * @throws InvalidClassException
302
-     * @throws DuplicateCollectionIdentifierException
303
-     */
304
-    protected function loadClassFromFQCN($FQCN)
305
-    {
306
-        if (! is_string($FQCN)) {
307
-            throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308
-        }
309
-        if (! class_exists($FQCN)) {
310
-            throw new InvalidClassException($FQCN);
311
-        }
312
-        do_action(
313
-            'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
314
-            $FQCN,
315
-            $this->collection_details->collectionName(),
316
-            $this->collection_details
317
-        );
318
-        $entity = $this->entity_factory instanceof FactoryInterface
319
-            ? call_user_func(array($this->entity_factory, 'create'), $FQCN)
320
-            : EE_Registry::instance()->create($FQCN);
321
-        return $this->addEntityToCollection($entity, $FQCN);
322
-    }
292
+	/**
293
+	 * @param  string $FQCN Fully Qualified Class Name
294
+	 * @return string
295
+	 * @throws InvalidArgumentException
296
+	 * @throws InvalidInterfaceException
297
+	 * @throws ReflectionException
298
+	 * @throws EE_Error
299
+	 * @throws InvalidEntityException
300
+	 * @throws InvalidDataTypeException
301
+	 * @throws InvalidClassException
302
+	 * @throws DuplicateCollectionIdentifierException
303
+	 */
304
+	protected function loadClassFromFQCN($FQCN)
305
+	{
306
+		if (! is_string($FQCN)) {
307
+			throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308
+		}
309
+		if (! class_exists($FQCN)) {
310
+			throw new InvalidClassException($FQCN);
311
+		}
312
+		do_action(
313
+			'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
314
+			$FQCN,
315
+			$this->collection_details->collectionName(),
316
+			$this->collection_details
317
+		);
318
+		$entity = $this->entity_factory instanceof FactoryInterface
319
+			? call_user_func(array($this->entity_factory, 'create'), $FQCN)
320
+			: EE_Registry::instance()->create($FQCN);
321
+		return $this->addEntityToCollection($entity, $FQCN);
322
+	}
323 323
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     ) {
88 88
         try {
89 89
             $this->collection_details = $collection_details;
90
-            if (! $collection instanceof CollectionInterface) {
90
+            if ( ! $collection instanceof CollectionInterface) {
91 91
                 $collection = new Collection($this->collection_details->getCollectionInterface());
92 92
             }
93 93
             $this->collection = $collection;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function loadAllFromFilepaths()
121 121
     {
122
-        if (! $this->file_locator instanceof FileLocator) {
122
+        if ( ! $this->file_locator instanceof FileLocator) {
123 123
             $this->file_locator = new FileLocator();
124 124
         }
125 125
         $this->file_locator->setFileMask($this->collection_details->getFileMask());
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      */
153 153
     protected function loadClassFromFilepath($filepath)
154 154
     {
155
-        if (! is_string($filepath)) {
155
+        if ( ! is_string($filepath)) {
156 156
             throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157 157
         }
158
-        if (! is_readable($filepath)) {
158
+        if ( ! is_readable($filepath)) {
159 159
             throw new InvalidFilePathException($filepath);
160 160
         }
161 161
         require_once $filepath;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $file_name = basename($filepath);
164 164
         // now remove any file extensions
165 165
         $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
-        if (! class_exists($class_name)) {
166
+        if ( ! class_exists($class_name)) {
167 167
             throw new InvalidClassException($class_name);
168 168
         }
169 169
         $entity = $this->entity_factory instanceof FactoryInterface
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             // objects added to the collection based on entity callback, so the entity itself decides
238 238
             case CollectionDetails::ID_CALLBACK_METHOD:
239 239
                 $identifier_callback = $this->collection_details->identifierCallback();
240
-                if (! method_exists($entity, $identifier_callback)) {
240
+                if ( ! method_exists($entity, $identifier_callback)) {
241 241
                     throw new InvalidEntityException(
242 242
                         $entity,
243 243
                         $this->collection_details->getCollectionInterface(),
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     protected function loadClassFromFQCN($FQCN)
305 305
     {
306
-        if (! is_string($FQCN)) {
306
+        if ( ! is_string($FQCN)) {
307 307
             throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308 308
         }
309
-        if (! class_exists($FQCN)) {
309
+        if ( ! class_exists($FQCN)) {
310 310
             throw new InvalidClassException($FQCN);
311 311
         }
312 312
         do_action(
Please login to merge, or discard this patch.
core/domain/entities/editor/BlockInterface.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -22,70 +22,70 @@
 block discarded – undo
22 22
 interface BlockInterface
23 23
 {
24 24
 
25
-    const NAME_SPACE = 'eventespresso';
26
-
27
-    /**
28
-     * Perform any early setup required by the block
29
-     * including setting the block type and supported post types
30
-     *
31
-     * @return void
32
-     */
33
-    public function initialize();
34
-
35
-
36
-    /**
37
-     * @return string
38
-     */
39
-    public function blockType();
40
-
41
-
42
-    /**
43
-     * AssetRegister that this editor block uses for asset registration
44
-     *
45
-     * @return BlockAssetManagerInterface
46
-     */
47
-    public function assetManager();
48
-
49
-
50
-    /**
51
-     * Registers the Editor Block with WP core;
52
-     * Returns the registered block type on success, or false on failure.
53
-     *
54
-     * @return WP_Block_Type|false
55
-     */
56
-    public function registerBlock();
57
-
58
-
59
-    /**
60
-     * Un-registers the Editor Block with WP core;
61
-     * Returns the registered block type on success, or false on failure.
62
-     *
63
-     * @return WP_Block_Type|false
64
-     */
65
-    public function unRegisterBlock();
66
-
67
-
68
-    /**
69
-     * returns an array of fully qualified class names
70
-     * for RouteMatchSpecificationInterface objects
71
-     * that specify routes that the block should be loaded for.
72
-     *
73
-     * @return array
74
-     */
75
-    public function supportedRoutes();
76
-
77
-
78
-    /**
79
-     * @return array
80
-     */
81
-    public function getEditorContainer();
82
-
83
-
84
-    /**
85
-     * returns the rendered HTML for the block
86
-     *
87
-     * @param array $attributes
88
-     * @return string
89
-     */
90
-    public function renderBlock(array $attributes = array());
25
+	const NAME_SPACE = 'eventespresso';
26
+
27
+	/**
28
+	 * Perform any early setup required by the block
29
+	 * including setting the block type and supported post types
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function initialize();
34
+
35
+
36
+	/**
37
+	 * @return string
38
+	 */
39
+	public function blockType();
40
+
41
+
42
+	/**
43
+	 * AssetRegister that this editor block uses for asset registration
44
+	 *
45
+	 * @return BlockAssetManagerInterface
46
+	 */
47
+	public function assetManager();
48
+
49
+
50
+	/**
51
+	 * Registers the Editor Block with WP core;
52
+	 * Returns the registered block type on success, or false on failure.
53
+	 *
54
+	 * @return WP_Block_Type|false
55
+	 */
56
+	public function registerBlock();
57
+
58
+
59
+	/**
60
+	 * Un-registers the Editor Block with WP core;
61
+	 * Returns the registered block type on success, or false on failure.
62
+	 *
63
+	 * @return WP_Block_Type|false
64
+	 */
65
+	public function unRegisterBlock();
66
+
67
+
68
+	/**
69
+	 * returns an array of fully qualified class names
70
+	 * for RouteMatchSpecificationInterface objects
71
+	 * that specify routes that the block should be loaded for.
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public function supportedRoutes();
76
+
77
+
78
+	/**
79
+	 * @return array
80
+	 */
81
+	public function getEditorContainer();
82
+
83
+
84
+	/**
85
+	 * returns the rendered HTML for the block
86
+	 *
87
+	 * @param array $attributes
88
+	 * @return string
89
+	 */
90
+	public function renderBlock(array $attributes = array());
91 91
 }
Please login to merge, or discard this patch.
core/domain/entities/route_match/RouteMatchSpecification.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,17 +24,17 @@
 block discarded – undo
24 24
 abstract class RouteMatchSpecification implements RouteMatchSpecificationInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var RequestInterface $request
29
-     */
30
-    protected $request;
27
+	/**
28
+	 * @var RequestInterface $request
29
+	 */
30
+	protected $request;
31 31
 
32
-    /**
33
-     * RouteMatch constructor.
34
-     * @param RequestInterface $request
35
-     */
36
-    public function __construct(RequestInterface $request)
37
-    {
38
-        $this->request = $request;
39
-    }
32
+	/**
33
+	 * RouteMatch constructor.
34
+	 * @param RequestInterface $request
35
+	 */
36
+	public function __construct(RequestInterface $request)
37
+	{
38
+		$this->request = $request;
39
+	}
40 40
 }
Please login to merge, or discard this patch.
core/domain/entities/route_match/RouteMatchSpecificationDecorator.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@
 block discarded – undo
13 13
 abstract class RouteMatchSpecificationDecorator implements RouteMatchSpecificationInterface
14 14
 {
15 15
 
16
-    /**
17
-     * @var RouteMatchSpecificationInterface $specification
18
-     */
19
-    protected $specification;
16
+	/**
17
+	 * @var RouteMatchSpecificationInterface $specification
18
+	 */
19
+	protected $specification;
20 20
 
21
-    /**
22
-     * RouteMatchSpecificationDecorator constructor.
23
-     *
24
-     * @param RouteMatchSpecificationInterface $specification
25
-     */
26
-    public function __construct(RouteMatchSpecificationInterface $specification)
27
-    {
28
-        $this->specification = $specification;
29
-    }
21
+	/**
22
+	 * RouteMatchSpecificationDecorator constructor.
23
+	 *
24
+	 * @param RouteMatchSpecificationInterface $specification
25
+	 */
26
+	public function __construct(RouteMatchSpecificationInterface $specification)
27
+	{
28
+		$this->specification = $specification;
29
+	}
30 30
 }
Please login to merge, or discard this patch.