Completed
Branch master (d00746)
by
unknown
17:16 queued 15:05
created
core/EE_Error.core.php 2 patches
Indentation   +1127 added lines, -1127 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 // if you're a dev and want to receive all errors via email
12 12
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
13 13
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
14
-    set_error_handler(array('EE_Error', 'error_handler'));
15
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
14
+	set_error_handler(array('EE_Error', 'error_handler'));
15
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
16 16
 }
17 17
 
18 18
 
@@ -26,251 +26,251 @@  discard block
 block discarded – undo
26 26
 class EE_Error extends Exception
27 27
 {
28 28
 
29
-    const OPTIONS_KEY_NOTICES = 'ee_notices';
30
-
31
-
32
-    /**
33
-     * name of the file to log exceptions to
34
-     *
35
-     * @var string
36
-     */
37
-    private static $_exception_log_file = 'espresso_error_log.txt';
38
-
39
-    /**
40
-     *    stores details for all exception
41
-     *
42
-     * @var array
43
-     */
44
-    private static $_all_exceptions = array();
45
-
46
-    /**
47
-     *    tracks number of errors
48
-     *
49
-     * @var int
50
-     */
51
-    private static $_error_count = 0;
52
-
53
-    /**
54
-     * @var array $_espresso_notices
55
-     */
56
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
57
-
58
-
59
-    /**
60
-     * @override default exception handling
61
-     * @param string         $message
62
-     * @param int            $code
63
-     * @param Exception|null $previous
64
-     */
65
-    public function __construct($message, $code = 0, Exception $previous = null)
66
-    {
67
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
68
-            parent::__construct($message, $code);
69
-        } else {
70
-            parent::__construct($message, $code, $previous);
71
-        }
72
-    }
73
-
74
-
75
-    /**
76
-     *    error_handler
77
-     *
78
-     * @param $code
79
-     * @param $message
80
-     * @param $file
81
-     * @param $line
82
-     * @return void
83
-     */
84
-    public static function error_handler($code, $message, $file, $line)
85
-    {
86
-        $type = EE_Error::error_type($code);
87
-        $site = site_url();
88
-        switch ($site) {
89
-            case 'http://ee4.eventespresso.com/':
90
-            case 'http://ee4decaf.eventespresso.com/':
91
-            case 'http://ee4hf.eventespresso.com/':
92
-            case 'http://ee4a.eventespresso.com/':
93
-            case 'http://ee4ad.eventespresso.com/':
94
-            case 'http://ee4b.eventespresso.com/':
95
-            case 'http://ee4bd.eventespresso.com/':
96
-            case 'http://ee4d.eventespresso.com/':
97
-            case 'http://ee4dd.eventespresso.com/':
98
-                $to = '[email protected]';
99
-                break;
100
-            default:
101
-                $to = get_option('admin_email');
102
-        }
103
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
104
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
105
-        if (function_exists('wp_mail')) {
106
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107
-            wp_mail($to, $subject, $msg);
108
-        }
109
-        echo '<div id="message" class="espresso-notices error"><p>';
110
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
111
-        echo '<br /></p></div>';
112
-    }
113
-
114
-
115
-    /**
116
-     * error_type
117
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
118
-     *
119
-     * @param $code
120
-     * @return string
121
-     */
122
-    public static function error_type($code)
123
-    {
124
-        switch ($code) {
125
-            case E_ERROR: // 1 //
126
-                return 'E_ERROR';
127
-            case E_WARNING: // 2 //
128
-                return 'E_WARNING';
129
-            case E_PARSE: // 4 //
130
-                return 'E_PARSE';
131
-            case E_NOTICE: // 8 //
132
-                return 'E_NOTICE';
133
-            case E_CORE_ERROR: // 16 //
134
-                return 'E_CORE_ERROR';
135
-            case E_CORE_WARNING: // 32 //
136
-                return 'E_CORE_WARNING';
137
-            case E_COMPILE_ERROR: // 64 //
138
-                return 'E_COMPILE_ERROR';
139
-            case E_COMPILE_WARNING: // 128 //
140
-                return 'E_COMPILE_WARNING';
141
-            case E_USER_ERROR: // 256 //
142
-                return 'E_USER_ERROR';
143
-            case E_USER_WARNING: // 512 //
144
-                return 'E_USER_WARNING';
145
-            case E_USER_NOTICE: // 1024 //
146
-                return 'E_USER_NOTICE';
147
-            case E_STRICT: // 2048 //
148
-                return 'E_STRICT';
149
-            case E_RECOVERABLE_ERROR: // 4096 //
150
-                return 'E_RECOVERABLE_ERROR';
151
-            case E_DEPRECATED: // 8192 //
152
-                return 'E_DEPRECATED';
153
-            case E_USER_DEPRECATED: // 16384 //
154
-                return 'E_USER_DEPRECATED';
155
-            case E_ALL: // 16384 //
156
-                return 'E_ALL';
157
-        }
158
-        return '';
159
-    }
160
-
161
-
162
-    /**
163
-     *    fatal_error_handler
164
-     *
165
-     * @return void
166
-     */
167
-    public static function fatal_error_handler()
168
-    {
169
-        $last_error = error_get_last();
170
-        if ($last_error['type'] === E_ERROR) {
171
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * _format_error
178
-     *
179
-     * @param $code
180
-     * @param $message
181
-     * @param $file
182
-     * @param $line
183
-     * @return string
184
-     */
185
-    private static function _format_error($code, $message, $file, $line)
186
-    {
187
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
188
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
189
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
190
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
191
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
192
-        $html .= '</tbody></table>';
193
-        return $html;
194
-    }
195
-
196
-
197
-    /**
198
-     * set_content_type
199
-     *
200
-     * @param $content_type
201
-     * @return string
202
-     */
203
-    public static function set_content_type($content_type)
204
-    {
205
-        return 'text/html';
206
-    }
207
-
208
-
209
-    /**
210
-     * @return void
211
-     * @throws EE_Error
212
-     * @throws ReflectionException
213
-     */
214
-    public function get_error()
215
-    {
216
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
217
-            throw $this;
218
-        }
219
-        // get separate user and developer messages if they exist
220
-        $msg = explode('||', $this->getMessage());
221
-        $user_msg = $msg[0];
222
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
223
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
224
-        // add details to _all_exceptions array
225
-        $x_time = time();
226
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
233
-        self::$_error_count++;
234
-        // add_action( 'shutdown', array( $this, 'display_errors' ));
235
-        $this->display_errors();
236
-    }
237
-
238
-
239
-    /**
240
-     * @param bool   $check_stored
241
-     * @param string $type_to_check
242
-     * @return bool
243
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
244
-     * @throws \InvalidArgumentException
245
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
246
-     * @throws InvalidInterfaceException
247
-     */
248
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
249
-    {
250
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
252
-            ? true
253
-            : false;
254
-        if ($check_stored && ! $has_error) {
255
-            $notices = EE_Error::getStoredNotices();
256
-            foreach ($notices as $type => $notice) {
257
-                if ($type === $type_to_check && $notice) {
258
-                    return true;
259
-                }
260
-            }
261
-        }
262
-        return $has_error;
263
-    }
264
-
265
-
266
-    /**
267
-     * @echo string
268
-     * @throws \ReflectionException
269
-     */
270
-    public function display_errors()
271
-    {
272
-        $trace_details = '';
273
-        $output = '
29
+	const OPTIONS_KEY_NOTICES = 'ee_notices';
30
+
31
+
32
+	/**
33
+	 * name of the file to log exceptions to
34
+	 *
35
+	 * @var string
36
+	 */
37
+	private static $_exception_log_file = 'espresso_error_log.txt';
38
+
39
+	/**
40
+	 *    stores details for all exception
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private static $_all_exceptions = array();
45
+
46
+	/**
47
+	 *    tracks number of errors
48
+	 *
49
+	 * @var int
50
+	 */
51
+	private static $_error_count = 0;
52
+
53
+	/**
54
+	 * @var array $_espresso_notices
55
+	 */
56
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
57
+
58
+
59
+	/**
60
+	 * @override default exception handling
61
+	 * @param string         $message
62
+	 * @param int            $code
63
+	 * @param Exception|null $previous
64
+	 */
65
+	public function __construct($message, $code = 0, Exception $previous = null)
66
+	{
67
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
68
+			parent::__construct($message, $code);
69
+		} else {
70
+			parent::__construct($message, $code, $previous);
71
+		}
72
+	}
73
+
74
+
75
+	/**
76
+	 *    error_handler
77
+	 *
78
+	 * @param $code
79
+	 * @param $message
80
+	 * @param $file
81
+	 * @param $line
82
+	 * @return void
83
+	 */
84
+	public static function error_handler($code, $message, $file, $line)
85
+	{
86
+		$type = EE_Error::error_type($code);
87
+		$site = site_url();
88
+		switch ($site) {
89
+			case 'http://ee4.eventespresso.com/':
90
+			case 'http://ee4decaf.eventespresso.com/':
91
+			case 'http://ee4hf.eventespresso.com/':
92
+			case 'http://ee4a.eventespresso.com/':
93
+			case 'http://ee4ad.eventespresso.com/':
94
+			case 'http://ee4b.eventespresso.com/':
95
+			case 'http://ee4bd.eventespresso.com/':
96
+			case 'http://ee4d.eventespresso.com/':
97
+			case 'http://ee4dd.eventespresso.com/':
98
+				$to = '[email protected]';
99
+				break;
100
+			default:
101
+				$to = get_option('admin_email');
102
+		}
103
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
104
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
105
+		if (function_exists('wp_mail')) {
106
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107
+			wp_mail($to, $subject, $msg);
108
+		}
109
+		echo '<div id="message" class="espresso-notices error"><p>';
110
+		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
111
+		echo '<br /></p></div>';
112
+	}
113
+
114
+
115
+	/**
116
+	 * error_type
117
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
118
+	 *
119
+	 * @param $code
120
+	 * @return string
121
+	 */
122
+	public static function error_type($code)
123
+	{
124
+		switch ($code) {
125
+			case E_ERROR: // 1 //
126
+				return 'E_ERROR';
127
+			case E_WARNING: // 2 //
128
+				return 'E_WARNING';
129
+			case E_PARSE: // 4 //
130
+				return 'E_PARSE';
131
+			case E_NOTICE: // 8 //
132
+				return 'E_NOTICE';
133
+			case E_CORE_ERROR: // 16 //
134
+				return 'E_CORE_ERROR';
135
+			case E_CORE_WARNING: // 32 //
136
+				return 'E_CORE_WARNING';
137
+			case E_COMPILE_ERROR: // 64 //
138
+				return 'E_COMPILE_ERROR';
139
+			case E_COMPILE_WARNING: // 128 //
140
+				return 'E_COMPILE_WARNING';
141
+			case E_USER_ERROR: // 256 //
142
+				return 'E_USER_ERROR';
143
+			case E_USER_WARNING: // 512 //
144
+				return 'E_USER_WARNING';
145
+			case E_USER_NOTICE: // 1024 //
146
+				return 'E_USER_NOTICE';
147
+			case E_STRICT: // 2048 //
148
+				return 'E_STRICT';
149
+			case E_RECOVERABLE_ERROR: // 4096 //
150
+				return 'E_RECOVERABLE_ERROR';
151
+			case E_DEPRECATED: // 8192 //
152
+				return 'E_DEPRECATED';
153
+			case E_USER_DEPRECATED: // 16384 //
154
+				return 'E_USER_DEPRECATED';
155
+			case E_ALL: // 16384 //
156
+				return 'E_ALL';
157
+		}
158
+		return '';
159
+	}
160
+
161
+
162
+	/**
163
+	 *    fatal_error_handler
164
+	 *
165
+	 * @return void
166
+	 */
167
+	public static function fatal_error_handler()
168
+	{
169
+		$last_error = error_get_last();
170
+		if ($last_error['type'] === E_ERROR) {
171
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * _format_error
178
+	 *
179
+	 * @param $code
180
+	 * @param $message
181
+	 * @param $file
182
+	 * @param $line
183
+	 * @return string
184
+	 */
185
+	private static function _format_error($code, $message, $file, $line)
186
+	{
187
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
188
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
189
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
190
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
191
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
192
+		$html .= '</tbody></table>';
193
+		return $html;
194
+	}
195
+
196
+
197
+	/**
198
+	 * set_content_type
199
+	 *
200
+	 * @param $content_type
201
+	 * @return string
202
+	 */
203
+	public static function set_content_type($content_type)
204
+	{
205
+		return 'text/html';
206
+	}
207
+
208
+
209
+	/**
210
+	 * @return void
211
+	 * @throws EE_Error
212
+	 * @throws ReflectionException
213
+	 */
214
+	public function get_error()
215
+	{
216
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
217
+			throw $this;
218
+		}
219
+		// get separate user and developer messages if they exist
220
+		$msg = explode('||', $this->getMessage());
221
+		$user_msg = $msg[0];
222
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
223
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
224
+		// add details to _all_exceptions array
225
+		$x_time = time();
226
+		self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
+		self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
+		self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
+		self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
+		self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
+		self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
+		self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
233
+		self::$_error_count++;
234
+		// add_action( 'shutdown', array( $this, 'display_errors' ));
235
+		$this->display_errors();
236
+	}
237
+
238
+
239
+	/**
240
+	 * @param bool   $check_stored
241
+	 * @param string $type_to_check
242
+	 * @return bool
243
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
244
+	 * @throws \InvalidArgumentException
245
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
246
+	 * @throws InvalidInterfaceException
247
+	 */
248
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
249
+	{
250
+		$has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
+					 && ! empty(self::$_espresso_notices[ $type_to_check ])
252
+			? true
253
+			: false;
254
+		if ($check_stored && ! $has_error) {
255
+			$notices = EE_Error::getStoredNotices();
256
+			foreach ($notices as $type => $notice) {
257
+				if ($type === $type_to_check && $notice) {
258
+					return true;
259
+				}
260
+			}
261
+		}
262
+		return $has_error;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @echo string
268
+	 * @throws \ReflectionException
269
+	 */
270
+	public function display_errors()
271
+	{
272
+		$trace_details = '';
273
+		$output = '
274 274
 <style type="text/css">
275 275
 	#ee-error-message {
276 276
 		max-width:90% !important;
@@ -326,21 +326,21 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 </style>
328 328
 <div id="ee-error-message" class="error">';
329
-        if (! WP_DEBUG) {
330
-            $output .= '
329
+		if (! WP_DEBUG) {
330
+			$output .= '
331 331
 	<p>';
332
-        }
333
-        // cycle thru errors
334
-        foreach (self::$_all_exceptions as $time => $ex) {
335
-            $error_code = '';
336
-            // process trace info
337
-            if (empty($ex['trace'])) {
338
-                $trace_details .= esc_html__(
339
-                    'Sorry, but no trace information was available for this exception.',
340
-                    'event_espresso'
341
-                );
342
-            } else {
343
-                $trace_details .= '
332
+		}
333
+		// cycle thru errors
334
+		foreach (self::$_all_exceptions as $time => $ex) {
335
+			$error_code = '';
336
+			// process trace info
337
+			if (empty($ex['trace'])) {
338
+				$trace_details .= esc_html__(
339
+					'Sorry, but no trace information was available for this exception.',
340
+					'event_espresso'
341
+				);
342
+			} else {
343
+				$trace_details .= '
344 344
 			<div id="ee-trace-details">
345 345
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
346 346
 				<tr>
@@ -350,43 +350,43 @@  discard block
 block discarded – undo
350 350
 					<th scope="col" align="left">Class</th>
351 351
 					<th scope="col" align="left">Method( arguments )</th>
352 352
 				</tr>';
353
-                $last_on_stack = count($ex['trace']) - 1;
354
-                // reverse array so that stack is in proper chronological order
355
-                $sorted_trace = array_reverse($ex['trace']);
356
-                foreach ($sorted_trace as $nmbr => $trace) {
357
-                    $file = isset($trace['file']) ? $trace['file'] : '';
358
-                    $class = isset($trace['class']) ? $trace['class'] : '';
359
-                    $type = isset($trace['type']) ? $trace['type'] : '';
360
-                    $function = isset($trace['function']) ? $trace['function'] : '';
361
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
362
-                    $line = isset($trace['line']) ? $trace['line'] : '';
363
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
364
-                    if (empty($file) && ! empty($class)) {
365
-                        $a = new ReflectionClass($class);
366
-                        $file = $a->getFileName();
367
-                        if (empty($line) && ! empty($function)) {
368
-                            try {
369
-                                // if $function is a closure, this throws an exception
370
-                                $b = new ReflectionMethod($class, $function);
371
-                                $line = $b->getStartLine();
372
-                            } catch (Exception $closure_exception) {
373
-                                $line = 'unknown';
374
-                            }
375
-                        }
376
-                    }
377
-                    if ($nmbr === $last_on_stack) {
378
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
379
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
380
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
381
-                    }
382
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
383
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
384
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
385
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
386
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
387
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
388
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
389
-                    $trace_details .= '
353
+				$last_on_stack = count($ex['trace']) - 1;
354
+				// reverse array so that stack is in proper chronological order
355
+				$sorted_trace = array_reverse($ex['trace']);
356
+				foreach ($sorted_trace as $nmbr => $trace) {
357
+					$file = isset($trace['file']) ? $trace['file'] : '';
358
+					$class = isset($trace['class']) ? $trace['class'] : '';
359
+					$type = isset($trace['type']) ? $trace['type'] : '';
360
+					$function = isset($trace['function']) ? $trace['function'] : '';
361
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
362
+					$line = isset($trace['line']) ? $trace['line'] : '';
363
+					$zebra = ($nmbr % 2) ? ' odd' : '';
364
+					if (empty($file) && ! empty($class)) {
365
+						$a = new ReflectionClass($class);
366
+						$file = $a->getFileName();
367
+						if (empty($line) && ! empty($function)) {
368
+							try {
369
+								// if $function is a closure, this throws an exception
370
+								$b = new ReflectionMethod($class, $function);
371
+								$line = $b->getStartLine();
372
+							} catch (Exception $closure_exception) {
373
+								$line = 'unknown';
374
+							}
375
+						}
376
+					}
377
+					if ($nmbr === $last_on_stack) {
378
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
379
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
380
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
381
+					}
382
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
383
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
384
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
385
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
386
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
387
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
388
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
389
+					$trace_details .= '
390 390
 					<tr>
391 391
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
392 392
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -394,628 +394,628 @@  discard block
 block discarded – undo
394 394
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
395 395
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
396 396
 					</tr>';
397
-                }
398
-                $trace_details .= '
397
+				}
398
+				$trace_details .= '
399 399
 			 </table>
400 400
 			</div>';
401
-            }
402
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403
-            // add generic non-identifying messages for non-privileged users
404
-            if (! WP_DEBUG) {
405
-                $output .= '<span class="ee-error-user-msg-spn">'
406
-                           . trim($ex['msg'])
407
-                           . '</span> &nbsp; <sup>'
408
-                           . $ex['code']
409
-                           . '</sup><br />';
410
-            } else {
411
-                // or helpful developer messages if debugging is on
412
-                $output .= '
401
+			}
402
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403
+			// add generic non-identifying messages for non-privileged users
404
+			if (! WP_DEBUG) {
405
+				$output .= '<span class="ee-error-user-msg-spn">'
406
+						   . trim($ex['msg'])
407
+						   . '</span> &nbsp; <sup>'
408
+						   . $ex['code']
409
+						   . '</sup><br />';
410
+			} else {
411
+				// or helpful developer messages if debugging is on
412
+				$output .= '
413 413
 		<div class="ee-error-dev-msg-dv">
414 414
 			<p class="ee-error-dev-msg-pg">
415 415
 				<strong class="ee-error-dev-msg-str">An '
416
-                           . $ex['name']
417
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
418
-                           . $ex['code']
419
-                           . '</span><br />
416
+						   . $ex['name']
417
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
418
+						   . $ex['code']
419
+						   . '</span><br />
420 420
 				<span class="big-text">"'
421
-                           . trim($ex['msg'])
422
-                           . '"</span><br/>
421
+						   . trim($ex['msg'])
422
+						   . '"</span><br/>
423 423
 				<a id="display-ee-error-trace-'
424
-                           . self::$_error_count
425
-                           . $time
426
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
427
-                           . self::$_error_count
428
-                           . $time
429
-                           . '">
424
+						   . self::$_error_count
425
+						   . $time
426
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
427
+						   . self::$_error_count
428
+						   . $time
429
+						   . '">
430 430
 					'
431
-                           . esc_html__('click to view backtrace and class/method details', 'event_espresso')
432
-                           . '
431
+						   . esc_html__('click to view backtrace and class/method details', 'event_espresso')
432
+						   . '
433 433
 				</a><br />
434 434
 				<span class="small-text lt-grey-text">'
435
-                           . $ex['file']
436
-                           . ' &nbsp; ( line no: '
437
-                           . $ex['line']
438
-                           . ' )</span>
435
+						   . $ex['file']
436
+						   . ' &nbsp; ( line no: '
437
+						   . $ex['line']
438
+						   . ' )</span>
439 439
 			</p>
440 440
 			<div id="ee-error-trace-'
441
-                           . self::$_error_count
442
-                           . $time
443
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
441
+						   . self::$_error_count
442
+						   . $time
443
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
444 444
 				'
445
-                           . $trace_details;
446
-                if (! empty($class)) {
447
-                    $output .= '
445
+						   . $trace_details;
446
+				if (! empty($class)) {
447
+					$output .= '
448 448
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
449 449
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
450 450
 						<h3>Class Details</h3>';
451
-                    $a = new ReflectionClass($class);
452
-                    $output .= '
451
+					$a = new ReflectionClass($class);
452
+					$output .= '
453 453
 						<pre>' . $a . '</pre>
454 454
 					</div>
455 455
 				</div>';
456
-                }
457
-                $output .= '
456
+				}
457
+				$output .= '
458 458
 			</div>
459 459
 		</div>
460 460
 		<br />';
461
-            }
462
-            $this->write_to_error_log($time, $ex);
463
-        }
464
-        // remove last linebreak
465
-        $output = substr($output, 0, -6);
466
-        if (! WP_DEBUG) {
467
-            $output .= '
461
+			}
462
+			$this->write_to_error_log($time, $ex);
463
+		}
464
+		// remove last linebreak
465
+		$output = substr($output, 0, -6);
466
+		if (! WP_DEBUG) {
467
+			$output .= '
468 468
 	</p>';
469
-        }
470
-        $output .= '
469
+		}
470
+		$output .= '
471 471
 </div>';
472
-        $output .= self::_print_scripts(true);
473
-        if (defined('DOING_AJAX')) {
474
-            echo wp_json_encode(array('error' => $output));
475
-            exit();
476
-        }
477
-        echo $output;
478
-        die();
479
-    }
480
-
481
-
482
-    /**
483
-     *    generate string from exception trace args
484
-     *
485
-     * @param array $arguments
486
-     * @param bool  $array
487
-     * @return string
488
-     */
489
-    private function _convert_args_to_string($arguments = array(), $array = false)
490
-    {
491
-        $arg_string = '';
492
-        if (! empty($arguments)) {
493
-            $args = array();
494
-            foreach ($arguments as $arg) {
495
-                if (! empty($arg)) {
496
-                    if (is_string($arg)) {
497
-                        $args[] = " '" . $arg . "'";
498
-                    } elseif (is_array($arg)) {
499
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
500
-                    } elseif ($arg === null) {
501
-                        $args[] = ' NULL';
502
-                    } elseif (is_bool($arg)) {
503
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
504
-                    } elseif (is_object($arg)) {
505
-                        $args[] = ' OBJECT ' . get_class($arg);
506
-                    } elseif (is_resource($arg)) {
507
-                        $args[] = get_resource_type($arg);
508
-                    } else {
509
-                        $args[] = $arg;
510
-                    }
511
-                }
512
-            }
513
-            $arg_string = implode(', ', $args);
514
-        }
515
-        if ($array) {
516
-            $arg_string .= ' )';
517
-        }
518
-        return $arg_string;
519
-    }
520
-
521
-
522
-    /**
523
-     *    add error message
524
-     *
525
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
-     *                            separate messages for user || dev
527
-     * @param        string $file the file that the error occurred in - just use __FILE__
528
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
-     * @param        string $line the line number where the error occurred - just use __LINE__
530
-     * @return        void
531
-     */
532
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
-    {
534
-        self::_add_notice('errors', $msg, $file, $func, $line);
535
-        self::$_error_count++;
536
-    }
537
-
538
-
539
-    /**
540
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
541
-     * adds an error
542
-     *
543
-     * @param string $msg
544
-     * @param string $file
545
-     * @param string $func
546
-     * @param string $line
547
-     * @throws EE_Error
548
-     */
549
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
550
-    {
551
-        if (WP_DEBUG) {
552
-            throw new EE_Error($msg);
553
-        }
554
-        EE_Error::add_error($msg, $file, $func, $line);
555
-    }
556
-
557
-
558
-    /**
559
-     *    add success message
560
-     *
561
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
562
-     *                            separate messages for user || dev
563
-     * @param        string $file the file that the error occurred in - just use __FILE__
564
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
565
-     * @param        string $line the line number where the error occurred - just use __LINE__
566
-     * @return        void
567
-     */
568
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
569
-    {
570
-        self::_add_notice('success', $msg, $file, $func, $line);
571
-    }
572
-
573
-
574
-    /**
575
-     *    add attention message
576
-     *
577
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
578
-     *                            separate messages for user || dev
579
-     * @param        string $file the file that the error occurred in - just use __FILE__
580
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
581
-     * @param        string $line the line number where the error occurred - just use __LINE__
582
-     * @return        void
583
-     */
584
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
585
-    {
586
-        self::_add_notice('attention', $msg, $file, $func, $line);
587
-    }
588
-
589
-
590
-    /**
591
-     * @param string $type whether the message is for a success or error notification
592
-     * @param string $msg  the message to display to users or developers
593
-     *                     - adding a double pipe || (OR) creates separate messages for user || dev
594
-     * @param string $file the file that the error occurred in - just use __FILE__
595
-     * @param string $func the function/method that the error occurred in - just use __FUNCTION__
596
-     * @param string $line the line number where the error occurred - just use __LINE__
597
-     * @return void
598
-     */
599
-    private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
600
-    {
601
-        if (empty($msg)) {
602
-            EE_Error::doing_it_wrong(
603
-                'EE_Error::add_' . $type . '()',
604
-                sprintf(
605
-                    esc_html__(
606
-                        'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
607
-                        'event_espresso'
608
-                    ),
609
-                    $type,
610
-                    $file,
611
-                    $line
612
-                ),
613
-                EVENT_ESPRESSO_VERSION
614
-            );
615
-        }
616
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
617
-            EE_Error::doing_it_wrong(
618
-                'EE_Error::add_error()',
619
-                esc_html__(
620
-                    'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
621
-                    'event_espresso'
622
-                ),
623
-                EVENT_ESPRESSO_VERSION
624
-            );
625
-        }
626
-        // get separate user and developer messages if they exist
627
-        $msg = explode('||', $msg);
628
-        $user_msg = $msg[0];
629
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
630
-        /**
631
-         * Do an action so other code can be triggered when a notice is created
632
-         *
633
-         * @param string $type     can be 'errors', 'attention', or 'success'
634
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
635
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
636
-         * @param string $file     file where error was generated
637
-         * @param string $func     function where error was generated
638
-         * @param string $line     line where error was generated
639
-         */
640
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
642
-        // add notice if message exists
643
-        if (! empty($msg)) {
644
-            // get error code
645
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
646
-            if (WP_DEBUG && $type === 'errors') {
647
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
648
-            }
649
-            // add notice. Index by code if it's not blank
650
-            if ($notice_code) {
651
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
652
-            } else {
653
-                self::$_espresso_notices[ $type ][] = $msg;
654
-            }
655
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656
-        }
657
-    }
658
-
659
-
660
-    /**
661
-     * in some case it may be necessary to overwrite the existing success messages
662
-     *
663
-     * @return        void
664
-     */
665
-    public static function overwrite_success()
666
-    {
667
-        self::$_espresso_notices['success'] = false;
668
-    }
669
-
670
-
671
-    /**
672
-     * in some case it may be necessary to overwrite the existing attention messages
673
-     *
674
-     * @return void
675
-     */
676
-    public static function overwrite_attention()
677
-    {
678
-        self::$_espresso_notices['attention'] = false;
679
-    }
680
-
681
-
682
-    /**
683
-     * in some case it may be necessary to overwrite the existing error messages
684
-     *
685
-     * @return void
686
-     */
687
-    public static function overwrite_errors()
688
-    {
689
-        self::$_espresso_notices['errors'] = false;
690
-    }
691
-
692
-
693
-    /**
694
-     * @return void
695
-     */
696
-    public static function reset_notices()
697
-    {
698
-        self::$_espresso_notices['success'] = false;
699
-        self::$_espresso_notices['attention'] = false;
700
-        self::$_espresso_notices['errors'] = false;
701
-    }
702
-
703
-
704
-    /**
705
-     * @return int
706
-     */
707
-    public static function has_notices()
708
-    {
709
-        $has_notices = 0;
710
-        // check for success messages
711
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
712
-            ? 3
713
-            : $has_notices;
714
-        // check for attention messages
715
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
716
-            ? 2
717
-            : $has_notices;
718
-        // check for error messages
719
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
720
-            ? 1
721
-            : $has_notices;
722
-        return $has_notices;
723
-    }
724
-
725
-
726
-    /**
727
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
728
-     *
729
-     * @since 4.9.0
730
-     * @return array
731
-     */
732
-    public static function get_vanilla_notices()
733
-    {
734
-        return array(
735
-            'success'   => isset(self::$_espresso_notices['success'])
736
-                ? self::$_espresso_notices['success']
737
-                : array(),
738
-            'attention' => isset(self::$_espresso_notices['attention'])
739
-                ? self::$_espresso_notices['attention']
740
-                : array(),
741
-            'errors'    => isset(self::$_espresso_notices['errors'])
742
-                ? self::$_espresso_notices['errors']
743
-                : array(),
744
-        );
745
-    }
746
-
747
-
748
-    /**
749
-     * @return array
750
-     * @throws InvalidArgumentException
751
-     * @throws InvalidDataTypeException
752
-     * @throws InvalidInterfaceException
753
-     */
754
-    public static function getStoredNotices()
755
-    {
756
-        if ($user_id = get_current_user_id()) {
757
-            // get notices for logged in user
758
-            $notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
759
-            return is_array($notices) ? $notices : array();
760
-        }
761
-        if (EE_Session::isLoadedAndActive()) {
762
-            // get notices for user currently engaged in a session
763
-            $session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
764
-            return is_array($session_data) ? $session_data : array();
765
-        }
766
-        // get global notices and hope they apply to the current site visitor
767
-        $notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
768
-        return is_array($notices) ? $notices : array();
769
-    }
770
-
771
-
772
-    /**
773
-     * @param array $notices
774
-     * @return bool
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidDataTypeException
777
-     * @throws InvalidInterfaceException
778
-     */
779
-    public static function storeNotices(array $notices)
780
-    {
781
-        if ($user_id = get_current_user_id()) {
782
-            // store notices for logged in user
783
-            return (bool) update_user_option(
784
-                $user_id,
785
-                EE_Error::OPTIONS_KEY_NOTICES,
786
-                $notices
787
-            );
788
-        }
789
-        if (EE_Session::isLoadedAndActive()) {
790
-            // store notices for user currently engaged in a session
791
-            return EE_Session::instance()->set_session_data(
792
-                array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
793
-            );
794
-        }
795
-        // store global notices and hope they apply to the same site visitor on the next request
796
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
797
-    }
798
-
799
-
800
-    /**
801
-     * @return bool|TRUE
802
-     * @throws InvalidArgumentException
803
-     * @throws InvalidDataTypeException
804
-     * @throws InvalidInterfaceException
805
-     */
806
-    public static function clearNotices()
807
-    {
808
-        if ($user_id = get_current_user_id()) {
809
-            // clear notices for logged in user
810
-            return (bool) update_user_option(
811
-                $user_id,
812
-                EE_Error::OPTIONS_KEY_NOTICES,
813
-                array()
814
-            );
815
-        }
816
-        if (EE_Session::isLoadedAndActive()) {
817
-            // clear notices for user currently engaged in a session
818
-            return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
819
-        }
820
-        // clear global notices and hope none belonged to some for some other site visitor
821
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
822
-    }
823
-
824
-
825
-    /**
826
-     * saves notices to the db for retrieval on next request
827
-     *
828
-     * @return void
829
-     * @throws InvalidArgumentException
830
-     * @throws InvalidDataTypeException
831
-     * @throws InvalidInterfaceException
832
-     */
833
-    public static function stashNoticesBeforeRedirect()
834
-    {
835
-        EE_Error::get_notices(false, true);
836
-    }
837
-
838
-
839
-    /**
840
-     * compile all error or success messages into one string
841
-     *
842
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
843
-     * @param boolean $format_output            whether or not to format the messages for display in the WP admin
844
-     * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
845
-     *                                          - ONLY do this just before redirecting
846
-     * @param boolean $remove_empty             whether or not to unset empty messages
847
-     * @return array
848
-     * @throws InvalidArgumentException
849
-     * @throws InvalidDataTypeException
850
-     * @throws InvalidInterfaceException
851
-     */
852
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
853
-    {
854
-        $success_messages = '';
855
-        $attention_messages = '';
856
-        $error_messages = '';
857
-        /** @var RequestInterface $request */
858
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
859
-        // either save notices to the db
860
-        if ($save_to_transient || $request->requestParamIsSet('activate-selected')) {
861
-            self::$_espresso_notices = array_merge(
862
-                EE_Error::getStoredNotices(),
863
-                self::$_espresso_notices
864
-            );
865
-            EE_Error::storeNotices(self::$_espresso_notices);
866
-            return array();
867
-        }
868
-        $print_scripts = EE_Error::combineExistingAndNewNotices();
869
-        // check for success messages
870
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
871
-            // combine messages
872
-            $success_messages .= implode('<br />', self::$_espresso_notices['success']);
873
-            $print_scripts = true;
874
-        }
875
-        // check for attention messages
876
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
877
-            // combine messages
878
-            $attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
879
-            $print_scripts = true;
880
-        }
881
-        // check for error messages
882
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
883
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
884
-                ? esc_html__('The following errors have occurred:', 'event_espresso')
885
-                : esc_html__('An error has occurred:', 'event_espresso');
886
-            // combine messages
887
-            $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
888
-            $print_scripts = true;
889
-        }
890
-        if ($format_output) {
891
-            $notices = EE_Error::formatNoticesOutput(
892
-                $success_messages,
893
-                $attention_messages,
894
-                $error_messages
895
-            );
896
-        } else {
897
-            $notices = array(
898
-                'success'   => $success_messages,
899
-                'attention' => $attention_messages,
900
-                'errors'    => $error_messages,
901
-            );
902
-            if ($remove_empty) {
903
-                // remove empty notices
904
-                foreach ($notices as $type => $notice) {
905
-                    if (empty($notice)) {
906
-                        unset($notices[ $type ]);
907
-                    }
908
-                }
909
-            }
910
-        }
911
-        if ($print_scripts) {
912
-            self::_print_scripts();
913
-        }
914
-        return $notices;
915
-    }
916
-
917
-
918
-    /**
919
-     * @return bool
920
-     * @throws InvalidArgumentException
921
-     * @throws InvalidDataTypeException
922
-     * @throws InvalidInterfaceException
923
-     */
924
-    private static function combineExistingAndNewNotices()
925
-    {
926
-        $print_scripts = false;
927
-        // grab any notices that have been previously saved
928
-        $notices = EE_Error::getStoredNotices();
929
-        if (! empty($notices)) {
930
-            foreach ($notices as $type => $notice) {
931
-                if (is_array($notice) && ! empty($notice)) {
932
-                    // make sure that existing notice type is an array
933
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
-                                                        && ! empty(self::$_espresso_notices[ $type ])
935
-                        ? self::$_espresso_notices[ $type ]
936
-                        : array();
937
-                    // add newly created notices to existing ones
938
-                    self::$_espresso_notices[ $type ] += $notice;
939
-                    $print_scripts = true;
940
-                }
941
-            }
942
-            // now clear any stored notices
943
-            EE_Error::clearNotices();
944
-        }
945
-        return $print_scripts;
946
-    }
947
-
948
-
949
-    /**
950
-     * @param string $success_messages
951
-     * @param string $attention_messages
952
-     * @param string $error_messages
953
-     * @return string
954
-     */
955
-    private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
956
-    {
957
-        $notices = '<div id="espresso-notices">';
958
-        $close = is_admin()
959
-            ? ''
960
-            : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
961
-        if ($success_messages !== '') {
962
-            $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963
-            $css_class = is_admin() ? 'updated fade' : 'success fade-away';
964
-            // showMessage( $success_messages );
965
-            $notices .= '<div id="' . $css_id . '" '
966
-                        . 'class="espresso-notices ' . $css_class . '" '
967
-                        . 'style="display:none;">'
968
-                        . '<p>' . $success_messages . '</p>'
969
-                        . $close
970
-                        . '</div>';
971
-        }
972
-        if ($attention_messages !== '') {
973
-            $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974
-            $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975
-            // showMessage( $error_messages, TRUE );
976
-            $notices .= '<div id="' . $css_id . '" '
977
-                        . 'class="espresso-notices ' . $css_class . '" '
978
-                        . 'style="display:none;">'
979
-                        . '<p>' . $attention_messages . '</p>'
980
-                        . $close
981
-                        . '</div>';
982
-        }
983
-        if ($error_messages !== '') {
984
-            $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985
-            $css_class = is_admin() ? 'error' : 'error fade-away';
986
-            // showMessage( $error_messages, TRUE );
987
-            $notices .= '<div id="' . $css_id . '" '
988
-                        . 'class="espresso-notices ' . $css_class . '" '
989
-                        . 'style="display:none;">'
990
-                        . '<p>' . $error_messages . '</p>'
991
-                        . $close
992
-                        . '</div>';
993
-        }
994
-        $notices .= '</div>';
995
-        return $notices;
996
-    }
997
-
998
-
999
-    /**
1000
-     * _print_scripts
1001
-     *
1002
-     * @param    bool $force_print
1003
-     * @return    string
1004
-     */
1005
-    private static function _print_scripts($force_print = false)
1006
-    {
1007
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008
-            if (wp_script_is('ee_error_js', 'registered')) {
1009
-                wp_enqueue_style('espresso_default');
1010
-                wp_enqueue_style('espresso_custom_css');
1011
-                wp_enqueue_script('ee_error_js');
1012
-            }
1013
-            if (wp_script_is('ee_error_js', 'enqueued')) {
1014
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1015
-                return '';
1016
-            }
1017
-        } else {
1018
-            return '
472
+		$output .= self::_print_scripts(true);
473
+		if (defined('DOING_AJAX')) {
474
+			echo wp_json_encode(array('error' => $output));
475
+			exit();
476
+		}
477
+		echo $output;
478
+		die();
479
+	}
480
+
481
+
482
+	/**
483
+	 *    generate string from exception trace args
484
+	 *
485
+	 * @param array $arguments
486
+	 * @param bool  $array
487
+	 * @return string
488
+	 */
489
+	private function _convert_args_to_string($arguments = array(), $array = false)
490
+	{
491
+		$arg_string = '';
492
+		if (! empty($arguments)) {
493
+			$args = array();
494
+			foreach ($arguments as $arg) {
495
+				if (! empty($arg)) {
496
+					if (is_string($arg)) {
497
+						$args[] = " '" . $arg . "'";
498
+					} elseif (is_array($arg)) {
499
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
500
+					} elseif ($arg === null) {
501
+						$args[] = ' NULL';
502
+					} elseif (is_bool($arg)) {
503
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
504
+					} elseif (is_object($arg)) {
505
+						$args[] = ' OBJECT ' . get_class($arg);
506
+					} elseif (is_resource($arg)) {
507
+						$args[] = get_resource_type($arg);
508
+					} else {
509
+						$args[] = $arg;
510
+					}
511
+				}
512
+			}
513
+			$arg_string = implode(', ', $args);
514
+		}
515
+		if ($array) {
516
+			$arg_string .= ' )';
517
+		}
518
+		return $arg_string;
519
+	}
520
+
521
+
522
+	/**
523
+	 *    add error message
524
+	 *
525
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
+	 *                            separate messages for user || dev
527
+	 * @param        string $file the file that the error occurred in - just use __FILE__
528
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
+	 * @param        string $line the line number where the error occurred - just use __LINE__
530
+	 * @return        void
531
+	 */
532
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
+	{
534
+		self::_add_notice('errors', $msg, $file, $func, $line);
535
+		self::$_error_count++;
536
+	}
537
+
538
+
539
+	/**
540
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
541
+	 * adds an error
542
+	 *
543
+	 * @param string $msg
544
+	 * @param string $file
545
+	 * @param string $func
546
+	 * @param string $line
547
+	 * @throws EE_Error
548
+	 */
549
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
550
+	{
551
+		if (WP_DEBUG) {
552
+			throw new EE_Error($msg);
553
+		}
554
+		EE_Error::add_error($msg, $file, $func, $line);
555
+	}
556
+
557
+
558
+	/**
559
+	 *    add success message
560
+	 *
561
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
562
+	 *                            separate messages for user || dev
563
+	 * @param        string $file the file that the error occurred in - just use __FILE__
564
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
565
+	 * @param        string $line the line number where the error occurred - just use __LINE__
566
+	 * @return        void
567
+	 */
568
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
569
+	{
570
+		self::_add_notice('success', $msg, $file, $func, $line);
571
+	}
572
+
573
+
574
+	/**
575
+	 *    add attention message
576
+	 *
577
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
578
+	 *                            separate messages for user || dev
579
+	 * @param        string $file the file that the error occurred in - just use __FILE__
580
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
581
+	 * @param        string $line the line number where the error occurred - just use __LINE__
582
+	 * @return        void
583
+	 */
584
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
585
+	{
586
+		self::_add_notice('attention', $msg, $file, $func, $line);
587
+	}
588
+
589
+
590
+	/**
591
+	 * @param string $type whether the message is for a success or error notification
592
+	 * @param string $msg  the message to display to users or developers
593
+	 *                     - adding a double pipe || (OR) creates separate messages for user || dev
594
+	 * @param string $file the file that the error occurred in - just use __FILE__
595
+	 * @param string $func the function/method that the error occurred in - just use __FUNCTION__
596
+	 * @param string $line the line number where the error occurred - just use __LINE__
597
+	 * @return void
598
+	 */
599
+	private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
600
+	{
601
+		if (empty($msg)) {
602
+			EE_Error::doing_it_wrong(
603
+				'EE_Error::add_' . $type . '()',
604
+				sprintf(
605
+					esc_html__(
606
+						'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
607
+						'event_espresso'
608
+					),
609
+					$type,
610
+					$file,
611
+					$line
612
+				),
613
+				EVENT_ESPRESSO_VERSION
614
+			);
615
+		}
616
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
617
+			EE_Error::doing_it_wrong(
618
+				'EE_Error::add_error()',
619
+				esc_html__(
620
+					'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
621
+					'event_espresso'
622
+				),
623
+				EVENT_ESPRESSO_VERSION
624
+			);
625
+		}
626
+		// get separate user and developer messages if they exist
627
+		$msg = explode('||', $msg);
628
+		$user_msg = $msg[0];
629
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
630
+		/**
631
+		 * Do an action so other code can be triggered when a notice is created
632
+		 *
633
+		 * @param string $type     can be 'errors', 'attention', or 'success'
634
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
635
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
636
+		 * @param string $file     file where error was generated
637
+		 * @param string $func     function where error was generated
638
+		 * @param string $line     line where error was generated
639
+		 */
640
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
642
+		// add notice if message exists
643
+		if (! empty($msg)) {
644
+			// get error code
645
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
646
+			if (WP_DEBUG && $type === 'errors') {
647
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
648
+			}
649
+			// add notice. Index by code if it's not blank
650
+			if ($notice_code) {
651
+				self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
652
+			} else {
653
+				self::$_espresso_notices[ $type ][] = $msg;
654
+			}
655
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656
+		}
657
+	}
658
+
659
+
660
+	/**
661
+	 * in some case it may be necessary to overwrite the existing success messages
662
+	 *
663
+	 * @return        void
664
+	 */
665
+	public static function overwrite_success()
666
+	{
667
+		self::$_espresso_notices['success'] = false;
668
+	}
669
+
670
+
671
+	/**
672
+	 * in some case it may be necessary to overwrite the existing attention messages
673
+	 *
674
+	 * @return void
675
+	 */
676
+	public static function overwrite_attention()
677
+	{
678
+		self::$_espresso_notices['attention'] = false;
679
+	}
680
+
681
+
682
+	/**
683
+	 * in some case it may be necessary to overwrite the existing error messages
684
+	 *
685
+	 * @return void
686
+	 */
687
+	public static function overwrite_errors()
688
+	{
689
+		self::$_espresso_notices['errors'] = false;
690
+	}
691
+
692
+
693
+	/**
694
+	 * @return void
695
+	 */
696
+	public static function reset_notices()
697
+	{
698
+		self::$_espresso_notices['success'] = false;
699
+		self::$_espresso_notices['attention'] = false;
700
+		self::$_espresso_notices['errors'] = false;
701
+	}
702
+
703
+
704
+	/**
705
+	 * @return int
706
+	 */
707
+	public static function has_notices()
708
+	{
709
+		$has_notices = 0;
710
+		// check for success messages
711
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
712
+			? 3
713
+			: $has_notices;
714
+		// check for attention messages
715
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
716
+			? 2
717
+			: $has_notices;
718
+		// check for error messages
719
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
720
+			? 1
721
+			: $has_notices;
722
+		return $has_notices;
723
+	}
724
+
725
+
726
+	/**
727
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
728
+	 *
729
+	 * @since 4.9.0
730
+	 * @return array
731
+	 */
732
+	public static function get_vanilla_notices()
733
+	{
734
+		return array(
735
+			'success'   => isset(self::$_espresso_notices['success'])
736
+				? self::$_espresso_notices['success']
737
+				: array(),
738
+			'attention' => isset(self::$_espresso_notices['attention'])
739
+				? self::$_espresso_notices['attention']
740
+				: array(),
741
+			'errors'    => isset(self::$_espresso_notices['errors'])
742
+				? self::$_espresso_notices['errors']
743
+				: array(),
744
+		);
745
+	}
746
+
747
+
748
+	/**
749
+	 * @return array
750
+	 * @throws InvalidArgumentException
751
+	 * @throws InvalidDataTypeException
752
+	 * @throws InvalidInterfaceException
753
+	 */
754
+	public static function getStoredNotices()
755
+	{
756
+		if ($user_id = get_current_user_id()) {
757
+			// get notices for logged in user
758
+			$notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
759
+			return is_array($notices) ? $notices : array();
760
+		}
761
+		if (EE_Session::isLoadedAndActive()) {
762
+			// get notices for user currently engaged in a session
763
+			$session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
764
+			return is_array($session_data) ? $session_data : array();
765
+		}
766
+		// get global notices and hope they apply to the current site visitor
767
+		$notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
768
+		return is_array($notices) ? $notices : array();
769
+	}
770
+
771
+
772
+	/**
773
+	 * @param array $notices
774
+	 * @return bool
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws InvalidInterfaceException
778
+	 */
779
+	public static function storeNotices(array $notices)
780
+	{
781
+		if ($user_id = get_current_user_id()) {
782
+			// store notices for logged in user
783
+			return (bool) update_user_option(
784
+				$user_id,
785
+				EE_Error::OPTIONS_KEY_NOTICES,
786
+				$notices
787
+			);
788
+		}
789
+		if (EE_Session::isLoadedAndActive()) {
790
+			// store notices for user currently engaged in a session
791
+			return EE_Session::instance()->set_session_data(
792
+				array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
793
+			);
794
+		}
795
+		// store global notices and hope they apply to the same site visitor on the next request
796
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
797
+	}
798
+
799
+
800
+	/**
801
+	 * @return bool|TRUE
802
+	 * @throws InvalidArgumentException
803
+	 * @throws InvalidDataTypeException
804
+	 * @throws InvalidInterfaceException
805
+	 */
806
+	public static function clearNotices()
807
+	{
808
+		if ($user_id = get_current_user_id()) {
809
+			// clear notices for logged in user
810
+			return (bool) update_user_option(
811
+				$user_id,
812
+				EE_Error::OPTIONS_KEY_NOTICES,
813
+				array()
814
+			);
815
+		}
816
+		if (EE_Session::isLoadedAndActive()) {
817
+			// clear notices for user currently engaged in a session
818
+			return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
819
+		}
820
+		// clear global notices and hope none belonged to some for some other site visitor
821
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
822
+	}
823
+
824
+
825
+	/**
826
+	 * saves notices to the db for retrieval on next request
827
+	 *
828
+	 * @return void
829
+	 * @throws InvalidArgumentException
830
+	 * @throws InvalidDataTypeException
831
+	 * @throws InvalidInterfaceException
832
+	 */
833
+	public static function stashNoticesBeforeRedirect()
834
+	{
835
+		EE_Error::get_notices(false, true);
836
+	}
837
+
838
+
839
+	/**
840
+	 * compile all error or success messages into one string
841
+	 *
842
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
843
+	 * @param boolean $format_output            whether or not to format the messages for display in the WP admin
844
+	 * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
845
+	 *                                          - ONLY do this just before redirecting
846
+	 * @param boolean $remove_empty             whether or not to unset empty messages
847
+	 * @return array
848
+	 * @throws InvalidArgumentException
849
+	 * @throws InvalidDataTypeException
850
+	 * @throws InvalidInterfaceException
851
+	 */
852
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
853
+	{
854
+		$success_messages = '';
855
+		$attention_messages = '';
856
+		$error_messages = '';
857
+		/** @var RequestInterface $request */
858
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
859
+		// either save notices to the db
860
+		if ($save_to_transient || $request->requestParamIsSet('activate-selected')) {
861
+			self::$_espresso_notices = array_merge(
862
+				EE_Error::getStoredNotices(),
863
+				self::$_espresso_notices
864
+			);
865
+			EE_Error::storeNotices(self::$_espresso_notices);
866
+			return array();
867
+		}
868
+		$print_scripts = EE_Error::combineExistingAndNewNotices();
869
+		// check for success messages
870
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
871
+			// combine messages
872
+			$success_messages .= implode('<br />', self::$_espresso_notices['success']);
873
+			$print_scripts = true;
874
+		}
875
+		// check for attention messages
876
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
877
+			// combine messages
878
+			$attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
879
+			$print_scripts = true;
880
+		}
881
+		// check for error messages
882
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
883
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
884
+				? esc_html__('The following errors have occurred:', 'event_espresso')
885
+				: esc_html__('An error has occurred:', 'event_espresso');
886
+			// combine messages
887
+			$error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
888
+			$print_scripts = true;
889
+		}
890
+		if ($format_output) {
891
+			$notices = EE_Error::formatNoticesOutput(
892
+				$success_messages,
893
+				$attention_messages,
894
+				$error_messages
895
+			);
896
+		} else {
897
+			$notices = array(
898
+				'success'   => $success_messages,
899
+				'attention' => $attention_messages,
900
+				'errors'    => $error_messages,
901
+			);
902
+			if ($remove_empty) {
903
+				// remove empty notices
904
+				foreach ($notices as $type => $notice) {
905
+					if (empty($notice)) {
906
+						unset($notices[ $type ]);
907
+					}
908
+				}
909
+			}
910
+		}
911
+		if ($print_scripts) {
912
+			self::_print_scripts();
913
+		}
914
+		return $notices;
915
+	}
916
+
917
+
918
+	/**
919
+	 * @return bool
920
+	 * @throws InvalidArgumentException
921
+	 * @throws InvalidDataTypeException
922
+	 * @throws InvalidInterfaceException
923
+	 */
924
+	private static function combineExistingAndNewNotices()
925
+	{
926
+		$print_scripts = false;
927
+		// grab any notices that have been previously saved
928
+		$notices = EE_Error::getStoredNotices();
929
+		if (! empty($notices)) {
930
+			foreach ($notices as $type => $notice) {
931
+				if (is_array($notice) && ! empty($notice)) {
932
+					// make sure that existing notice type is an array
933
+					self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
+														&& ! empty(self::$_espresso_notices[ $type ])
935
+						? self::$_espresso_notices[ $type ]
936
+						: array();
937
+					// add newly created notices to existing ones
938
+					self::$_espresso_notices[ $type ] += $notice;
939
+					$print_scripts = true;
940
+				}
941
+			}
942
+			// now clear any stored notices
943
+			EE_Error::clearNotices();
944
+		}
945
+		return $print_scripts;
946
+	}
947
+
948
+
949
+	/**
950
+	 * @param string $success_messages
951
+	 * @param string $attention_messages
952
+	 * @param string $error_messages
953
+	 * @return string
954
+	 */
955
+	private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
956
+	{
957
+		$notices = '<div id="espresso-notices">';
958
+		$close = is_admin()
959
+			? ''
960
+			: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
961
+		if ($success_messages !== '') {
962
+			$css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963
+			$css_class = is_admin() ? 'updated fade' : 'success fade-away';
964
+			// showMessage( $success_messages );
965
+			$notices .= '<div id="' . $css_id . '" '
966
+						. 'class="espresso-notices ' . $css_class . '" '
967
+						. 'style="display:none;">'
968
+						. '<p>' . $success_messages . '</p>'
969
+						. $close
970
+						. '</div>';
971
+		}
972
+		if ($attention_messages !== '') {
973
+			$css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974
+			$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975
+			// showMessage( $error_messages, TRUE );
976
+			$notices .= '<div id="' . $css_id . '" '
977
+						. 'class="espresso-notices ' . $css_class . '" '
978
+						. 'style="display:none;">'
979
+						. '<p>' . $attention_messages . '</p>'
980
+						. $close
981
+						. '</div>';
982
+		}
983
+		if ($error_messages !== '') {
984
+			$css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985
+			$css_class = is_admin() ? 'error' : 'error fade-away';
986
+			// showMessage( $error_messages, TRUE );
987
+			$notices .= '<div id="' . $css_id . '" '
988
+						. 'class="espresso-notices ' . $css_class . '" '
989
+						. 'style="display:none;">'
990
+						. '<p>' . $error_messages . '</p>'
991
+						. $close
992
+						. '</div>';
993
+		}
994
+		$notices .= '</div>';
995
+		return $notices;
996
+	}
997
+
998
+
999
+	/**
1000
+	 * _print_scripts
1001
+	 *
1002
+	 * @param    bool $force_print
1003
+	 * @return    string
1004
+	 */
1005
+	private static function _print_scripts($force_print = false)
1006
+	{
1007
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008
+			if (wp_script_is('ee_error_js', 'registered')) {
1009
+				wp_enqueue_style('espresso_default');
1010
+				wp_enqueue_style('espresso_custom_css');
1011
+				wp_enqueue_script('ee_error_js');
1012
+			}
1013
+			if (wp_script_is('ee_error_js', 'enqueued')) {
1014
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1015
+				return '';
1016
+			}
1017
+		} else {
1018
+			return '
1019 1019
 <script>
1020 1020
 /* <![CDATA[ */
1021 1021
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -1025,221 +1025,221 @@  discard block
 block discarded – undo
1025 1025
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1026 1026
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1027 1027
 ';
1028
-        }
1029
-        return '';
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return void
1035
-     */
1036
-    public static function enqueue_error_scripts()
1037
-    {
1038
-        self::_print_scripts();
1039
-    }
1040
-
1041
-
1042
-    /**
1043
-     * create error code from filepath, function name,
1044
-     * and line number where exception or error was thrown
1045
-     *
1046
-     * @param string $file
1047
-     * @param string $func
1048
-     * @param string $line
1049
-     * @return string
1050
-     */
1051
-    public static function generate_error_code($file = '', $func = '', $line = '')
1052
-    {
1053
-        $file = explode('.', basename($file));
1054
-        $error_code = ! empty($file[0]) ? $file[0] : '';
1055
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1056
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1057
-        return $error_code;
1058
-    }
1059
-
1060
-
1061
-    /**
1062
-     * write exception details to log file
1063
-     * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1064
-     *
1065
-     * @param int   $time
1066
-     * @param array $ex
1067
-     * @param bool  $clear
1068
-     * @return void
1069
-     */
1070
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1071
-    {
1072
-        if (empty($ex)) {
1073
-            return;
1074
-        }
1075
-        if (! $time) {
1076
-            $time = time();
1077
-        }
1078
-        $exception_log = '----------------------------------------------------------------------------------------'
1079
-                         . PHP_EOL;
1080
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1086
-        $exception_log .= $ex['string'] . PHP_EOL;
1087
-        $exception_log .= '----------------------------------------------------------------------------------------'
1088
-                          . PHP_EOL;
1089
-        try {
1090
-            error_log($exception_log);
1091
-        } catch (EE_Error $e) {
1092
-            EE_Error::add_error(
1093
-                sprintf(
1094
-                    esc_html__(
1095
-                        'Event Espresso error logging could not be setup because: %s',
1096
-                        'event_espresso'
1097
-                    ),
1098
-                    $e->getMessage()
1099
-                )
1100
-            );
1101
-        }
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1107
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1108
-     * but the code execution is done in a manner that could lead to unexpected results
1109
-     * (i.e. running to early, or too late in WP or EE loading process).
1110
-     * A good test for knowing whether to use this method is:
1111
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1112
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1113
-     * 2. If this is loaded before something else, it won't break anything,
1114
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1115
-     *
1116
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1117
-     * @param string $function      The function that was called
1118
-     * @param string $message       A message explaining what has been done incorrectly
1119
-     * @param string $version       The version of Event Espresso where the error was added
1120
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1121
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1122
-     *                              but not have any notices appear until a later version. This allows developers
1123
-     *                              extra time to update their code before notices appear.
1124
-     * @param int    $error_type
1125
-     */
1126
-    public static function doing_it_wrong(
1127
-        $function,
1128
-        $message,
1129
-        $version,
1130
-        $applies_when = '',
1131
-        $error_type = null
1132
-    ) {
1133
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1134
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1135
-        }
1136
-    }
1137
-
1138
-
1139
-    /**
1140
-     * Like get_notices, but returns an array of all the notices of the given type.
1141
-     *
1142
-     * @return array {
1143
-     * @type array $success   all the success messages
1144
-     * @type array $errors    all the error messages
1145
-     * @type array $attention all the attention messages
1146
-     * }
1147
-     */
1148
-    public static function get_raw_notices()
1149
-    {
1150
-        return self::$_espresso_notices;
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * @deprecated 4.9.27
1156
-     * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1157
-     * @param string $pan_message  the message to be stored persistently until dismissed
1158
-     * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1159
-     * @return void
1160
-     * @throws InvalidDataTypeException
1161
-     */
1162
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1163
-    {
1164
-        new PersistentAdminNotice(
1165
-            $pan_name,
1166
-            $pan_message,
1167
-            $force_update
1168
-        );
1169
-        EE_Error::doing_it_wrong(
1170
-            __METHOD__,
1171
-            sprintf(
1172
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1173
-                '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1174
-            ),
1175
-            '4.9.27'
1176
-        );
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     * @deprecated 4.9.27
1182
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1183
-     * @param bool   $purge
1184
-     * @param bool   $return
1185
-     * @throws DomainException
1186
-     * @throws InvalidInterfaceException
1187
-     * @throws InvalidDataTypeException
1188
-     * @throws ServiceNotFoundException
1189
-     * @throws InvalidArgumentException
1190
-     */
1191
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1192
-    {
1193
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1194
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1195
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1196
-        );
1197
-        $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1198
-        EE_Error::doing_it_wrong(
1199
-            __METHOD__,
1200
-            sprintf(
1201
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1202
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1203
-            ),
1204
-            '4.9.27'
1205
-        );
1206
-    }
1207
-
1208
-
1209
-    /**
1210
-     * @deprecated 4.9.27
1211
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1212
-     * @param  string $pan_message the message to be stored persistently until dismissed
1213
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
1214
-     */
1215
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1216
-    {
1217
-        EE_Error::doing_it_wrong(
1218
-            __METHOD__,
1219
-            sprintf(
1220
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1221
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1222
-            ),
1223
-            '4.9.27'
1224
-        );
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * @deprecated 4.9.27
1230
-     * @param string $return_url
1231
-     */
1232
-    public static function get_persistent_admin_notices($return_url = '')
1233
-    {
1234
-        EE_Error::doing_it_wrong(
1235
-            __METHOD__,
1236
-            sprintf(
1237
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1238
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1239
-            ),
1240
-            '4.9.27'
1241
-        );
1242
-    }
1028
+		}
1029
+		return '';
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return void
1035
+	 */
1036
+	public static function enqueue_error_scripts()
1037
+	{
1038
+		self::_print_scripts();
1039
+	}
1040
+
1041
+
1042
+	/**
1043
+	 * create error code from filepath, function name,
1044
+	 * and line number where exception or error was thrown
1045
+	 *
1046
+	 * @param string $file
1047
+	 * @param string $func
1048
+	 * @param string $line
1049
+	 * @return string
1050
+	 */
1051
+	public static function generate_error_code($file = '', $func = '', $line = '')
1052
+	{
1053
+		$file = explode('.', basename($file));
1054
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1055
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
1056
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
1057
+		return $error_code;
1058
+	}
1059
+
1060
+
1061
+	/**
1062
+	 * write exception details to log file
1063
+	 * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1064
+	 *
1065
+	 * @param int   $time
1066
+	 * @param array $ex
1067
+	 * @param bool  $clear
1068
+	 * @return void
1069
+	 */
1070
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1071
+	{
1072
+		if (empty($ex)) {
1073
+			return;
1074
+		}
1075
+		if (! $time) {
1076
+			$time = time();
1077
+		}
1078
+		$exception_log = '----------------------------------------------------------------------------------------'
1079
+						 . PHP_EOL;
1080
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
1086
+		$exception_log .= $ex['string'] . PHP_EOL;
1087
+		$exception_log .= '----------------------------------------------------------------------------------------'
1088
+						  . PHP_EOL;
1089
+		try {
1090
+			error_log($exception_log);
1091
+		} catch (EE_Error $e) {
1092
+			EE_Error::add_error(
1093
+				sprintf(
1094
+					esc_html__(
1095
+						'Event Espresso error logging could not be setup because: %s',
1096
+						'event_espresso'
1097
+					),
1098
+					$e->getMessage()
1099
+				)
1100
+			);
1101
+		}
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1107
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1108
+	 * but the code execution is done in a manner that could lead to unexpected results
1109
+	 * (i.e. running to early, or too late in WP or EE loading process).
1110
+	 * A good test for knowing whether to use this method is:
1111
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1112
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1113
+	 * 2. If this is loaded before something else, it won't break anything,
1114
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1115
+	 *
1116
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1117
+	 * @param string $function      The function that was called
1118
+	 * @param string $message       A message explaining what has been done incorrectly
1119
+	 * @param string $version       The version of Event Espresso where the error was added
1120
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1121
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1122
+	 *                              but not have any notices appear until a later version. This allows developers
1123
+	 *                              extra time to update their code before notices appear.
1124
+	 * @param int    $error_type
1125
+	 */
1126
+	public static function doing_it_wrong(
1127
+		$function,
1128
+		$message,
1129
+		$version,
1130
+		$applies_when = '',
1131
+		$error_type = null
1132
+	) {
1133
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1134
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1135
+		}
1136
+	}
1137
+
1138
+
1139
+	/**
1140
+	 * Like get_notices, but returns an array of all the notices of the given type.
1141
+	 *
1142
+	 * @return array {
1143
+	 * @type array $success   all the success messages
1144
+	 * @type array $errors    all the error messages
1145
+	 * @type array $attention all the attention messages
1146
+	 * }
1147
+	 */
1148
+	public static function get_raw_notices()
1149
+	{
1150
+		return self::$_espresso_notices;
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * @deprecated 4.9.27
1156
+	 * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1157
+	 * @param string $pan_message  the message to be stored persistently until dismissed
1158
+	 * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1159
+	 * @return void
1160
+	 * @throws InvalidDataTypeException
1161
+	 */
1162
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1163
+	{
1164
+		new PersistentAdminNotice(
1165
+			$pan_name,
1166
+			$pan_message,
1167
+			$force_update
1168
+		);
1169
+		EE_Error::doing_it_wrong(
1170
+			__METHOD__,
1171
+			sprintf(
1172
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1173
+				'\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1174
+			),
1175
+			'4.9.27'
1176
+		);
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 * @deprecated 4.9.27
1182
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1183
+	 * @param bool   $purge
1184
+	 * @param bool   $return
1185
+	 * @throws DomainException
1186
+	 * @throws InvalidInterfaceException
1187
+	 * @throws InvalidDataTypeException
1188
+	 * @throws ServiceNotFoundException
1189
+	 * @throws InvalidArgumentException
1190
+	 */
1191
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1192
+	{
1193
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1194
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1195
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1196
+		);
1197
+		$persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1198
+		EE_Error::doing_it_wrong(
1199
+			__METHOD__,
1200
+			sprintf(
1201
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1202
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1203
+			),
1204
+			'4.9.27'
1205
+		);
1206
+	}
1207
+
1208
+
1209
+	/**
1210
+	 * @deprecated 4.9.27
1211
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1212
+	 * @param  string $pan_message the message to be stored persistently until dismissed
1213
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
1214
+	 */
1215
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1216
+	{
1217
+		EE_Error::doing_it_wrong(
1218
+			__METHOD__,
1219
+			sprintf(
1220
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1221
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1222
+			),
1223
+			'4.9.27'
1224
+		);
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * @deprecated 4.9.27
1230
+	 * @param string $return_url
1231
+	 */
1232
+	public static function get_persistent_admin_notices($return_url = '')
1233
+	{
1234
+		EE_Error::doing_it_wrong(
1235
+			__METHOD__,
1236
+			sprintf(
1237
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1238
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1239
+			),
1240
+			'4.9.27'
1241
+		);
1242
+	}
1243 1243
 }
1244 1244
 
1245 1245
 // end of Class EE_Exceptions
@@ -1252,26 +1252,26 @@  discard block
 block discarded – undo
1252 1252
  */
1253 1253
 function espresso_error_enqueue_scripts()
1254 1254
 {
1255
-    // js for error handling
1256
-    wp_register_script(
1257
-        'espresso_core',
1258
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1259
-        array('jquery'),
1260
-        EVENT_ESPRESSO_VERSION
1261
-    );
1262
-    wp_register_script(
1263
-        'ee_error_js',
1264
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1265
-        array('espresso_core'),
1266
-        EVENT_ESPRESSO_VERSION
1267
-    );
1268
-    wp_localize_script('ee_error_js', 'ee_settings', ['wp_debug' => WP_DEBUG]);
1255
+	// js for error handling
1256
+	wp_register_script(
1257
+		'espresso_core',
1258
+		EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1259
+		array('jquery'),
1260
+		EVENT_ESPRESSO_VERSION
1261
+	);
1262
+	wp_register_script(
1263
+		'ee_error_js',
1264
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1265
+		array('espresso_core'),
1266
+		EVENT_ESPRESSO_VERSION
1267
+	);
1268
+	wp_localize_script('ee_error_js', 'ee_settings', ['wp_debug' => WP_DEBUG]);
1269 1269
 }
1270 1270
 
1271 1271
 if (is_admin()) {
1272
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1272
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1273 1273
 } else {
1274
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1274
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1275 1275
 }
1276 1276
 
1277 1277
 
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
             default:
101 101
                 $to = get_option('admin_email');
102 102
         }
103
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
103
+        $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url();
104 104
         $msg = EE_Error::_format_error($type, $message, $file, $line);
105 105
         if (function_exists('wp_mail')) {
106 106
             add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107 107
             wp_mail($to, $subject, $msg);
108 108
         }
109 109
         echo '<div id="message" class="espresso-notices error"><p>';
110
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
110
+        echo $type.': '.$message.'<br />'.$file.' line '.$line;
111 111
         echo '<br /></p></div>';
112 112
     }
113 113
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
224 224
         // add details to _all_exceptions array
225 225
         $x_time = time();
226
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
226
+        self::$_all_exceptions[$x_time]['name'] = get_class($this);
227
+        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
228
+        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
229
+        self::$_all_exceptions[$x_time]['msg'] = $msg;
230
+        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
231
+        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
232
+        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
233 233
         self::$_error_count++;
234 234
         // add_action( 'shutdown', array( $this, 'display_errors' ));
235 235
         $this->display_errors();
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function has_error($check_stored = false, $type_to_check = 'errors')
249 249
     {
250
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
250
+        $has_error = isset(self::$_espresso_notices[$type_to_check])
251
+                     && ! empty(self::$_espresso_notices[$type_to_check])
252 252
             ? true
253 253
             : false;
254 254
         if ($check_stored && ! $has_error) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 </style>
328 328
 <div id="ee-error-message" class="error">';
329
-        if (! WP_DEBUG) {
329
+        if ( ! WP_DEBUG) {
330 330
             $output .= '
331 331
 	<p>';
332 332
         }
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
                     $class_dsply = ! empty($class) ? $class : '&nbsp;';
386 386
                     $type_dsply = ! empty($type) ? $type : '&nbsp;';
387 387
                     $function_dsply = ! empty($function) ? $function : '&nbsp;';
388
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
388
+                    $args_dsply = ! empty($args) ? '( '.$args.' )' : '';
389 389
                     $trace_details .= '
390 390
 					<tr>
391
-						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
392
-						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
393
-						<td align="left" class="' . $zebra . '">' . $file_dsply . '</td>
394
-						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
395
-						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
391
+						<td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td>
392
+						<td align="right" class="' . $zebra.'">'.$line_dsply.'</td>
393
+						<td align="left" class="' . $zebra.'">'.$file_dsply.'</td>
394
+						<td align="left" class="' . $zebra.'">'.$class_dsply.'</td>
395
+						<td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td>
396 396
 					</tr>';
397 397
                 }
398 398
                 $trace_details .= '
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             }
402 402
             $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403 403
             // add generic non-identifying messages for non-privileged users
404
-            if (! WP_DEBUG) {
404
+            if ( ! WP_DEBUG) {
405 405
                 $output .= '<span class="ee-error-user-msg-spn">'
406 406
                            . trim($ex['msg'])
407 407
                            . '</span> &nbsp; <sup>'
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
                            . '-dv" class="ee-error-trace-dv" style="display: none;">
444 444
 				'
445 445
                            . $trace_details;
446
-                if (! empty($class)) {
446
+                if ( ! empty($class)) {
447 447
                     $output .= '
448 448
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
449 449
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
450 450
 						<h3>Class Details</h3>';
451 451
                     $a = new ReflectionClass($class);
452 452
                     $output .= '
453
-						<pre>' . $a . '</pre>
453
+						<pre>' . $a.'</pre>
454 454
 					</div>
455 455
 				</div>';
456 456
                 }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         }
464 464
         // remove last linebreak
465 465
         $output = substr($output, 0, -6);
466
-        if (! WP_DEBUG) {
466
+        if ( ! WP_DEBUG) {
467 467
             $output .= '
468 468
 	</p>';
469 469
         }
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
     private function _convert_args_to_string($arguments = array(), $array = false)
490 490
     {
491 491
         $arg_string = '';
492
-        if (! empty($arguments)) {
492
+        if ( ! empty($arguments)) {
493 493
             $args = array();
494 494
             foreach ($arguments as $arg) {
495
-                if (! empty($arg)) {
495
+                if ( ! empty($arg)) {
496 496
                     if (is_string($arg)) {
497
-                        $args[] = " '" . $arg . "'";
497
+                        $args[] = " '".$arg."'";
498 498
                     } elseif (is_array($arg)) {
499
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
+                        $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, true);
500 500
                     } elseif ($arg === null) {
501 501
                         $args[] = ' NULL';
502 502
                     } elseif (is_bool($arg)) {
503 503
                         $args[] = ($arg) ? ' TRUE' : ' FALSE';
504 504
                     } elseif (is_object($arg)) {
505
-                        $args[] = ' OBJECT ' . get_class($arg);
505
+                        $args[] = ' OBJECT '.get_class($arg);
506 506
                     } elseif (is_resource($arg)) {
507 507
                         $args[] = get_resource_type($arg);
508 508
                     } else {
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     {
601 601
         if (empty($msg)) {
602 602
             EE_Error::doing_it_wrong(
603
-                'EE_Error::add_' . $type . '()',
603
+                'EE_Error::add_'.$type.'()',
604 604
                 sprintf(
605 605
                     esc_html__(
606 606
                         'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
@@ -640,17 +640,17 @@  discard block
 block discarded – undo
640 640
         do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641 641
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
642 642
         // add notice if message exists
643
-        if (! empty($msg)) {
643
+        if ( ! empty($msg)) {
644 644
             // get error code
645 645
             $notice_code = EE_Error::generate_error_code($file, $func, $line);
646 646
             if (WP_DEBUG && $type === 'errors') {
647
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
647
+                $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>';
648 648
             }
649 649
             // add notice. Index by code if it's not blank
650 650
             if ($notice_code) {
651
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
651
+                self::$_espresso_notices[$type][$notice_code] = $msg;
652 652
             } else {
653
-                self::$_espresso_notices[ $type ][] = $msg;
653
+                self::$_espresso_notices[$type][] = $msg;
654 654
             }
655 655
             add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656 656
         }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
                 ? esc_html__('The following errors have occurred:', 'event_espresso')
885 885
                 : esc_html__('An error has occurred:', 'event_espresso');
886 886
             // combine messages
887
-            $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
887
+            $error_messages .= '<br />'.implode('<br />', self::$_espresso_notices['errors']);
888 888
             $print_scripts = true;
889 889
         }
890 890
         if ($format_output) {
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
                 // remove empty notices
904 904
                 foreach ($notices as $type => $notice) {
905 905
                     if (empty($notice)) {
906
-                        unset($notices[ $type ]);
906
+                        unset($notices[$type]);
907 907
                     }
908 908
                 }
909 909
             }
@@ -926,16 +926,16 @@  discard block
 block discarded – undo
926 926
         $print_scripts = false;
927 927
         // grab any notices that have been previously saved
928 928
         $notices = EE_Error::getStoredNotices();
929
-        if (! empty($notices)) {
929
+        if ( ! empty($notices)) {
930 930
             foreach ($notices as $type => $notice) {
931 931
                 if (is_array($notice) && ! empty($notice)) {
932 932
                     // make sure that existing notice type is an array
933
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
-                                                        && ! empty(self::$_espresso_notices[ $type ])
935
-                        ? self::$_espresso_notices[ $type ]
933
+                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
934
+                                                        && ! empty(self::$_espresso_notices[$type])
935
+                        ? self::$_espresso_notices[$type]
936 936
                         : array();
937 937
                     // add newly created notices to existing ones
938
-                    self::$_espresso_notices[ $type ] += $notice;
938
+                    self::$_espresso_notices[$type] += $notice;
939 939
                     $print_scripts = true;
940 940
                 }
941 941
             }
@@ -962,10 +962,10 @@  discard block
 block discarded – undo
962 962
             $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963 963
             $css_class = is_admin() ? 'updated fade' : 'success fade-away';
964 964
             // showMessage( $success_messages );
965
-            $notices .= '<div id="' . $css_id . '" '
966
-                        . 'class="espresso-notices ' . $css_class . '" '
965
+            $notices .= '<div id="'.$css_id.'" '
966
+                        . 'class="espresso-notices '.$css_class.'" '
967 967
                         . 'style="display:none;">'
968
-                        . '<p>' . $success_messages . '</p>'
968
+                        . '<p>'.$success_messages.'</p>'
969 969
                         . $close
970 970
                         . '</div>';
971 971
         }
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
             $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974 974
             $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975 975
             // showMessage( $error_messages, TRUE );
976
-            $notices .= '<div id="' . $css_id . '" '
977
-                        . 'class="espresso-notices ' . $css_class . '" '
976
+            $notices .= '<div id="'.$css_id.'" '
977
+                        . 'class="espresso-notices '.$css_class.'" '
978 978
                         . 'style="display:none;">'
979
-                        . '<p>' . $attention_messages . '</p>'
979
+                        . '<p>'.$attention_messages.'</p>'
980 980
                         . $close
981 981
                         . '</div>';
982 982
         }
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
             $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985 985
             $css_class = is_admin() ? 'error' : 'error fade-away';
986 986
             // showMessage( $error_messages, TRUE );
987
-            $notices .= '<div id="' . $css_id . '" '
988
-                        . 'class="espresso-notices ' . $css_class . '" '
987
+            $notices .= '<div id="'.$css_id.'" '
988
+                        . 'class="espresso-notices '.$css_class.'" '
989 989
                         . 'style="display:none;">'
990
-                        . '<p>' . $error_messages . '</p>'
990
+                        . '<p>'.$error_messages.'</p>'
991 991
                         . $close
992 992
                         . '</div>';
993 993
         }
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      */
1005 1005
     private static function _print_scripts($force_print = false)
1006 1006
     {
1007
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1007
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008 1008
             if (wp_script_is('ee_error_js', 'registered')) {
1009 1009
                 wp_enqueue_style('espresso_default');
1010 1010
                 wp_enqueue_style('espresso_custom_css');
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
             return '
1019 1019
 <script>
1020 1020
 /* <![CDATA[ */
1021
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
1021
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
1022 1022
 /* ]]> */
1023 1023
 </script>
1024
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
1025
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1026
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1024
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
1025
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1026
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1027 1027
 ';
1028 1028
         }
1029 1029
         return '';
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
     {
1053 1053
         $file = explode('.', basename($file));
1054 1054
         $error_code = ! empty($file[0]) ? $file[0] : '';
1055
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1056
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1055
+        $error_code .= ! empty($func) ? ' - '.$func : '';
1056
+        $error_code .= ! empty($line) ? ' - '.$line : '';
1057 1057
         return $error_code;
1058 1058
     }
1059 1059
 
@@ -1072,18 +1072,18 @@  discard block
 block discarded – undo
1072 1072
         if (empty($ex)) {
1073 1073
             return;
1074 1074
         }
1075
-        if (! $time) {
1075
+        if ( ! $time) {
1076 1076
             $time = time();
1077 1077
         }
1078 1078
         $exception_log = '----------------------------------------------------------------------------------------'
1079 1079
                          . PHP_EOL;
1080
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1086
-        $exception_log .= $ex['string'] . PHP_EOL;
1080
+        $exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
1081
+        $exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
1082
+        $exception_log .= 'Code: '.$ex['code'].PHP_EOL;
1083
+        $exception_log .= 'File: '.$ex['file'].PHP_EOL;
1084
+        $exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
1085
+        $exception_log .= 'Stack trace: '.PHP_EOL;
1086
+        $exception_log .= $ex['string'].PHP_EOL;
1087 1087
         $exception_log .= '----------------------------------------------------------------------------------------'
1088 1088
                           . PHP_EOL;
1089 1089
         try {
@@ -1255,13 +1255,13 @@  discard block
 block discarded – undo
1255 1255
     // js for error handling
1256 1256
     wp_register_script(
1257 1257
         'espresso_core',
1258
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1258
+        EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
1259 1259
         array('jquery'),
1260 1260
         EVENT_ESPRESSO_VERSION
1261 1261
     );
1262 1262
     wp_register_script(
1263 1263
         'ee_error_js',
1264
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1264
+        EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
1265 1265
         array('espresso_core'),
1266 1266
         EVENT_ESPRESSO_VERSION
1267 1267
     );
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.019');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.019');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.