public static function inspect($data, $expand_objects = false, $max_depth = 2, $echo = true) { it_classes_load('it-debug.php'); $args = compact('expand_objects', 'max_depth', 'echo'); return ITDebug::inspect($data, $args); }
public static function developer_warn($message, $show_backtrace = true) { if (!WP_DEBUG) { return; } it_classes_load('it-debug.php'); $backtrace = ITDebug::get_backtrace(array('offset' => 2, 'remove_abspath' => false)); echo "<pre style='color:black;background:white;padding:15px;font-family:\"Courier New\",Courier,monospace;font-size:12px;text-align:left;max-width:100%;'>"; echo "<strong>Developer Notice</strong>\n"; echo " {$message}\n\n"; echo "<strong>Stack Backtrace</strong>\n"; foreach ($backtrace as $trace) { echo ' ' . ITDebug::get_backtrace_description($trace) . "\n"; } echo "</pre>\n"; }
public static function _inspect_dive($data, $expand_objects, $max_depth, $depth = 0, $show_array_header = true) { $pad = ITUtility::pad($depth, ' '); if (is_string($data)) { if ('' === $data) { return "<strong>[empty string]</strong>"; } else { return htmlspecialchars($data); } } if (is_bool($data)) { return $data ? '<strong>[boolean] true</strong>' : '<strong>[boolean] false</strong>'; } if (is_null($data)) { return '<strong>null</strong>'; } if (is_object($data)) { $class_name = get_class($data); $retval = "<strong>Object</strong> {$class_name}"; if (!$expand_objects || $depth == $max_depth) { return $retval; } $vars = get_object_vars($data); if (empty($vars)) { $vars = ''; } else { $vars = ITDebug::_inspect_dive($vars, $expand_objects, $max_depth, $depth, false); } $retval .= "{$vars}"; return $retval; } if (is_array($data)) { $retval = $show_array_header ? '<strong>Array</strong>' : ''; if (empty($data)) { return "{$retval}()"; } if ($depth == $max_depth) { return "{$retval}( " . count($data) . " )"; } $max = 0; foreach (array_keys($data) as $index) { if (strlen($index) > $max) { $max = strlen($index); } } foreach ($data as $index => $val) { $spaces = ITUtility::pad($max - strlen($index), ' '); $retval .= "\n{$pad}" . htmlspecialchars($index) . "{$spaces} <strong>=></strong> " . ITDebug::_inspect_dive($val, $expand_objects, $max_depth, $depth + 1); } return $retval; } return '<strong>[' . gettype($data) . ']</strong> ' . $data; }