Ticket #44177: wp_debug_backtrace_summary.diff
File wp_debug_backtrace_summary.diff, 3.1 KB (added by , 7 years ago) |
---|
-
wp-includes/functions.php
5408 5408 * back to the source of the issue. Default 0. 5409 5409 * @param bool $pretty Optional. Whether or not you want a comma separated string or raw 5410 5410 * array returned. Default true. 5411 * @param bool $include_args Optional. Whether or not you want to include arguments in the 5412 * output. Default false. 5411 5413 * @return string|array Either a string containing a reversed comma separated trace or an array 5412 5414 * of individual calls. 5413 5415 */ 5414 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {5416 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true, $include_args = false ) { 5415 5417 static $truncate_paths; 5416 5418 5417 if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) { 5418 $trace = debug_backtrace( false ); 5419 } else { 5420 $trace = debug_backtrace(); 5421 } 5419 $trace = debug_backtrace( false ); 5422 5420 5423 5421 $caller = array(); 5424 5422 $check_class = ! is_null( $ignore_class ); … … 5435 5433 if ( $skip_frames > 0 ) { 5436 5434 $skip_frames--; 5437 5435 } elseif ( isset( $call['class'] ) ) { 5438 if ( $check_class && $ignore_class == $call['class'] ) {5436 if ( $check_class && $ignore_class == $call['class'] ) 5439 5437 continue; // Filter out calls 5440 }5441 5442 5438 $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; 5443 5439 } else { 5444 if ( in_array( $call['function'], array( 'do_action', 'apply_filters' , 'do_action_ref_array', 'apply_filters_ref_array') ) ) {5440 if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) { 5445 5441 $caller[] = "{$call['function']}('{$call['args'][0]}')"; 5446 5442 } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { 5447 $filename = isset( $call['args'][0] ) ? $call['args'][0] : ''; 5448 $caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')"; 5443 $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')"; 5444 } elseif ( !$include_args || empty( $call['args'] ) ) { 5445 $caller[] = $call['function']; 5449 5446 } else { 5450 $caller[] = $call['function']; 5447 $args_as_text = array(); 5448 foreach ( $call['args'] as $arg ) { 5449 if ( is_string( $arg ) ) { 5450 $args_as_text[] = '"' . $arg . '"'; 5451 } elseif ( is_null ( $arg ) ) { 5452 $args_as_text[] = 'null'; 5453 } elseif ( is_bool( $arg ) || is_numeric( $arg ) ) { 5454 $args_as_text[] = $arg; 5455 } elseif ( is_object( $arg ) ) { 5456 $args_as_text[] = get_class($arg); 5457 } elseif ( is_callable ( $arg ) ) { 5458 $args_as_text[] = "Callable"; 5459 } elseif ( is_array( $arg ) ) { 5460 $args_as_text[] = "Array"; 5461 } else { 5462 $args_as_text[] = "?"; 5463 } 5464 } 5465 $caller[] = $call['function'] . "(" . join( ', ', $args_as_text ) . ")"; 5451 5466 } 5452 5467 } 5453 5468 }