wp_debug_backtrace_summary

Return a comma-separated string of functions that have been called to get to the current point in code.

Description

(string|array) wp_debug_backtrace_summary( (constant) $ignore_class = null, (int) $skip_frames = 0, (bool) $pretty = true ); 

Returns (string|array)

Either a string containing a reversed comma separated trace or an array of individual calls.

Parameters (3)

0. $ignore_class — Optional. (constant) => null
A class to ignore all function calls within - useful when you want to just give info about the callee. Default null.
1. $skip_frames — Optional. (int)
A number of stack frames to skip - useful for unwinding back to the source of the issue. Default 0.
2. $pretty — Optional. (bool) => true
Whether or not you want a comma separated string or raw array returned. Default true.

Usage

  1. if ( !function_exists( 'wp_debug_backtrace_summary' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Optional. A class to ignore all function calls within - useful 
  5. // when you want to just give info about the callee. Default null. 
  6. $ignore_class = null; 
  7.  
  8. // Optional. A number of stack frames to skip - useful for unwinding 
  9. // back to the source of the issue. Default 0. 
  10. $skip_frames = -1; 
  11.  
  12. // Optional. Whether or not you want a comma separated string or raw 
  13. // array returned. Default true. 
  14. $pretty = true; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wp_debug_backtrace_summary($ignore_class, $skip_frames, $pretty); 
  18.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { 
  2. if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) 
  3. $trace = debug_backtrace( false ); 
  4. else 
  5. $trace = debug_backtrace(); 
  6.  
  7. $caller = array(); 
  8. $check_class = ! is_null( $ignore_class ); 
  9. $skip_frames++; // skip this function 
  10.  
  11. foreach ( $trace as $call ) { 
  12. if ( $skip_frames > 0 ) { 
  13. $skip_frames--; 
  14. } elseif ( isset( $call['class'] ) ) { 
  15. if ( $check_class && $ignore_class == $call['class'] ) 
  16. continue; // Filter out calls 
  17.  
  18. $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; 
  19. } else { 
  20. if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) { 
  21. $caller[] = "{$call['function']}('{$call['args'][0]}')"; 
  22. } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { 
  23. $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')"; 
  24. } else { 
  25. $caller[] = $call['function']; 
  26. if ( $pretty ) 
  27. return join( ', ', array_reverse( $caller ) ); 
  28. else 
  29. return $caller;