@@ -20,163 +20,163 @@ discard block |
||
| 20 | 20 | class ExceptionStackTraceDisplay |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var string |
|
| 25 | - * @since 4.10.24.p |
|
| 26 | - */ |
|
| 27 | - private $class_name = ''; |
|
| 23 | + /** |
|
| 24 | + * @var string |
|
| 25 | + * @since 4.10.24.p |
|
| 26 | + */ |
|
| 27 | + private $class_name = ''; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - * @since 4.10.24.p |
|
| 32 | - */ |
|
| 33 | - private $error_code = ''; |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + * @since 4.10.24.p |
|
| 32 | + */ |
|
| 33 | + private $error_code = ''; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param Exception $exception |
|
| 38 | - * @throws Exception |
|
| 39 | - */ |
|
| 40 | - public function __construct(Exception $exception) |
|
| 41 | - { |
|
| 42 | - if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
| 43 | - $this->displayException($exception); |
|
| 44 | - } else { |
|
| 45 | - throw $exception; |
|
| 46 | - } |
|
| 47 | - } |
|
| 36 | + /** |
|
| 37 | + * @param Exception $exception |
|
| 38 | + * @throws Exception |
|
| 39 | + */ |
|
| 40 | + public function __construct(Exception $exception) |
|
| 41 | + { |
|
| 42 | + if (WP_DEBUG && ! defined('EE_TESTS_DIR')) { |
|
| 43 | + $this->displayException($exception); |
|
| 44 | + } else { |
|
| 45 | + throw $exception; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @access protected |
|
| 52 | - * @param Exception $exception |
|
| 53 | - * @throws ReflectionException |
|
| 54 | - */ |
|
| 55 | - protected function displayException(Exception $exception) |
|
| 56 | - { |
|
| 57 | - // get separate user and developer messages if they exist |
|
| 58 | - $msg = explode('||', $exception->getMessage()); |
|
| 59 | - $user_msg = $msg[0]; |
|
| 60 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 61 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
| 62 | - // process trace info |
|
| 63 | - $trace_details = $this->traceDetails($exception); |
|
| 64 | - $code = $exception->getCode() ?: $this->error_code; |
|
| 65 | - // add helpful developer messages if debugging is on |
|
| 66 | - // or generic non-identifying messages for non-privileged users |
|
| 67 | - $error_message = WP_DEBUG |
|
| 68 | - ? $this->developerError($exception, $msg, $code, $trace_details) |
|
| 69 | - : $this->genericError($msg, $code); |
|
| 70 | - // start gathering output |
|
| 71 | - $output = ' |
|
| 50 | + /** |
|
| 51 | + * @access protected |
|
| 52 | + * @param Exception $exception |
|
| 53 | + * @throws ReflectionException |
|
| 54 | + */ |
|
| 55 | + protected function displayException(Exception $exception) |
|
| 56 | + { |
|
| 57 | + // get separate user and developer messages if they exist |
|
| 58 | + $msg = explode('||', $exception->getMessage()); |
|
| 59 | + $user_msg = $msg[0]; |
|
| 60 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 61 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
| 62 | + // process trace info |
|
| 63 | + $trace_details = $this->traceDetails($exception); |
|
| 64 | + $code = $exception->getCode() ?: $this->error_code; |
|
| 65 | + // add helpful developer messages if debugging is on |
|
| 66 | + // or generic non-identifying messages for non-privileged users |
|
| 67 | + $error_message = WP_DEBUG |
|
| 68 | + ? $this->developerError($exception, $msg, $code, $trace_details) |
|
| 69 | + : $this->genericError($msg, $code); |
|
| 70 | + // start gathering output |
|
| 71 | + $output = ' |
|
| 72 | 72 | <div id="ee-error-message" class="error"> |
| 73 | 73 | ' . $error_message . ' |
| 74 | 74 | </div>'; |
| 75 | - $scripts = $this->printScripts(true); |
|
| 76 | - if (defined('DOING_AJAX')) { |
|
| 77 | - echo wp_json_encode(array('error' => $output . $scripts)); |
|
| 78 | - exit(); |
|
| 79 | - } |
|
| 80 | - echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags()); |
|
| 81 | - } |
|
| 75 | + $scripts = $this->printScripts(true); |
|
| 76 | + if (defined('DOING_AJAX')) { |
|
| 77 | + echo wp_json_encode(array('error' => $output . $scripts)); |
|
| 78 | + exit(); |
|
| 79 | + } |
|
| 80 | + echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags()); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | - private function genericError($msg, $code) |
|
| 85 | - { |
|
| 86 | - return ' |
|
| 84 | + private function genericError($msg, $code) |
|
| 85 | + { |
|
| 86 | + return ' |
|
| 87 | 87 | <p> |
| 88 | 88 | <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> <sup>' . $code . '</sup> |
| 89 | 89 | </p>'; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @param Exception $exception |
|
| 95 | - * @param $msg |
|
| 96 | - * @param $code |
|
| 97 | - * @param $trace_details |
|
| 98 | - * @return string |
|
| 99 | - * @throws ReflectionException |
|
| 100 | - */ |
|
| 101 | - private function developerError(Exception $exception, $msg, $code, $trace_details) |
|
| 102 | - { |
|
| 103 | - $time = time(); |
|
| 104 | - return ' |
|
| 93 | + /** |
|
| 94 | + * @param Exception $exception |
|
| 95 | + * @param $msg |
|
| 96 | + * @param $code |
|
| 97 | + * @param $trace_details |
|
| 98 | + * @return string |
|
| 99 | + * @throws ReflectionException |
|
| 100 | + */ |
|
| 101 | + private function developerError(Exception $exception, $msg, $code, $trace_details) |
|
| 102 | + { |
|
| 103 | + $time = time(); |
|
| 104 | + return ' |
|
| 105 | 105 | <div class="ee-error-dev-msg-dv"> |
| 106 | 106 | <p class="ee-error-dev-msg-pg"> |
| 107 | 107 | ' |
| 108 | - . sprintf( |
|
| 109 | - esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
| 110 | - '<strong class="ee-error-dev-msg-str">', |
|
| 111 | - get_class($exception), |
|
| 112 | - '</strong> <span>', |
|
| 113 | - $code . '</span>' |
|
| 114 | - ) |
|
| 115 | - . '<br /> |
|
| 108 | + . sprintf( |
|
| 109 | + esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
| 110 | + '<strong class="ee-error-dev-msg-str">', |
|
| 111 | + get_class($exception), |
|
| 112 | + '</strong> <span>', |
|
| 113 | + $code . '</span>' |
|
| 114 | + ) |
|
| 115 | + . '<br /> |
|
| 116 | 116 | <span class="big-text">"' . trim($msg) . '"</span><br/> |
| 117 | 117 | <a id="display-ee-error-trace-1' |
| 118 | - . $time |
|
| 119 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
| 120 | - . $time |
|
| 121 | - . '"> |
|
| 118 | + . $time |
|
| 119 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
|
| 120 | + . $time |
|
| 121 | + . '"> |
|
| 122 | 122 | ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . ' |
| 123 | 123 | </a><br /> |
| 124 | 124 | ' |
| 125 | - . $exception->getFile() |
|
| 126 | - . sprintf( |
|
| 127 | - esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
| 128 | - ' <span class="small-text lt-grey-text">', |
|
| 129 | - $exception->getLine(), |
|
| 130 | - '</span>' |
|
| 131 | - ) |
|
| 132 | - . ' |
|
| 125 | + . $exception->getFile() |
|
| 126 | + . sprintf( |
|
| 127 | + esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
| 128 | + ' <span class="small-text lt-grey-text">', |
|
| 129 | + $exception->getLine(), |
|
| 130 | + '</span>' |
|
| 131 | + ) |
|
| 132 | + . ' |
|
| 133 | 133 | </p> |
| 134 | 134 | <div id="ee-error-trace-1' |
| 135 | - . $time |
|
| 136 | - . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden"> |
|
| 135 | + . $time |
|
| 136 | + . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden"> |
|
| 137 | 137 | ' |
| 138 | - . $trace_details |
|
| 139 | - . $this->classDetails() . ' |
|
| 138 | + . $trace_details |
|
| 139 | + . $this->classDetails() . ' |
|
| 140 | 140 | </div> |
| 141 | 141 | </div>'; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * @throws ReflectionException |
|
| 147 | - */ |
|
| 148 | - private function classDetails() |
|
| 149 | - { |
|
| 150 | - if (empty($this->class_name)) { |
|
| 151 | - return ''; |
|
| 152 | - } |
|
| 153 | - $a = new ReflectionClass($this->class_name); |
|
| 154 | - return ' |
|
| 145 | + /** |
|
| 146 | + * @throws ReflectionException |
|
| 147 | + */ |
|
| 148 | + private function classDetails() |
|
| 149 | + { |
|
| 150 | + if (empty($this->class_name)) { |
|
| 151 | + return ''; |
|
| 152 | + } |
|
| 153 | + $a = new ReflectionClass($this->class_name); |
|
| 154 | + return ' |
|
| 155 | 155 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
| 156 | 156 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
| 157 | 157 | <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3> |
| 158 | 158 | <pre>' . $a . '</pre> |
| 159 | 159 | </div> |
| 160 | 160 | </div>'; |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * @param Exception $exception |
|
| 165 | - * @return string |
|
| 166 | - * @throws ReflectionException |
|
| 167 | - * @since 4.10.24.p |
|
| 168 | - */ |
|
| 169 | - private function traceDetails(Exception $exception) |
|
| 170 | - { |
|
| 171 | - $trace = $exception->getTrace(); |
|
| 172 | - if (empty($trace)) { |
|
| 173 | - return esc_html__( |
|
| 174 | - 'Sorry, but no trace information was available for this exception.', |
|
| 175 | - 'event_espresso' |
|
| 176 | - ); |
|
| 177 | - } |
|
| 163 | + /** |
|
| 164 | + * @param Exception $exception |
|
| 165 | + * @return string |
|
| 166 | + * @throws ReflectionException |
|
| 167 | + * @since 4.10.24.p |
|
| 168 | + */ |
|
| 169 | + private function traceDetails(Exception $exception) |
|
| 170 | + { |
|
| 171 | + $trace = $exception->getTrace(); |
|
| 172 | + if (empty($trace)) { |
|
| 173 | + return esc_html__( |
|
| 174 | + 'Sorry, but no trace information was available for this exception.', |
|
| 175 | + 'event_espresso' |
|
| 176 | + ); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - $trace_details = ' |
|
| 179 | + $trace_details = ' |
|
| 180 | 180 | <div id="ee-trace-details"> |
| 181 | 181 | <table> |
| 182 | 182 | <tr> |
@@ -185,180 +185,180 @@ discard block |
||
| 185 | 185 | <th scope="col" class="ee-align-left" style="width:40%;">File</th> |
| 186 | 186 | <th scope="col" class="ee-align-left"> |
| 187 | 187 | ' . esc_html__('Class', 'event_espresso') |
| 188 | - . '->' |
|
| 189 | - . esc_html__('Method( arguments )', 'event_espresso') . ' |
|
| 188 | + . '->' |
|
| 189 | + . esc_html__('Method( arguments )', 'event_espresso') . ' |
|
| 190 | 190 | </th> |
| 191 | 191 | </tr>'; |
| 192 | - $last_on_stack = count($trace) - 1; |
|
| 193 | - // reverse array so that stack is in proper chronological order |
|
| 194 | - $sorted_trace = array_reverse($trace); |
|
| 195 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
| 196 | - $this->class_name = isset($trace['class']) ? $trace['class'] : ''; |
|
| 197 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
| 198 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
| 199 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
| 200 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
| 201 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
| 202 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
| 203 | - if (empty($file) && ! empty($this->class_name)) { |
|
| 204 | - $a = new ReflectionClass($this->class_name); |
|
| 205 | - $file = $a->getFileName(); |
|
| 206 | - if (empty($line) && ! empty($function)) { |
|
| 207 | - try { |
|
| 208 | - // if $function is a closure, this throws an exception |
|
| 209 | - $b = new ReflectionMethod($this->class_name, $function); |
|
| 210 | - $line = $b->getStartLine(); |
|
| 211 | - } catch (Exception $closure_exception) { |
|
| 212 | - $line = 'unknown'; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - if ($nmbr === $last_on_stack) { |
|
| 217 | - $file = $exception->getFile() ?: $file; |
|
| 218 | - $line = $exception->getLine() ?: $line; |
|
| 219 | - $this->error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
| 220 | - } |
|
| 221 | - $file = EEH_File::standardise_directory_separators($file); |
|
| 222 | - $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
| 223 | - $line = ! empty($line) ? $line : ' '; |
|
| 224 | - $file = ! empty($file) ? $file : ' '; |
|
| 225 | - $type = ! empty($type) ? $type : ''; |
|
| 226 | - $function = ! empty($function) ? $function : ''; |
|
| 227 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
| 228 | - $trace_details .= ' |
|
| 192 | + $last_on_stack = count($trace) - 1; |
|
| 193 | + // reverse array so that stack is in proper chronological order |
|
| 194 | + $sorted_trace = array_reverse($trace); |
|
| 195 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
| 196 | + $this->class_name = isset($trace['class']) ? $trace['class'] : ''; |
|
| 197 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
| 198 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
| 199 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
| 200 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
| 201 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
| 202 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
| 203 | + if (empty($file) && ! empty($this->class_name)) { |
|
| 204 | + $a = new ReflectionClass($this->class_name); |
|
| 205 | + $file = $a->getFileName(); |
|
| 206 | + if (empty($line) && ! empty($function)) { |
|
| 207 | + try { |
|
| 208 | + // if $function is a closure, this throws an exception |
|
| 209 | + $b = new ReflectionMethod($this->class_name, $function); |
|
| 210 | + $line = $b->getStartLine(); |
|
| 211 | + } catch (Exception $closure_exception) { |
|
| 212 | + $line = 'unknown'; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + if ($nmbr === $last_on_stack) { |
|
| 217 | + $file = $exception->getFile() ?: $file; |
|
| 218 | + $line = $exception->getLine() ?: $line; |
|
| 219 | + $this->error_code = $this->generate_error_code($file, $trace['function'], $line); |
|
| 220 | + } |
|
| 221 | + $file = EEH_File::standardise_directory_separators($file); |
|
| 222 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
| 223 | + $line = ! empty($line) ? $line : ' '; |
|
| 224 | + $file = ! empty($file) ? $file : ' '; |
|
| 225 | + $type = ! empty($type) ? $type : ''; |
|
| 226 | + $function = ! empty($function) ? $function : ''; |
|
| 227 | + $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
| 228 | + $trace_details .= ' |
|
| 229 | 229 | <tr> |
| 230 | 230 | <td class="ee-align-right">' . $nmbr . '</td> |
| 231 | 231 | <td class="ee-align-right">' . $line . '</td> |
| 232 | 232 | <td class="ee-align-left">' . $file . '</td> |
| 233 | 233 | <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td> |
| 234 | 234 | </tr>'; |
| 235 | - } |
|
| 236 | - $trace_details .= ' |
|
| 235 | + } |
|
| 236 | + $trace_details .= ' |
|
| 237 | 237 | </table> |
| 238 | 238 | </div>'; |
| 239 | - return $trace_details; |
|
| 240 | - } |
|
| 239 | + return $trace_details; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 244 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
| 243 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 244 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * generate string from exception trace args |
|
| 248 | - * |
|
| 249 | - * @param array $arguments |
|
| 250 | - * @param int $indent |
|
| 251 | - * @param bool $array |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 254 | - private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
| 255 | - { |
|
| 256 | - $args = array(); |
|
| 257 | - $args_count = count($arguments); |
|
| 258 | - if ($args_count > 2) { |
|
| 259 | - $indent++; |
|
| 260 | - $args[] = '<br />'; |
|
| 261 | - } |
|
| 262 | - $x = 0; |
|
| 263 | - foreach ($arguments as $arg) { |
|
| 264 | - $x++; |
|
| 265 | - for ($i = 0; $i < $indent; $i++) { |
|
| 266 | - $args[] = ' '; |
|
| 267 | - } |
|
| 268 | - if (is_string($arg)) { |
|
| 269 | - if (! $array && strlen($arg) > 75) { |
|
| 270 | - $args[] = '<br />'; |
|
| 271 | - for ($i = 0; $i <= $indent; $i++) { |
|
| 272 | - $args[] = ' '; |
|
| 273 | - } |
|
| 274 | - $args[] = "'" . $arg . "'<br />"; |
|
| 275 | - } else { |
|
| 276 | - $args[] = " '" . $arg . "'"; |
|
| 277 | - } |
|
| 278 | - } elseif (is_array($arg)) { |
|
| 279 | - $arg_count = count($arg); |
|
| 280 | - if ($arg_count > 2) { |
|
| 281 | - $indent++; |
|
| 282 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
| 283 | - $indent--; |
|
| 284 | - } elseif ($arg_count === 0) { |
|
| 285 | - $args[] = ' array()'; |
|
| 286 | - } else { |
|
| 287 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
| 288 | - } |
|
| 289 | - } elseif ($arg === null) { |
|
| 290 | - $args[] = ' null'; |
|
| 291 | - } elseif (is_bool($arg)) { |
|
| 292 | - $args[] = $arg ? ' true' : ' false'; |
|
| 293 | - } elseif (is_object($arg)) { |
|
| 294 | - $args[] = get_class($arg); |
|
| 295 | - } elseif (is_resource($arg)) { |
|
| 296 | - $args[] = get_resource_type($arg); |
|
| 297 | - } else { |
|
| 298 | - $args[] = $arg; |
|
| 299 | - } |
|
| 300 | - if ($x === $args_count) { |
|
| 301 | - if ($args_count > 2) { |
|
| 302 | - $args[] = '<br />'; |
|
| 303 | - $indent--; |
|
| 304 | - for ($i = 1; $i < $indent; $i++) { |
|
| 305 | - $args[] = ' '; |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - } else { |
|
| 309 | - $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - return implode('', $args); |
|
| 313 | - } |
|
| 246 | + /** |
|
| 247 | + * generate string from exception trace args |
|
| 248 | + * |
|
| 249 | + * @param array $arguments |
|
| 250 | + * @param int $indent |
|
| 251 | + * @param bool $array |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) |
|
| 255 | + { |
|
| 256 | + $args = array(); |
|
| 257 | + $args_count = count($arguments); |
|
| 258 | + if ($args_count > 2) { |
|
| 259 | + $indent++; |
|
| 260 | + $args[] = '<br />'; |
|
| 261 | + } |
|
| 262 | + $x = 0; |
|
| 263 | + foreach ($arguments as $arg) { |
|
| 264 | + $x++; |
|
| 265 | + for ($i = 0; $i < $indent; $i++) { |
|
| 266 | + $args[] = ' '; |
|
| 267 | + } |
|
| 268 | + if (is_string($arg)) { |
|
| 269 | + if (! $array && strlen($arg) > 75) { |
|
| 270 | + $args[] = '<br />'; |
|
| 271 | + for ($i = 0; $i <= $indent; $i++) { |
|
| 272 | + $args[] = ' '; |
|
| 273 | + } |
|
| 274 | + $args[] = "'" . $arg . "'<br />"; |
|
| 275 | + } else { |
|
| 276 | + $args[] = " '" . $arg . "'"; |
|
| 277 | + } |
|
| 278 | + } elseif (is_array($arg)) { |
|
| 279 | + $arg_count = count($arg); |
|
| 280 | + if ($arg_count > 2) { |
|
| 281 | + $indent++; |
|
| 282 | + $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
| 283 | + $indent--; |
|
| 284 | + } elseif ($arg_count === 0) { |
|
| 285 | + $args[] = ' array()'; |
|
| 286 | + } else { |
|
| 287 | + $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
| 288 | + } |
|
| 289 | + } elseif ($arg === null) { |
|
| 290 | + $args[] = ' null'; |
|
| 291 | + } elseif (is_bool($arg)) { |
|
| 292 | + $args[] = $arg ? ' true' : ' false'; |
|
| 293 | + } elseif (is_object($arg)) { |
|
| 294 | + $args[] = get_class($arg); |
|
| 295 | + } elseif (is_resource($arg)) { |
|
| 296 | + $args[] = get_resource_type($arg); |
|
| 297 | + } else { |
|
| 298 | + $args[] = $arg; |
|
| 299 | + } |
|
| 300 | + if ($x === $args_count) { |
|
| 301 | + if ($args_count > 2) { |
|
| 302 | + $args[] = '<br />'; |
|
| 303 | + $indent--; |
|
| 304 | + for ($i = 1; $i < $indent; $i++) { |
|
| 305 | + $args[] = ' '; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + } else { |
|
| 309 | + $args[] = $args_count > 2 ? ',<br />' : ', '; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + return implode('', $args); |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | |
| 316 | - /** |
|
| 317 | - * create error code from filepath, function name, |
|
| 318 | - * and line number where exception or error was thrown |
|
| 319 | - * |
|
| 320 | - * @access protected |
|
| 321 | - * @param string $file |
|
| 322 | - * @param string $func |
|
| 323 | - * @param string $line |
|
| 324 | - * @return string |
|
| 325 | - */ |
|
| 326 | - protected function generate_error_code($file = '', $func = '', $line = '') |
|
| 327 | - { |
|
| 328 | - $file_bits = explode('.', basename($file)); |
|
| 329 | - $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
| 330 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
| 331 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
| 332 | - return $error_code; |
|
| 333 | - } |
|
| 316 | + /** |
|
| 317 | + * create error code from filepath, function name, |
|
| 318 | + * and line number where exception or error was thrown |
|
| 319 | + * |
|
| 320 | + * @access protected |
|
| 321 | + * @param string $file |
|
| 322 | + * @param string $func |
|
| 323 | + * @param string $line |
|
| 324 | + * @return string |
|
| 325 | + */ |
|
| 326 | + protected function generate_error_code($file = '', $func = '', $line = '') |
|
| 327 | + { |
|
| 328 | + $file_bits = explode('.', basename($file)); |
|
| 329 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
| 330 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
| 331 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
| 332 | + return $error_code; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | |
| 336 | - /** |
|
| 337 | - * _print_scripts |
|
| 338 | - * |
|
| 339 | - * @param bool $force_print |
|
| 340 | - * @return string |
|
| 341 | - */ |
|
| 342 | - private function printScripts($force_print = false) |
|
| 343 | - { |
|
| 344 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
| 345 | - // if script is already enqueued then we can just get out |
|
| 346 | - if (wp_script_is('ee_error_js')) { |
|
| 347 | - return ''; |
|
| 348 | - } |
|
| 349 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
| 350 | - wp_enqueue_style('espresso_default'); |
|
| 351 | - wp_enqueue_style('espresso_custom_css'); |
|
| 352 | - wp_enqueue_script('ee_error_js'); |
|
| 353 | - wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
| 354 | - return ''; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - $jquery = includes_url() . 'js/jquery/jquery.js'; |
|
| 358 | - $core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version(); |
|
| 359 | - $ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version(); |
|
| 360 | - $style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css'; |
|
| 361 | - return ' |
|
| 336 | + /** |
|
| 337 | + * _print_scripts |
|
| 338 | + * |
|
| 339 | + * @param bool $force_print |
|
| 340 | + * @return string |
|
| 341 | + */ |
|
| 342 | + private function printScripts($force_print = false) |
|
| 343 | + { |
|
| 344 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
| 345 | + // if script is already enqueued then we can just get out |
|
| 346 | + if (wp_script_is('ee_error_js')) { |
|
| 347 | + return ''; |
|
| 348 | + } |
|
| 349 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
| 350 | + wp_enqueue_style('espresso_default'); |
|
| 351 | + wp_enqueue_style('espresso_custom_css'); |
|
| 352 | + wp_enqueue_script('ee_error_js'); |
|
| 353 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
| 354 | + return ''; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + $jquery = includes_url() . 'js/jquery/jquery.js'; |
|
| 358 | + $core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version(); |
|
| 359 | + $ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version(); |
|
| 360 | + $style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css'; |
|
| 361 | + return ' |
|
| 362 | 362 | <script> |
| 363 | 363 | const ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
| 364 | 364 | </script> |
@@ -367,5 +367,5 @@ discard block |
||
| 367 | 367 | <script src="' . esc_url_raw($ee_error) . '" type="text/javascript"></script> |
| 368 | 368 | <link href="' . esc_url_raw($style) . '" rel="stylesheet" /> |
| 369 | 369 | '; |
| 370 | - } |
|
| 370 | + } |
|
| 371 | 371 | } |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | // start gathering output |
| 71 | 71 | $output = ' |
| 72 | 72 | <div id="ee-error-message" class="error"> |
| 73 | - ' . $error_message . ' |
|
| 73 | + ' . $error_message.' |
|
| 74 | 74 | </div>'; |
| 75 | 75 | $scripts = $this->printScripts(true); |
| 76 | 76 | if (defined('DOING_AJAX')) { |
| 77 | - echo wp_json_encode(array('error' => $output . $scripts)); |
|
| 77 | + echo wp_json_encode(array('error' => $output.$scripts)); |
|
| 78 | 78 | exit(); |
| 79 | 79 | } |
| 80 | - echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags()); |
|
| 80 | + echo wp_kses($output.$scripts, AllowedTags::getWithScriptAndStyleTags()); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | return ' |
| 87 | 87 | <p> |
| 88 | - <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> <sup>' . $code . '</sup> |
|
| 88 | + <span class="ee-error-user-msg-spn">' . trim($msg).'</span> <sup>'.$code.'</sup> |
|
| 89 | 89 | </p>'; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | '<strong class="ee-error-dev-msg-str">', |
| 111 | 111 | get_class($exception), |
| 112 | 112 | '</strong> <span>', |
| 113 | - $code . '</span>' |
|
| 113 | + $code.'</span>' |
|
| 114 | 114 | ) |
| 115 | 115 | . '<br /> |
| 116 | - <span class="big-text">"' . trim($msg) . '"</span><br/> |
|
| 116 | + <span class="big-text">"' . trim($msg).'"</span><br/> |
|
| 117 | 117 | <a id="display-ee-error-trace-1' |
| 118 | 118 | . $time |
| 119 | 119 | . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1' |
| 120 | 120 | . $time |
| 121 | 121 | . '"> |
| 122 | - ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . ' |
|
| 122 | + ' . esc_html__('click to view backtrace and class/method details', 'event_espresso').' |
|
| 123 | 123 | </a><br /> |
| 124 | 124 | ' |
| 125 | 125 | . $exception->getFile() |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden"> |
| 137 | 137 | ' |
| 138 | 138 | . $trace_details |
| 139 | - . $this->classDetails() . ' |
|
| 139 | + . $this->classDetails().' |
|
| 140 | 140 | </div> |
| 141 | 141 | </div>'; |
| 142 | 142 | } |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | return ' |
| 155 | 155 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
| 156 | 156 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
| 157 | - <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3> |
|
| 158 | - <pre>' . $a . '</pre> |
|
| 157 | + <h3>' . esc_html__('Class Details', 'event_espresso').'</h3> |
|
| 158 | + <pre>' . $a.'</pre> |
|
| 159 | 159 | </div> |
| 160 | 160 | </div>'; |
| 161 | 161 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | <th scope="col" class="ee-align-left"> |
| 187 | 187 | ' . esc_html__('Class', 'event_espresso') |
| 188 | 188 | . '->' |
| 189 | - . esc_html__('Method( arguments )', 'event_espresso') . ' |
|
| 189 | + . esc_html__('Method( arguments )', 'event_espresso').' |
|
| 190 | 190 | </th> |
| 191 | 191 | </tr>'; |
| 192 | 192 | $last_on_stack = count($trace) - 1; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $type = isset($trace['type']) ? $trace['type'] : ''; |
| 199 | 199 | $function = isset($trace['function']) ? $trace['function'] : ''; |
| 200 | 200 | $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
| 201 | - $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
| 201 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
| 202 | 202 | $line = isset($trace['line']) ? $trace['line'] : ''; |
| 203 | 203 | if (empty($file) && ! empty($this->class_name)) { |
| 204 | 204 | $a = new ReflectionClass($this->class_name); |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | $file = ! empty($file) ? $file : ' '; |
| 225 | 225 | $type = ! empty($type) ? $type : ''; |
| 226 | 226 | $function = ! empty($function) ? $function : ''; |
| 227 | - $args = ! empty($args) ? '( ' . $args . ' )' : '()'; |
|
| 227 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
| 228 | 228 | $trace_details .= ' |
| 229 | 229 | <tr> |
| 230 | - <td class="ee-align-right">' . $nmbr . '</td> |
|
| 231 | - <td class="ee-align-right">' . $line . '</td> |
|
| 232 | - <td class="ee-align-left">' . $file . '</td> |
|
| 233 | - <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td> |
|
| 230 | + <td class="ee-align-right">' . $nmbr.'</td> |
|
| 231 | + <td class="ee-align-right">' . $line.'</td> |
|
| 232 | + <td class="ee-align-left">' . $file.'</td> |
|
| 233 | + <td class="ee-align-left">' . $this->class_name.$type.$function.$args.'</td> |
|
| 234 | 234 | </tr>'; |
| 235 | 235 | } |
| 236 | 236 | $trace_details .= ' |
@@ -266,25 +266,25 @@ discard block |
||
| 266 | 266 | $args[] = ' '; |
| 267 | 267 | } |
| 268 | 268 | if (is_string($arg)) { |
| 269 | - if (! $array && strlen($arg) > 75) { |
|
| 269 | + if ( ! $array && strlen($arg) > 75) { |
|
| 270 | 270 | $args[] = '<br />'; |
| 271 | 271 | for ($i = 0; $i <= $indent; $i++) { |
| 272 | 272 | $args[] = ' '; |
| 273 | 273 | } |
| 274 | - $args[] = "'" . $arg . "'<br />"; |
|
| 274 | + $args[] = "'".$arg."'<br />"; |
|
| 275 | 275 | } else { |
| 276 | - $args[] = " '" . $arg . "'"; |
|
| 276 | + $args[] = " '".$arg."'"; |
|
| 277 | 277 | } |
| 278 | 278 | } elseif (is_array($arg)) { |
| 279 | 279 | $arg_count = count($arg); |
| 280 | 280 | if ($arg_count > 2) { |
| 281 | 281 | $indent++; |
| 282 | - $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')'; |
|
| 282 | + $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')'; |
|
| 283 | 283 | $indent--; |
| 284 | 284 | } elseif ($arg_count === 0) { |
| 285 | 285 | $args[] = ' array()'; |
| 286 | 286 | } else { |
| 287 | - $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )'; |
|
| 287 | + $args[] = ' array( '.$this->_convert_args_to_string($arg).' )'; |
|
| 288 | 288 | } |
| 289 | 289 | } elseif ($arg === null) { |
| 290 | 290 | $args[] = ' null'; |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | { |
| 328 | 328 | $file_bits = explode('.', basename($file)); |
| 329 | 329 | $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
| 330 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
| 331 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
| 330 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
| 331 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
| 332 | 332 | return $error_code; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | private function printScripts($force_print = false) |
| 343 | 343 | { |
| 344 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
| 344 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
| 345 | 345 | // if script is already enqueued then we can just get out |
| 346 | 346 | if (wp_script_is('ee_error_js')) { |
| 347 | 347 | return ''; |
@@ -354,18 +354,18 @@ discard block |
||
| 354 | 354 | return ''; |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | - $jquery = includes_url() . 'js/jquery/jquery.js'; |
|
| 358 | - $core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version(); |
|
| 359 | - $ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version(); |
|
| 360 | - $style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css'; |
|
| 357 | + $jquery = includes_url().'js/jquery/jquery.js'; |
|
| 358 | + $core = EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.espresso_version(); |
|
| 359 | + $ee_error = EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js?ver='.espresso_version(); |
|
| 360 | + $style = EE_GLOBAL_ASSETS_URL.'css/ee-exception-stack-display.css'; |
|
| 361 | 361 | return ' |
| 362 | 362 | <script> |
| 363 | - const ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
| 363 | + const ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
| 364 | 364 | </script> |
| 365 | - <script src="' . esc_url_raw($jquery) . '" type="text/javascript"></script> |
|
| 366 | - <script src="' . esc_url_raw($core) . '" type="text/javascript"></script> |
|
| 367 | - <script src="' . esc_url_raw($ee_error) . '" type="text/javascript"></script> |
|
| 368 | - <link href="' . esc_url_raw($style) . '" rel="stylesheet" /> |
|
| 365 | + <script src="' . esc_url_raw($jquery).'" type="text/javascript"></script> |
|
| 366 | + <script src="' . esc_url_raw($core).'" type="text/javascript"></script> |
|
| 367 | + <script src="' . esc_url_raw($ee_error).'" type="text/javascript"></script> |
|
| 368 | + <link href="' . esc_url_raw($style).'" rel="stylesheet" /> |
|
| 369 | 369 | '; |
| 370 | 370 | } |
| 371 | 371 | } |