pods_debug

Debugging common issues using this function saves a few lines and is compatible with.

Description

pods_debug( (string) $debug = '_null', (constant) $die = false, (string) $prefix = '_null' ); 

Parameters (3)

0. $debug — Optional. (string) => '_null'
The error message to be thrown / displayed
1. $die — Optional. (constant) => false
If set to true, a die() will occur, if set to (int) 2 then a wp_die() will occur
2. $prefix — Optional. (string) => '_null'
The prefix.

Usage

  1. if ( !function_exists( 'pods_debug' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'pods-custom-content-types-and-fields/includes/general.php'; 
  3.  
  4. // The error message to be thrown / displayed 
  5. $debug = '_null'; 
  6.  
  7. // If set to true, a die() will occur, if set to (int) 2 then a wp_die() will occur 
  8. $die = false; 
  9.  
  10. // The prefix. 
  11. $prefix = '_null'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pods_debug($debug, $die, $prefix); 
  15.  

Defined (1)

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

/includes/general.php  
  1. function pods_debug ( $debug = '_null', $die = false, $prefix = '_null' ) { 
  2. global $pods_debug; 
  3.  
  4. $pods_debug++; 
  5.  
  6. ob_start(); 
  7.  
  8. if ( '_null' !== $prefix ) 
  9. var_dump( $prefix ); 
  10.  
  11. if ( '_null' !== $debug ) 
  12. var_dump( $debug ); 
  13. else 
  14. var_dump( 'Pods Debug #' . $pods_debug ); 
  15.  
  16. $debug = ob_get_clean(); 
  17.  
  18. if ( false === strpos( $debug, "<pre class='xdebug-var-dump'" ) && ( !ini_get( 'xdebug.overload_var_dump' ) && !ini_get( 'html_errors' ) ) ) { 
  19. if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) 
  20. $debug = esc_html( $debug ); 
  21.  
  22. $debug = '<pre>' . $debug . '</pre>'; 
  23.  
  24. $debug = '<e>' . $debug; 
  25.  
  26. if ( 2 === $die ) 
  27. wp_die( $debug ); 
  28. elseif ( true === $die ) 
  29. die( $debug ); 
  30.  
  31. echo $debug;