| 3531 | * Output formatted backtrace |
| 3532 | * |
| 3533 | * @subpackage Debug |
| 3534 | * @since 3.3 |
| 3535 | */ |
| 3536 | function wp_debug_backtrace( $echo = true ) { |
| 3537 | $all = array_reverse( debug_backtrace() ); |
| 3538 | $trace = ''; |
| 3539 | $i = 0; |
| 3540 | $b1 = '<i>'; |
| 3541 | $b2 = '</i>'; |
| 3542 | |
| 3543 | foreach ( $all as $key => $call ) { |
| 3544 | if ( $call['function'] == __FUNCTION__ || $call['function'] == '_doing_it_wrong' ) // skip __FUNCTION__ and _doing_it_wrong() calls |
| 3545 | continue; |
| 3546 | |
| 3547 | ++$i; |
| 3548 | $func = isset( $call['class'] ) ? "{$call['class']}->{$call['function']}" : $call['function']; |
| 3549 | |
| 3550 | if ( strpos( $call['file'], '/plugins/' ) !== false || strpos( $call['file'], '/themes/' ) !== false ) |
| 3551 | $b1 = $b2 = ''; |
| 3552 | |
| 3553 | $trace .= "{$i} $b1{$call['file']}, " . __('line:') . " {$call['line']}, " . __('function:') . " {$func} $b2\n"; |
| 3554 | } |
| 3555 | |
| 3556 | if ( !$echo ) |
| 3557 | return $trace; |
| 3558 | |
| 3559 | echo '<p>' . __('Backtrace:') . "</p>\n<pre style='overflow:auto;'>$trace</pre>"; |
| 3560 | } |
| 3561 | |
| 3562 | /** |