@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\Benchmark; |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -17,638 +17,638 @@ discard block |
||
| 17 | 17 | class EEH_Debug_Tools |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * instance of the EEH_Autoloader object |
|
| 22 | - * |
|
| 23 | - * @var $_instance |
|
| 24 | - * @access private |
|
| 25 | - */ |
|
| 26 | - private static $_instance; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - protected $_memory_usage_points = array(); |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @singleton method used to instantiate class object |
|
| 37 | - * @access public |
|
| 38 | - * @return EEH_Debug_Tools |
|
| 39 | - */ |
|
| 40 | - public static function instance() |
|
| 41 | - { |
|
| 42 | - // check if class object is instantiated, and instantiated properly |
|
| 43 | - if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | - self::$_instance = new self(); |
|
| 45 | - } |
|
| 46 | - return self::$_instance; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * private class constructor |
|
| 53 | - */ |
|
| 54 | - private function __construct() |
|
| 55 | - { |
|
| 56 | - // load Kint PHP debugging library |
|
| 57 | - if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 58 | - // despite EE4 having a check for an existing copy of the Kint debugging class, |
|
| 59 | - // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
|
| 60 | - // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
|
| 61 | - // so we've moved it to our test folder so that it is not included with production releases |
|
| 62 | - // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
|
| 63 | - require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 64 | - } |
|
| 65 | - // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
|
| 66 | - //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
|
| 67 | - // } |
|
| 68 | - $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
| 69 | - add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 70 | - add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 71 | - add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * show_db_name |
|
| 78 | - * |
|
| 79 | - * @return void |
|
| 80 | - */ |
|
| 81 | - public static function show_db_name() |
|
| 82 | - { |
|
| 83 | - if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
|
| 85 | - . DB_NAME |
|
| 86 | - . '</p>'; |
|
| 87 | - } |
|
| 88 | - if (EE_DEBUG) { |
|
| 89 | - Benchmark::displayResults(); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * dump EE_Session object at bottom of page after everything else has happened |
|
| 97 | - * |
|
| 98 | - * @return void |
|
| 99 | - */ |
|
| 100 | - public function espresso_session_footer_dump() |
|
| 101 | - { |
|
| 102 | - if ( |
|
| 103 | - (defined('WP_DEBUG') && WP_DEBUG) |
|
| 104 | - && ! defined('DOING_AJAX') |
|
| 105 | - && class_exists('Kint') |
|
| 106 | - && function_exists('wp_get_current_user') |
|
| 107 | - && current_user_can('update_core') |
|
| 108 | - && class_exists('EE_Registry') |
|
| 109 | - ) { |
|
| 110 | - Kint::dump(EE_Registry::instance()->SSN->id()); |
|
| 111 | - Kint::dump(EE_Registry::instance()->SSN); |
|
| 112 | - // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
|
| 113 | - $this->espresso_list_hooked_functions(); |
|
| 114 | - Benchmark::displayResults(); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * List All Hooked Functions |
|
| 122 | - * to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL |
|
| 123 | - * http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/ |
|
| 124 | - * |
|
| 125 | - * @param string $tag |
|
| 126 | - * @return void |
|
| 127 | - */ |
|
| 128 | - public function espresso_list_hooked_functions($tag = '') |
|
| 129 | - { |
|
| 130 | - global $wp_filter; |
|
| 131 | - echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
|
| 132 | - if ($tag) { |
|
| 133 | - $hook[$tag] = $wp_filter[$tag]; |
|
| 134 | - if (! is_array($hook[$tag])) { |
|
| 135 | - trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
| 136 | - return; |
|
| 137 | - } |
|
| 138 | - echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 139 | - } else { |
|
| 140 | - $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
|
| 141 | - ksort($hook); |
|
| 142 | - } |
|
| 143 | - foreach ($hook as $tag_name => $priorities) { |
|
| 144 | - echo "<br />>>>>>\t<strong>$tag_name</strong><br />"; |
|
| 145 | - ksort($priorities); |
|
| 146 | - foreach ($priorities as $priority => $function) { |
|
| 147 | - echo $priority; |
|
| 148 | - foreach ($function as $name => $properties) { |
|
| 149 | - echo "\t$name<br />"; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * registered_filter_callbacks |
|
| 159 | - * |
|
| 160 | - * @param string $hook_name |
|
| 161 | - * @return array |
|
| 162 | - */ |
|
| 163 | - public static function registered_filter_callbacks($hook_name = '') |
|
| 164 | - { |
|
| 165 | - $filters = array(); |
|
| 166 | - global $wp_filter; |
|
| 167 | - if (isset($wp_filter[$hook_name])) { |
|
| 168 | - $filters[$hook_name] = array(); |
|
| 169 | - foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
| 170 | - $filters[$hook_name][$priority] = array(); |
|
| 171 | - foreach ($callbacks as $callback) { |
|
| 172 | - $filters[$hook_name][$priority][] = $callback['function']; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - return $filters; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * captures plugin activation errors for debugging |
|
| 183 | - * |
|
| 184 | - * @return void |
|
| 185 | - * @throws EE_Error |
|
| 186 | - */ |
|
| 187 | - public static function ee_plugin_activation_errors() |
|
| 188 | - { |
|
| 189 | - if (WP_DEBUG) { |
|
| 190 | - $activation_errors = ob_get_contents(); |
|
| 191 | - if (! empty($activation_errors)) { |
|
| 192 | - $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 193 | - } |
|
| 194 | - espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 195 | - if (class_exists('EEH_File')) { |
|
| 196 | - try { |
|
| 197 | - EEH_File::ensure_file_exists_and_is_writable( |
|
| 198 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 199 | - ); |
|
| 200 | - EEH_File::write_to_file( |
|
| 201 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 202 | - $activation_errors |
|
| 203 | - ); |
|
| 204 | - } catch (EE_Error $e) { |
|
| 205 | - EE_Error::add_error( |
|
| 206 | - sprintf( |
|
| 207 | - __( |
|
| 208 | - 'The Event Espresso activation errors file could not be setup because: %s', |
|
| 209 | - 'event_espresso' |
|
| 210 | - ), |
|
| 211 | - $e->getMessage() |
|
| 212 | - ), |
|
| 213 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 214 | - ); |
|
| 215 | - } |
|
| 216 | - } else { |
|
| 217 | - // old school attempt |
|
| 218 | - file_put_contents( |
|
| 219 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 220 | - $activation_errors |
|
| 221 | - ); |
|
| 222 | - } |
|
| 223 | - $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 224 | - update_option('ee_plugin_activation_errors', $activation_errors); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc. |
|
| 232 | - * Very useful for providing helpful messages to developers when the method of doing something has been deprecated, |
|
| 233 | - * or we want to make sure they use something the right way. |
|
| 234 | - * |
|
| 235 | - * @access public |
|
| 236 | - * @param string $function The function that was called |
|
| 237 | - * @param string $message A message explaining what has been done incorrectly |
|
| 238 | - * @param string $version The version of Event Espresso where the error was added |
|
| 239 | - * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
| 240 | - * for a deprecated function. This allows deprecation to occur during one version, |
|
| 241 | - * but not have any notices appear until a later version. This allows developers |
|
| 242 | - * extra time to update their code before notices appear. |
|
| 243 | - * @param int $error_type |
|
| 244 | - * @uses trigger_error() |
|
| 245 | - */ |
|
| 246 | - public function doing_it_wrong( |
|
| 247 | - $function, |
|
| 248 | - $message, |
|
| 249 | - $version, |
|
| 250 | - $applies_when = '', |
|
| 251 | - $error_type = null |
|
| 252 | - ) { |
|
| 253 | - $applies_when = ! empty($applies_when) ? $applies_when : espresso_version(); |
|
| 254 | - $error_type = $error_type !== null ? $error_type : E_USER_NOTICE; |
|
| 255 | - // because we swapped the parameter order around for the last two params, |
|
| 256 | - // let's verify that some third party isn't still passing an error type value for the third param |
|
| 257 | - if (is_int($applies_when)) { |
|
| 258 | - $error_type = $applies_when; |
|
| 259 | - $applies_when = espresso_version(); |
|
| 260 | - } |
|
| 261 | - // if not displaying notices yet, then just leave |
|
| 262 | - if (version_compare(espresso_version(), $applies_when, '<')) { |
|
| 263 | - return; |
|
| 264 | - } |
|
| 265 | - do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 266 | - $version = $version === null |
|
| 267 | - ? '' |
|
| 268 | - : sprintf( |
|
| 269 | - __('(This message was added in version %s of Event Espresso)', 'event_espresso'), |
|
| 270 | - $version |
|
| 271 | - ); |
|
| 272 | - $error_message = sprintf( |
|
| 273 | - esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), |
|
| 274 | - $function, |
|
| 275 | - '<strong>', |
|
| 276 | - '</strong>', |
|
| 277 | - $message, |
|
| 278 | - $version |
|
| 279 | - ); |
|
| 280 | - // don't trigger error if doing ajax, |
|
| 281 | - // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
|
| 282 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 283 | - $error_message .= ' ' . esc_html__( |
|
| 284 | - 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
|
| 285 | - 'event_espresso' |
|
| 286 | - ); |
|
| 287 | - $error_message .= '<ul><li>'; |
|
| 288 | - $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
| 289 | - $error_message .= '</ul>'; |
|
| 290 | - EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
| 291 | - //now we set this on the transient so it shows up on the next request. |
|
| 292 | - EE_Error::get_notices(false, true); |
|
| 293 | - } else { |
|
| 294 | - trigger_error($error_message, $error_type); |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * Logger helpers |
|
| 303 | - */ |
|
| 304 | - /** |
|
| 305 | - * debug |
|
| 306 | - * |
|
| 307 | - * @param string $class |
|
| 308 | - * @param string $func |
|
| 309 | - * @param string $line |
|
| 310 | - * @param array $info |
|
| 311 | - * @param bool $display_request |
|
| 312 | - * @param string $debug_index |
|
| 313 | - * @param string $debug_key |
|
| 314 | - * @throws EE_Error |
|
| 315 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 316 | - */ |
|
| 317 | - public static function log( |
|
| 318 | - $class = '', |
|
| 319 | - $func = '', |
|
| 320 | - $line = '', |
|
| 321 | - $info = array(), |
|
| 322 | - $display_request = false, |
|
| 323 | - $debug_index = '', |
|
| 324 | - $debug_key = 'EE_DEBUG_SPCO' |
|
| 325 | - ) { |
|
| 326 | - if (WP_DEBUG) { |
|
| 327 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 328 | - $debug_data = get_option($debug_key, array()); |
|
| 329 | - $default_data = array( |
|
| 330 | - $class => $func . '() : ' . $line, |
|
| 331 | - 'REQ' => $display_request ? $_REQUEST : '', |
|
| 332 | - ); |
|
| 333 | - // don't serialize objects |
|
| 334 | - $info = self::strip_objects($info); |
|
| 335 | - $index = ! empty($debug_index) ? $debug_index : 0; |
|
| 336 | - if (! isset($debug_data[$index])) { |
|
| 337 | - $debug_data[$index] = array(); |
|
| 338 | - } |
|
| 339 | - $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
| 340 | - update_option($debug_key, $debug_data); |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * strip_objects |
|
| 348 | - * |
|
| 349 | - * @param array $info |
|
| 350 | - * @return array |
|
| 351 | - */ |
|
| 352 | - public static function strip_objects($info = array()) |
|
| 353 | - { |
|
| 354 | - foreach ($info as $key => $value) { |
|
| 355 | - if (is_array($value)) { |
|
| 356 | - $info[$key] = self::strip_objects($value); |
|
| 357 | - } else if (is_object($value)) { |
|
| 358 | - $object_class = get_class($value); |
|
| 359 | - $info[$object_class] = array(); |
|
| 360 | - $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
| 361 | - if (method_exists($value, 'ID')) { |
|
| 362 | - $info[$object_class]['ID'] = $value->ID(); |
|
| 363 | - } |
|
| 364 | - if (method_exists($value, 'status')) { |
|
| 365 | - $info[$object_class]['status'] = $value->status(); |
|
| 366 | - } else if (method_exists($value, 'status_ID')) { |
|
| 367 | - $info[$object_class]['status'] = $value->status_ID(); |
|
| 368 | - } |
|
| 369 | - unset($info[$key]); |
|
| 370 | - } |
|
| 371 | - } |
|
| 372 | - return (array)$info; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * @param mixed $var |
|
| 379 | - * @param string $var_name |
|
| 380 | - * @param string $file |
|
| 381 | - * @param int|string $line |
|
| 382 | - * @param int $heading_tag |
|
| 383 | - * @param bool $die |
|
| 384 | - * @param string $margin |
|
| 385 | - */ |
|
| 386 | - public static function printv( |
|
| 387 | - $var, |
|
| 388 | - $var_name = '', |
|
| 389 | - $file = '', |
|
| 390 | - $line = '', |
|
| 391 | - $heading_tag = 5, |
|
| 392 | - $die = false, |
|
| 393 | - $margin = '' |
|
| 394 | - ) { |
|
| 395 | - $var_name = ! $var_name ? 'string' : $var_name; |
|
| 396 | - $var_name = ucwords(str_replace('$', '', $var_name)); |
|
| 397 | - $is_method = method_exists($var_name, $var); |
|
| 398 | - $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
| 399 | - $result = $heading_tag > 3 && defined('EE_TESTS_DIR') |
|
| 400 | - ? "\n" |
|
| 401 | - :''; |
|
| 402 | - $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 403 | - $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 404 | - $result .= $is_method |
|
| 405 | - ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 406 | - : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 407 | - $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 408 | - $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 409 | - if ($die) { |
|
| 410 | - die($result); |
|
| 411 | - } |
|
| 412 | - echo $result; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - protected static function plainOutput() |
|
| 417 | - { |
|
| 418 | - return defined('EE_TESTS_DIR') || (defined('DOING_AJAX') && DOING_AJAX); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * @param string $var_name |
|
| 424 | - * @param string $heading_tag |
|
| 425 | - * @param string $margin |
|
| 426 | - * @param int $line |
|
| 427 | - * @return string |
|
| 428 | - */ |
|
| 429 | - protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0) |
|
| 430 | - { |
|
| 431 | - if (EEH_Debug_Tools::plainOutput()) { |
|
| 432 | - return "\n{$line}) {$var_name}"; |
|
| 433 | - } |
|
| 434 | - $margin = "25px 0 0 {$margin}"; |
|
| 435 | - return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * @param string $heading_tag |
|
| 442 | - * @return string |
|
| 443 | - */ |
|
| 444 | - protected static function headingX($heading_tag = 'h5') |
|
| 445 | - { |
|
| 446 | - if (EEH_Debug_Tools::plainOutput()) { |
|
| 447 | - return ''; |
|
| 448 | - } |
|
| 449 | - return '</' . $heading_tag . '>'; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * @param string $content |
|
| 456 | - * @return string |
|
| 457 | - */ |
|
| 458 | - protected static function grey_span($content = '') |
|
| 459 | - { |
|
| 460 | - if (EEH_Debug_Tools::plainOutput()) { |
|
| 461 | - return $content; |
|
| 462 | - } |
|
| 463 | - return '<span style="color:#999">' . $content . '</span>'; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - |
|
| 467 | - |
|
| 468 | - /** |
|
| 469 | - * @param string $file |
|
| 470 | - * @param int $line |
|
| 471 | - * @return string |
|
| 472 | - */ |
|
| 473 | - protected static function file_and_line($file, $line) |
|
| 474 | - { |
|
| 475 | - if ($file === '' || $line === '' || EEH_Debug_Tools::plainOutput()) { |
|
| 476 | - return ''; |
|
| 477 | - } |
|
| 478 | - return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' |
|
| 479 | - . $file |
|
| 480 | - . '<br />line no: ' |
|
| 481 | - . $line |
|
| 482 | - . '</span>'; |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * @param string $content |
|
| 489 | - * @return string |
|
| 490 | - */ |
|
| 491 | - protected static function orange_span($content = '') |
|
| 492 | - { |
|
| 493 | - if (EEH_Debug_Tools::plainOutput()) { |
|
| 494 | - return $content; |
|
| 495 | - } |
|
| 496 | - return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * @param mixed $var |
|
| 503 | - * @return string |
|
| 504 | - */ |
|
| 505 | - protected static function pre_span($var) |
|
| 506 | - { |
|
| 507 | - ob_start(); |
|
| 508 | - var_dump($var); |
|
| 509 | - $var = ob_get_clean(); |
|
| 510 | - if (EEH_Debug_Tools::plainOutput()) { |
|
| 511 | - return "\n" . $var; |
|
| 512 | - } |
|
| 513 | - return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * @param mixed $var |
|
| 520 | - * @param string $var_name |
|
| 521 | - * @param string $file |
|
| 522 | - * @param int|string $line |
|
| 523 | - * @param int $heading_tag |
|
| 524 | - * @param bool $die |
|
| 525 | - */ |
|
| 526 | - public static function printr( |
|
| 527 | - $var, |
|
| 528 | - $var_name = '', |
|
| 529 | - $file = '', |
|
| 530 | - $line = '', |
|
| 531 | - $heading_tag = 5, |
|
| 532 | - $die = false |
|
| 533 | - ) { |
|
| 534 | - // return; |
|
| 535 | - $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
| 536 | - $margin = is_admin() ? ' 180px' : '0'; |
|
| 537 | - //$print_r = false; |
|
| 538 | - if (is_string($var)) { |
|
| 539 | - EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin); |
|
| 540 | - return; |
|
| 541 | - } |
|
| 542 | - if (is_object($var)) { |
|
| 543 | - $var_name = ! $var_name ? 'object' : $var_name; |
|
| 544 | - //$print_r = true; |
|
| 545 | - } else if (is_array($var)) { |
|
| 546 | - $var_name = ! $var_name ? 'array' : $var_name; |
|
| 547 | - //$print_r = true; |
|
| 548 | - } else if (is_numeric($var)) { |
|
| 549 | - $var_name = ! $var_name ? 'numeric' : $var_name; |
|
| 550 | - } else if ($var === null) { |
|
| 551 | - $var_name = ! $var_name ? 'null' : $var_name; |
|
| 552 | - } |
|
| 553 | - $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
| 554 | - $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 555 | - $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line); |
|
| 556 | - $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 557 | - EEH_Debug_Tools::pre_span($var) |
|
| 558 | - ); |
|
| 559 | - $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 560 | - $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 561 | - if ($die) { |
|
| 562 | - die($result); |
|
| 563 | - } |
|
| 564 | - echo $result; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /******************** deprecated ********************/ |
|
| 570 | - |
|
| 571 | - |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * @deprecated 4.9.39.rc.034 |
|
| 575 | - */ |
|
| 576 | - public function reset_times() |
|
| 577 | - { |
|
| 578 | - Benchmark::resetTimes(); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - /** |
|
| 584 | - * @deprecated 4.9.39.rc.034 |
|
| 585 | - * @param null $timer_name |
|
| 586 | - */ |
|
| 587 | - public function start_timer($timer_name = null) |
|
| 588 | - { |
|
| 589 | - Benchmark::startTimer($timer_name); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * @deprecated 4.9.39.rc.034 |
|
| 596 | - * @param string $timer_name |
|
| 597 | - */ |
|
| 598 | - public function stop_timer($timer_name = '') |
|
| 599 | - { |
|
| 600 | - Benchmark::stopTimer($timer_name); |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * @deprecated 4.9.39.rc.034 |
|
| 607 | - * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 608 | - * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 609 | - * @return void |
|
| 610 | - */ |
|
| 611 | - public function measure_memory($label, $output_now = false) |
|
| 612 | - { |
|
| 613 | - Benchmark::measureMemory($label, $output_now); |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - |
|
| 617 | - |
|
| 618 | - /** |
|
| 619 | - * @deprecated 4.9.39.rc.034 |
|
| 620 | - * @param int $size |
|
| 621 | - * @return string |
|
| 622 | - */ |
|
| 623 | - public function convert($size) |
|
| 624 | - { |
|
| 625 | - return Benchmark::convert($size); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * @deprecated 4.9.39.rc.034 |
|
| 632 | - * @param bool $output_now |
|
| 633 | - * @return string |
|
| 634 | - */ |
|
| 635 | - public function show_times($output_now = true) |
|
| 636 | - { |
|
| 637 | - return Benchmark::displayResults($output_now); |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * @deprecated 4.9.39.rc.034 |
|
| 644 | - * @param string $timer_name |
|
| 645 | - * @param float $total_time |
|
| 646 | - * @return string |
|
| 647 | - */ |
|
| 648 | - public function format_time($timer_name, $total_time) |
|
| 649 | - { |
|
| 650 | - return Benchmark::formatTime($timer_name, $total_time); |
|
| 651 | - } |
|
| 20 | + /** |
|
| 21 | + * instance of the EEH_Autoloader object |
|
| 22 | + * |
|
| 23 | + * @var $_instance |
|
| 24 | + * @access private |
|
| 25 | + */ |
|
| 26 | + private static $_instance; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + protected $_memory_usage_points = array(); |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @singleton method used to instantiate class object |
|
| 37 | + * @access public |
|
| 38 | + * @return EEH_Debug_Tools |
|
| 39 | + */ |
|
| 40 | + public static function instance() |
|
| 41 | + { |
|
| 42 | + // check if class object is instantiated, and instantiated properly |
|
| 43 | + if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | + self::$_instance = new self(); |
|
| 45 | + } |
|
| 46 | + return self::$_instance; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * private class constructor |
|
| 53 | + */ |
|
| 54 | + private function __construct() |
|
| 55 | + { |
|
| 56 | + // load Kint PHP debugging library |
|
| 57 | + if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 58 | + // despite EE4 having a check for an existing copy of the Kint debugging class, |
|
| 59 | + // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
|
| 60 | + // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
|
| 61 | + // so we've moved it to our test folder so that it is not included with production releases |
|
| 62 | + // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
|
| 63 | + require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 64 | + } |
|
| 65 | + // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
|
| 66 | + //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
|
| 67 | + // } |
|
| 68 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
| 69 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 70 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 71 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * show_db_name |
|
| 78 | + * |
|
| 79 | + * @return void |
|
| 80 | + */ |
|
| 81 | + public static function show_db_name() |
|
| 82 | + { |
|
| 83 | + if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
|
| 85 | + . DB_NAME |
|
| 86 | + . '</p>'; |
|
| 87 | + } |
|
| 88 | + if (EE_DEBUG) { |
|
| 89 | + Benchmark::displayResults(); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * dump EE_Session object at bottom of page after everything else has happened |
|
| 97 | + * |
|
| 98 | + * @return void |
|
| 99 | + */ |
|
| 100 | + public function espresso_session_footer_dump() |
|
| 101 | + { |
|
| 102 | + if ( |
|
| 103 | + (defined('WP_DEBUG') && WP_DEBUG) |
|
| 104 | + && ! defined('DOING_AJAX') |
|
| 105 | + && class_exists('Kint') |
|
| 106 | + && function_exists('wp_get_current_user') |
|
| 107 | + && current_user_can('update_core') |
|
| 108 | + && class_exists('EE_Registry') |
|
| 109 | + ) { |
|
| 110 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
| 111 | + Kint::dump(EE_Registry::instance()->SSN); |
|
| 112 | + // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
|
| 113 | + $this->espresso_list_hooked_functions(); |
|
| 114 | + Benchmark::displayResults(); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * List All Hooked Functions |
|
| 122 | + * to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL |
|
| 123 | + * http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/ |
|
| 124 | + * |
|
| 125 | + * @param string $tag |
|
| 126 | + * @return void |
|
| 127 | + */ |
|
| 128 | + public function espresso_list_hooked_functions($tag = '') |
|
| 129 | + { |
|
| 130 | + global $wp_filter; |
|
| 131 | + echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
|
| 132 | + if ($tag) { |
|
| 133 | + $hook[$tag] = $wp_filter[$tag]; |
|
| 134 | + if (! is_array($hook[$tag])) { |
|
| 135 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
| 136 | + return; |
|
| 137 | + } |
|
| 138 | + echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 139 | + } else { |
|
| 140 | + $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
|
| 141 | + ksort($hook); |
|
| 142 | + } |
|
| 143 | + foreach ($hook as $tag_name => $priorities) { |
|
| 144 | + echo "<br />>>>>>\t<strong>$tag_name</strong><br />"; |
|
| 145 | + ksort($priorities); |
|
| 146 | + foreach ($priorities as $priority => $function) { |
|
| 147 | + echo $priority; |
|
| 148 | + foreach ($function as $name => $properties) { |
|
| 149 | + echo "\t$name<br />"; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * registered_filter_callbacks |
|
| 159 | + * |
|
| 160 | + * @param string $hook_name |
|
| 161 | + * @return array |
|
| 162 | + */ |
|
| 163 | + public static function registered_filter_callbacks($hook_name = '') |
|
| 164 | + { |
|
| 165 | + $filters = array(); |
|
| 166 | + global $wp_filter; |
|
| 167 | + if (isset($wp_filter[$hook_name])) { |
|
| 168 | + $filters[$hook_name] = array(); |
|
| 169 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
| 170 | + $filters[$hook_name][$priority] = array(); |
|
| 171 | + foreach ($callbacks as $callback) { |
|
| 172 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + return $filters; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * captures plugin activation errors for debugging |
|
| 183 | + * |
|
| 184 | + * @return void |
|
| 185 | + * @throws EE_Error |
|
| 186 | + */ |
|
| 187 | + public static function ee_plugin_activation_errors() |
|
| 188 | + { |
|
| 189 | + if (WP_DEBUG) { |
|
| 190 | + $activation_errors = ob_get_contents(); |
|
| 191 | + if (! empty($activation_errors)) { |
|
| 192 | + $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 193 | + } |
|
| 194 | + espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 195 | + if (class_exists('EEH_File')) { |
|
| 196 | + try { |
|
| 197 | + EEH_File::ensure_file_exists_and_is_writable( |
|
| 198 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 199 | + ); |
|
| 200 | + EEH_File::write_to_file( |
|
| 201 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 202 | + $activation_errors |
|
| 203 | + ); |
|
| 204 | + } catch (EE_Error $e) { |
|
| 205 | + EE_Error::add_error( |
|
| 206 | + sprintf( |
|
| 207 | + __( |
|
| 208 | + 'The Event Espresso activation errors file could not be setup because: %s', |
|
| 209 | + 'event_espresso' |
|
| 210 | + ), |
|
| 211 | + $e->getMessage() |
|
| 212 | + ), |
|
| 213 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 214 | + ); |
|
| 215 | + } |
|
| 216 | + } else { |
|
| 217 | + // old school attempt |
|
| 218 | + file_put_contents( |
|
| 219 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 220 | + $activation_errors |
|
| 221 | + ); |
|
| 222 | + } |
|
| 223 | + $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 224 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc. |
|
| 232 | + * Very useful for providing helpful messages to developers when the method of doing something has been deprecated, |
|
| 233 | + * or we want to make sure they use something the right way. |
|
| 234 | + * |
|
| 235 | + * @access public |
|
| 236 | + * @param string $function The function that was called |
|
| 237 | + * @param string $message A message explaining what has been done incorrectly |
|
| 238 | + * @param string $version The version of Event Espresso where the error was added |
|
| 239 | + * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
| 240 | + * for a deprecated function. This allows deprecation to occur during one version, |
|
| 241 | + * but not have any notices appear until a later version. This allows developers |
|
| 242 | + * extra time to update their code before notices appear. |
|
| 243 | + * @param int $error_type |
|
| 244 | + * @uses trigger_error() |
|
| 245 | + */ |
|
| 246 | + public function doing_it_wrong( |
|
| 247 | + $function, |
|
| 248 | + $message, |
|
| 249 | + $version, |
|
| 250 | + $applies_when = '', |
|
| 251 | + $error_type = null |
|
| 252 | + ) { |
|
| 253 | + $applies_when = ! empty($applies_when) ? $applies_when : espresso_version(); |
|
| 254 | + $error_type = $error_type !== null ? $error_type : E_USER_NOTICE; |
|
| 255 | + // because we swapped the parameter order around for the last two params, |
|
| 256 | + // let's verify that some third party isn't still passing an error type value for the third param |
|
| 257 | + if (is_int($applies_when)) { |
|
| 258 | + $error_type = $applies_when; |
|
| 259 | + $applies_when = espresso_version(); |
|
| 260 | + } |
|
| 261 | + // if not displaying notices yet, then just leave |
|
| 262 | + if (version_compare(espresso_version(), $applies_when, '<')) { |
|
| 263 | + return; |
|
| 264 | + } |
|
| 265 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 266 | + $version = $version === null |
|
| 267 | + ? '' |
|
| 268 | + : sprintf( |
|
| 269 | + __('(This message was added in version %s of Event Espresso)', 'event_espresso'), |
|
| 270 | + $version |
|
| 271 | + ); |
|
| 272 | + $error_message = sprintf( |
|
| 273 | + esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), |
|
| 274 | + $function, |
|
| 275 | + '<strong>', |
|
| 276 | + '</strong>', |
|
| 277 | + $message, |
|
| 278 | + $version |
|
| 279 | + ); |
|
| 280 | + // don't trigger error if doing ajax, |
|
| 281 | + // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
|
| 282 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 283 | + $error_message .= ' ' . esc_html__( |
|
| 284 | + 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
|
| 285 | + 'event_espresso' |
|
| 286 | + ); |
|
| 287 | + $error_message .= '<ul><li>'; |
|
| 288 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
| 289 | + $error_message .= '</ul>'; |
|
| 290 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
| 291 | + //now we set this on the transient so it shows up on the next request. |
|
| 292 | + EE_Error::get_notices(false, true); |
|
| 293 | + } else { |
|
| 294 | + trigger_error($error_message, $error_type); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * Logger helpers |
|
| 303 | + */ |
|
| 304 | + /** |
|
| 305 | + * debug |
|
| 306 | + * |
|
| 307 | + * @param string $class |
|
| 308 | + * @param string $func |
|
| 309 | + * @param string $line |
|
| 310 | + * @param array $info |
|
| 311 | + * @param bool $display_request |
|
| 312 | + * @param string $debug_index |
|
| 313 | + * @param string $debug_key |
|
| 314 | + * @throws EE_Error |
|
| 315 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
| 316 | + */ |
|
| 317 | + public static function log( |
|
| 318 | + $class = '', |
|
| 319 | + $func = '', |
|
| 320 | + $line = '', |
|
| 321 | + $info = array(), |
|
| 322 | + $display_request = false, |
|
| 323 | + $debug_index = '', |
|
| 324 | + $debug_key = 'EE_DEBUG_SPCO' |
|
| 325 | + ) { |
|
| 326 | + if (WP_DEBUG) { |
|
| 327 | + $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 328 | + $debug_data = get_option($debug_key, array()); |
|
| 329 | + $default_data = array( |
|
| 330 | + $class => $func . '() : ' . $line, |
|
| 331 | + 'REQ' => $display_request ? $_REQUEST : '', |
|
| 332 | + ); |
|
| 333 | + // don't serialize objects |
|
| 334 | + $info = self::strip_objects($info); |
|
| 335 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
| 336 | + if (! isset($debug_data[$index])) { |
|
| 337 | + $debug_data[$index] = array(); |
|
| 338 | + } |
|
| 339 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
| 340 | + update_option($debug_key, $debug_data); |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * strip_objects |
|
| 348 | + * |
|
| 349 | + * @param array $info |
|
| 350 | + * @return array |
|
| 351 | + */ |
|
| 352 | + public static function strip_objects($info = array()) |
|
| 353 | + { |
|
| 354 | + foreach ($info as $key => $value) { |
|
| 355 | + if (is_array($value)) { |
|
| 356 | + $info[$key] = self::strip_objects($value); |
|
| 357 | + } else if (is_object($value)) { |
|
| 358 | + $object_class = get_class($value); |
|
| 359 | + $info[$object_class] = array(); |
|
| 360 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
| 361 | + if (method_exists($value, 'ID')) { |
|
| 362 | + $info[$object_class]['ID'] = $value->ID(); |
|
| 363 | + } |
|
| 364 | + if (method_exists($value, 'status')) { |
|
| 365 | + $info[$object_class]['status'] = $value->status(); |
|
| 366 | + } else if (method_exists($value, 'status_ID')) { |
|
| 367 | + $info[$object_class]['status'] = $value->status_ID(); |
|
| 368 | + } |
|
| 369 | + unset($info[$key]); |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | + return (array)$info; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * @param mixed $var |
|
| 379 | + * @param string $var_name |
|
| 380 | + * @param string $file |
|
| 381 | + * @param int|string $line |
|
| 382 | + * @param int $heading_tag |
|
| 383 | + * @param bool $die |
|
| 384 | + * @param string $margin |
|
| 385 | + */ |
|
| 386 | + public static function printv( |
|
| 387 | + $var, |
|
| 388 | + $var_name = '', |
|
| 389 | + $file = '', |
|
| 390 | + $line = '', |
|
| 391 | + $heading_tag = 5, |
|
| 392 | + $die = false, |
|
| 393 | + $margin = '' |
|
| 394 | + ) { |
|
| 395 | + $var_name = ! $var_name ? 'string' : $var_name; |
|
| 396 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
| 397 | + $is_method = method_exists($var_name, $var); |
|
| 398 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
| 399 | + $result = $heading_tag > 3 && defined('EE_TESTS_DIR') |
|
| 400 | + ? "\n" |
|
| 401 | + :''; |
|
| 402 | + $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 403 | + $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
|
| 404 | + $result .= $is_method |
|
| 405 | + ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 406 | + : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 407 | + $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 408 | + $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 409 | + if ($die) { |
|
| 410 | + die($result); |
|
| 411 | + } |
|
| 412 | + echo $result; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + protected static function plainOutput() |
|
| 417 | + { |
|
| 418 | + return defined('EE_TESTS_DIR') || (defined('DOING_AJAX') && DOING_AJAX); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * @param string $var_name |
|
| 424 | + * @param string $heading_tag |
|
| 425 | + * @param string $margin |
|
| 426 | + * @param int $line |
|
| 427 | + * @return string |
|
| 428 | + */ |
|
| 429 | + protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '', $line = 0) |
|
| 430 | + { |
|
| 431 | + if (EEH_Debug_Tools::plainOutput()) { |
|
| 432 | + return "\n{$line}) {$var_name}"; |
|
| 433 | + } |
|
| 434 | + $margin = "25px 0 0 {$margin}"; |
|
| 435 | + return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * @param string $heading_tag |
|
| 442 | + * @return string |
|
| 443 | + */ |
|
| 444 | + protected static function headingX($heading_tag = 'h5') |
|
| 445 | + { |
|
| 446 | + if (EEH_Debug_Tools::plainOutput()) { |
|
| 447 | + return ''; |
|
| 448 | + } |
|
| 449 | + return '</' . $heading_tag . '>'; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + |
|
| 454 | + /** |
|
| 455 | + * @param string $content |
|
| 456 | + * @return string |
|
| 457 | + */ |
|
| 458 | + protected static function grey_span($content = '') |
|
| 459 | + { |
|
| 460 | + if (EEH_Debug_Tools::plainOutput()) { |
|
| 461 | + return $content; |
|
| 462 | + } |
|
| 463 | + return '<span style="color:#999">' . $content . '</span>'; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * @param string $file |
|
| 470 | + * @param int $line |
|
| 471 | + * @return string |
|
| 472 | + */ |
|
| 473 | + protected static function file_and_line($file, $line) |
|
| 474 | + { |
|
| 475 | + if ($file === '' || $line === '' || EEH_Debug_Tools::plainOutput()) { |
|
| 476 | + return ''; |
|
| 477 | + } |
|
| 478 | + return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' |
|
| 479 | + . $file |
|
| 480 | + . '<br />line no: ' |
|
| 481 | + . $line |
|
| 482 | + . '</span>'; |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * @param string $content |
|
| 489 | + * @return string |
|
| 490 | + */ |
|
| 491 | + protected static function orange_span($content = '') |
|
| 492 | + { |
|
| 493 | + if (EEH_Debug_Tools::plainOutput()) { |
|
| 494 | + return $content; |
|
| 495 | + } |
|
| 496 | + return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * @param mixed $var |
|
| 503 | + * @return string |
|
| 504 | + */ |
|
| 505 | + protected static function pre_span($var) |
|
| 506 | + { |
|
| 507 | + ob_start(); |
|
| 508 | + var_dump($var); |
|
| 509 | + $var = ob_get_clean(); |
|
| 510 | + if (EEH_Debug_Tools::plainOutput()) { |
|
| 511 | + return "\n" . $var; |
|
| 512 | + } |
|
| 513 | + return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * @param mixed $var |
|
| 520 | + * @param string $var_name |
|
| 521 | + * @param string $file |
|
| 522 | + * @param int|string $line |
|
| 523 | + * @param int $heading_tag |
|
| 524 | + * @param bool $die |
|
| 525 | + */ |
|
| 526 | + public static function printr( |
|
| 527 | + $var, |
|
| 528 | + $var_name = '', |
|
| 529 | + $file = '', |
|
| 530 | + $line = '', |
|
| 531 | + $heading_tag = 5, |
|
| 532 | + $die = false |
|
| 533 | + ) { |
|
| 534 | + // return; |
|
| 535 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
| 536 | + $margin = is_admin() ? ' 180px' : '0'; |
|
| 537 | + //$print_r = false; |
|
| 538 | + if (is_string($var)) { |
|
| 539 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin); |
|
| 540 | + return; |
|
| 541 | + } |
|
| 542 | + if (is_object($var)) { |
|
| 543 | + $var_name = ! $var_name ? 'object' : $var_name; |
|
| 544 | + //$print_r = true; |
|
| 545 | + } else if (is_array($var)) { |
|
| 546 | + $var_name = ! $var_name ? 'array' : $var_name; |
|
| 547 | + //$print_r = true; |
|
| 548 | + } else if (is_numeric($var)) { |
|
| 549 | + $var_name = ! $var_name ? 'numeric' : $var_name; |
|
| 550 | + } else if ($var === null) { |
|
| 551 | + $var_name = ! $var_name ? 'null' : $var_name; |
|
| 552 | + } |
|
| 553 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
| 554 | + $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
|
| 555 | + $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line); |
|
| 556 | + $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 557 | + EEH_Debug_Tools::pre_span($var) |
|
| 558 | + ); |
|
| 559 | + $result .= EEH_Debug_Tools::file_and_line($file, $line); |
|
| 560 | + $result .= EEH_Debug_Tools::headingX($heading_tag); |
|
| 561 | + if ($die) { |
|
| 562 | + die($result); |
|
| 563 | + } |
|
| 564 | + echo $result; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /******************** deprecated ********************/ |
|
| 570 | + |
|
| 571 | + |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * @deprecated 4.9.39.rc.034 |
|
| 575 | + */ |
|
| 576 | + public function reset_times() |
|
| 577 | + { |
|
| 578 | + Benchmark::resetTimes(); |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * @deprecated 4.9.39.rc.034 |
|
| 585 | + * @param null $timer_name |
|
| 586 | + */ |
|
| 587 | + public function start_timer($timer_name = null) |
|
| 588 | + { |
|
| 589 | + Benchmark::startTimer($timer_name); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * @deprecated 4.9.39.rc.034 |
|
| 596 | + * @param string $timer_name |
|
| 597 | + */ |
|
| 598 | + public function stop_timer($timer_name = '') |
|
| 599 | + { |
|
| 600 | + Benchmark::stopTimer($timer_name); |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * @deprecated 4.9.39.rc.034 |
|
| 607 | + * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
|
| 608 | + * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
|
| 609 | + * @return void |
|
| 610 | + */ |
|
| 611 | + public function measure_memory($label, $output_now = false) |
|
| 612 | + { |
|
| 613 | + Benchmark::measureMemory($label, $output_now); |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + |
|
| 617 | + |
|
| 618 | + /** |
|
| 619 | + * @deprecated 4.9.39.rc.034 |
|
| 620 | + * @param int $size |
|
| 621 | + * @return string |
|
| 622 | + */ |
|
| 623 | + public function convert($size) |
|
| 624 | + { |
|
| 625 | + return Benchmark::convert($size); |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * @deprecated 4.9.39.rc.034 |
|
| 632 | + * @param bool $output_now |
|
| 633 | + * @return string |
|
| 634 | + */ |
|
| 635 | + public function show_times($output_now = true) |
|
| 636 | + { |
|
| 637 | + return Benchmark::displayResults($output_now); |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * @deprecated 4.9.39.rc.034 |
|
| 644 | + * @param string $timer_name |
|
| 645 | + * @param float $total_time |
|
| 646 | + * @return string |
|
| 647 | + */ |
|
| 648 | + public function format_time($timer_name, $total_time) |
|
| 649 | + { |
|
| 650 | + return Benchmark::formatTime($timer_name, $total_time); |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | 653 | |
| 654 | 654 | |
@@ -661,31 +661,31 @@ discard block |
||
| 661 | 661 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 662 | 662 | */ |
| 663 | 663 | if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
| 664 | - function dump_wp_query() |
|
| 665 | - { |
|
| 666 | - global $wp_query; |
|
| 667 | - d($wp_query); |
|
| 668 | - } |
|
| 664 | + function dump_wp_query() |
|
| 665 | + { |
|
| 666 | + global $wp_query; |
|
| 667 | + d($wp_query); |
|
| 668 | + } |
|
| 669 | 669 | } |
| 670 | 670 | /** |
| 671 | 671 | * borrowed from Kint Debugger |
| 672 | 672 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 673 | 673 | */ |
| 674 | 674 | if (class_exists('Kint') && ! function_exists('dump_wp')) { |
| 675 | - function dump_wp() |
|
| 676 | - { |
|
| 677 | - global $wp; |
|
| 678 | - d($wp); |
|
| 679 | - } |
|
| 675 | + function dump_wp() |
|
| 676 | + { |
|
| 677 | + global $wp; |
|
| 678 | + d($wp); |
|
| 679 | + } |
|
| 680 | 680 | } |
| 681 | 681 | /** |
| 682 | 682 | * borrowed from Kint Debugger |
| 683 | 683 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 684 | 684 | */ |
| 685 | 685 | if (class_exists('Kint') && ! function_exists('dump_post')) { |
| 686 | - function dump_post() |
|
| 687 | - { |
|
| 688 | - global $post; |
|
| 689 | - d($post); |
|
| 690 | - } |
|
| 686 | + function dump_post() |
|
| 687 | + { |
|
| 688 | + global $post; |
|
| 689 | + d($post); |
|
| 690 | + } |
|
| 691 | 691 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\Benchmark; |
| 2 | 2 | |
| 3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public static function instance() |
| 41 | 41 | { |
| 42 | 42 | // check if class object is instantiated, and instantiated properly |
| 43 | - if (! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 43 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 44 | 44 | self::$_instance = new self(); |
| 45 | 45 | } |
| 46 | 46 | return self::$_instance; |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | private function __construct() |
| 55 | 55 | { |
| 56 | 56 | // load Kint PHP debugging library |
| 57 | - if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) { |
|
| 57 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
| 58 | 58 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
| 59 | 59 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
| 60 | 60 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
| 61 | 61 | // so we've moved it to our test folder so that it is not included with production releases |
| 62 | 62 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
| 63 | - require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php'); |
|
| 63 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
| 64 | 64 | } |
| 65 | 65 | // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
| 66 | 66 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function show_db_name() |
| 82 | 82 | { |
| 83 | - if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 83 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 84 | 84 | echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: ' |
| 85 | 85 | . DB_NAME |
| 86 | 86 | . '</p>'; |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
| 132 | 132 | if ($tag) { |
| 133 | 133 | $hook[$tag] = $wp_filter[$tag]; |
| 134 | - if (! is_array($hook[$tag])) { |
|
| 134 | + if ( ! is_array($hook[$tag])) { |
|
| 135 | 135 | trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
| 136 | 136 | return; |
| 137 | 137 | } |
| 138 | - echo '<h5>For Tag: ' . $tag . '</h5>'; |
|
| 138 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
| 139 | 139 | } else { |
| 140 | 140 | $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter); |
| 141 | 141 | ksort($hook); |
@@ -188,17 +188,17 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | if (WP_DEBUG) { |
| 190 | 190 | $activation_errors = ob_get_contents(); |
| 191 | - if (! empty($activation_errors)) { |
|
| 192 | - $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors; |
|
| 191 | + if ( ! empty($activation_errors)) { |
|
| 192 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
| 193 | 193 | } |
| 194 | - espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php'); |
|
| 194 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
| 195 | 195 | if (class_exists('EEH_File')) { |
| 196 | 196 | try { |
| 197 | 197 | EEH_File::ensure_file_exists_and_is_writable( |
| 198 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' |
|
| 198 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html' |
|
| 199 | 199 | ); |
| 200 | 200 | EEH_File::write_to_file( |
| 201 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 201 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', |
|
| 202 | 202 | $activation_errors |
| 203 | 203 | ); |
| 204 | 204 | } catch (EE_Error $e) { |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | } else { |
| 217 | 217 | // old school attempt |
| 218 | 218 | file_put_contents( |
| 219 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', |
|
| 219 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', |
|
| 220 | 220 | $activation_errors |
| 221 | 221 | ); |
| 222 | 222 | } |
| 223 | - $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors; |
|
| 223 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
| 224 | 224 | update_option('ee_plugin_activation_errors', $activation_errors); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | // don't trigger error if doing ajax, |
| 281 | 281 | // instead we'll add a transient EE_Error notice that in theory should show on the next request. |
| 282 | 282 | if (defined('DOING_AJAX') && DOING_AJAX) { |
| 283 | - $error_message .= ' ' . esc_html__( |
|
| 283 | + $error_message .= ' '.esc_html__( |
|
| 284 | 284 | 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', |
| 285 | 285 | 'event_espresso' |
| 286 | 286 | ); |
@@ -324,16 +324,16 @@ discard block |
||
| 324 | 324 | $debug_key = 'EE_DEBUG_SPCO' |
| 325 | 325 | ) { |
| 326 | 326 | if (WP_DEBUG) { |
| 327 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 327 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
| 328 | 328 | $debug_data = get_option($debug_key, array()); |
| 329 | 329 | $default_data = array( |
| 330 | - $class => $func . '() : ' . $line, |
|
| 330 | + $class => $func.'() : '.$line, |
|
| 331 | 331 | 'REQ' => $display_request ? $_REQUEST : '', |
| 332 | 332 | ); |
| 333 | 333 | // don't serialize objects |
| 334 | 334 | $info = self::strip_objects($info); |
| 335 | 335 | $index = ! empty($debug_index) ? $debug_index : 0; |
| 336 | - if (! isset($debug_data[$index])) { |
|
| 336 | + if ( ! isset($debug_data[$index])) { |
|
| 337 | 337 | $debug_data[$index] = array(); |
| 338 | 338 | } |
| 339 | 339 | $debug_data[$index][microtime()] = array_merge($default_data, $info); |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | unset($info[$key]); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | - return (array)$info; |
|
| 372 | + return (array) $info; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
| 403 | 403 | $result .= EEH_Debug_Tools::heading($var_name, $heading_tag, $margin); |
| 404 | 404 | $result .= $is_method |
| 405 | - ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()') |
|
| 406 | - : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var); |
|
| 405 | + ? EEH_Debug_Tools::grey_span('::').EEH_Debug_Tools::orange_span($var.'()') |
|
| 406 | + : EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span($var); |
|
| 407 | 407 | $result .= EEH_Debug_Tools::file_and_line($file, $line); |
| 408 | 408 | $result .= EEH_Debug_Tools::headingX($heading_tag); |
| 409 | 409 | if ($die) { |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | return "\n{$line}) {$var_name}"; |
| 433 | 433 | } |
| 434 | 434 | $margin = "25px 0 0 {$margin}"; |
| 435 | - return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 435 | + return '<'.$heading_tag.' style="color:#2EA2CC; margin:'.$margin.';"><b>'.$var_name.'</b>'; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | if (EEH_Debug_Tools::plainOutput()) { |
| 447 | 447 | return ''; |
| 448 | 448 | } |
| 449 | - return '</' . $heading_tag . '>'; |
|
| 449 | + return '</'.$heading_tag.'>'; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | if (EEH_Debug_Tools::plainOutput()) { |
| 461 | 461 | return $content; |
| 462 | 462 | } |
| 463 | - return '<span style="color:#999">' . $content . '</span>'; |
|
| 463 | + return '<span style="color:#999">'.$content.'</span>'; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | if (EEH_Debug_Tools::plainOutput()) { |
| 494 | 494 | return $content; |
| 495 | 495 | } |
| 496 | - return '<span style="color:#E76700">' . $content . '</span>'; |
|
| 496 | + return '<span style="color:#E76700">'.$content.'</span>'; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | var_dump($var); |
| 509 | 509 | $var = ob_get_clean(); |
| 510 | 510 | if (EEH_Debug_Tools::plainOutput()) { |
| 511 | - return "\n" . $var; |
|
| 511 | + return "\n".$var; |
|
| 512 | 512 | } |
| 513 | - return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>'; |
|
| 513 | + return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>'; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
| 554 | 554 | $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5'; |
| 555 | 555 | $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin, $line); |
| 556 | - $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span( |
|
| 556 | + $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span( |
|
| 557 | 557 | EEH_Debug_Tools::pre_span($var) |
| 558 | 558 | ); |
| 559 | 559 | $result .= EEH_Debug_Tools::file_and_line($file, $line); |