$count = 0; foreach ( $keys as $key ) { if ( $count == $width ) { $string .= "\n" . $spaces . " ..."; break; } $string .= "\n" . $spaces . " [$key] => "; $string .= $this->var_debug( $variable[$key], $strlen, $width, $depth, $i + 1, $objects ); $count ++; } $string .= "\n" . $spaces . '}'; } break; case 'object': $id = array_search( $variable, $objects, true ); if ( $id !== false ) { $string .= get_class( $variable ) . '#' . ( $id + 1 ) . ' {...}'; } else if ( $i == $depth ) { $string .= get_class( $variable ) . ' {...}'; } else { $id = array_push( $objects, $variable ); $array = ( array ) $variable; $spaces = str_repeat( ' ', $i * 2 ); $string .= get_class( $variable ) . "#$id\n" . $spaces . '{'; $properties = array_keys( $array ); foreach ( $properties as $property ) { $name = str_replace( "\0", ':', trim( $property ) ); $string .= "\n" . $spaces . " [$name] => "; $string .= $this->var_debug( $array[$property], $strlen, $width, $depth, $i + 1, $objects ); } $string .= "\n" . $spaces . '}'; } break; } if ( $i > 0 ) { return $string; } $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); do { $caller = array_shift( $backtrace ); } while ( $caller && ! isset( $caller['file'] ) ); if ( $caller ) { $string = $caller['file'] . ':' . $caller['line'] . "\n" . $string; } echo nl2br( str_replace( ' ', ' ', htmlentities( $string ) ) ); } /** * Get HTML code with backtrace information for given exception. * * @param Exception $exception * * @return string HTML code. */ protected function _get_backtrace( $exception ) { $backtrace = ''; $trace = nl2br( $exception->getTraceAsString() ); $ident = sha1( $trace ); if ( ! empty( $trace ) ) { $request_uri = ''; if ( isset( $_SERVER['REQUEST_URI'] ) ) { // Remove all whitespaces $request_uri = preg_replace( '/\s+/', '', $_SERVER['REQUEST_URI'] ); // Convert request URI and strip tags $request_uri = strip_tags( htmlspecialchars_decode( $request_uri ) ); // Limit URL to 100 characters $request_uri = substr($request_uri, 0, 100); } $button_label = __( 'Toggle error details', AI1EC_PLUGIN_NAME ); $title = __( 'Error Details:', AI1EC_PLUGIN_NAME ); $backtrace = << jQuery( function($) { $( "a[data-rel='$ident']" ).click( function() { jQuery( "#ai1ec-error-$ident" ).slideToggle( "fast" ); return false; }); }); $button_label JAVASCRIPT; } return $backtrace; } }