title( __( 'Notices / Warnings', 'debug-bar' ) ); $this->real_error_handler = set_error_handler( array( &$this, 'error_handler' ) ); } function is_visible() { return count( $this->notices ) || count( $this->warnings ); } function debug_bar_classes( $classes ) { if ( count( $this->warnings ) ) { $classes[] = 'debug-bar-php-warning-summary'; } elseif ( count( $this->notices ) ) { $classes[] = 'debug-bar-php-notice-summary'; } return $classes; } function error_handler( $type, $message, $file, $line ) { $_key = md5( $file . ':' . $line . ':' . $message ); if ( ! defined( 'E_DEPRECATED' ) ) { define( 'E_DEPRECATED', 8192 ); } if ( ! defined( 'E_USER_DEPRECATED' ) ) { define( 'E_USER_DEPRECATED', 16384 ); } switch ( $type ) { case E_WARNING: case E_USER_WARNING: $this->warnings[ $_key ] = array( $file . ':' . $line, $message, wp_debug_backtrace_summary( __CLASS__ ), ); break; case E_NOTICE: case E_USER_NOTICE: $this->notices[ $_key ] = array( $file . ':' . $line, $message, wp_debug_backtrace_summary( __CLASS__ ), ); break; case E_STRICT: // TODO break; case E_DEPRECATED: case E_USER_DEPRECATED: // TODO break; case 0: // TODO break; } if ( null != $this->real_error_handler ) { return call_user_func( $this->real_error_handler, $type, $message, $file, $line ); } else { return false; } } function render() { echo "
"; echo '

', __( 'Total Warnings:', 'debug-bar' ), '', number_format_i18n( count( $this->warnings ) ), "

\n"; echo '

', __( 'Total Notices:', 'debug-bar' ), '', number_format_i18n( count( $this->notices ) ), "

\n"; if ( count( $this->warnings ) ) { echo '
    '; foreach ( $this->warnings as $location_message_stack ) { list( $location, $message, $stack ) = $location_message_stack; echo '
  1. ', __( 'WARNING:', 'debug-bar' ), ' '; echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message ); echo '
    '; echo $stack; echo '
  2. '; } echo '
'; } if ( count( $this->notices ) ) { echo '
    '; foreach ( $this->notices as $location_message_stack ) { list( $location, $message, $stack ) = $location_message_stack; echo '
  1. ', __( 'NOTICE:', 'debug-bar' ), ' '; echo str_replace( ABSPATH, '', $location ) . ' - ' . strip_tags( $message ); echo '
    '; echo $stack; echo '
  2. '; } echo '
'; } echo "
"; } }