/** * Prints out better looking debug information about a variable. * This echoes directly where it is called. * @param mixed1, [ $mixed2, $mixed3, ...] */ function debug() { if (!WP_DEBUG) { return; } $mixed = func_get_args(); if (count($mixed) === 1) { $mixed = $mixed[0]; } $context = "In unknown context at unknown line"; foreach (debug_backtrace() as $idx => $file) { if ($file['file'] != __FILE__) { $last = explode(DIRECTORY_SEPARATOR, $file['file']); $context = sprintf("In %s at line %s: ", $last[count($last) - 1], $file['line']); break; } } foreach (func_get_args() as $variable) { $exported = Debugger::export($variable, 5); if (Strata::isBundledServer()) { Strata::app()->getLogger("StrataConsole")->debug("\n\n<warning>{$context}</warning>\n" . $exported . "\n\n"); } if (Strata::isCommandLineInterface()) { echo "{$context}\n{$exported}\n"; } else { echo "<div style=\"" . Debugger::HTML_STYLES . "\"><pre>{$context}<br>" . $exported . "</pre></div>"; } } }
/** * Fetches the terms matching the TaxonomyQuery. * @return array */ public function fetch() { $this->logQueryStart(); $results = null; if (is_array($this->termLookupMode)) { $queryLog = "get_term_by(" . Debugger::export($this->termLookupMode[0]) . ", " . Debugger::export($this->termLookupMode[1]) . ", " . Debugger::export($this->taxnomony) . ")"; $results = get_term_by($this->termLookupMode[0], $this->termLookupMode[1], $this->taxnomony); } elseif (is_null($this->postId)) { $queryLog = "get_terms(" . Debugger::export($this->taxnomony) . ", " . Debugger::export($this->filters) . ")"; $results = get_terms($this->taxnomony, $this->filters); } else { $queryLog = "get_the_terms(" . Debugger::export($this->postId) . ", " . Debugger::export($this->taxnomony) . ", " . Debugger::export($this->filters) . ")"; $results = get_the_terms($this->postId, $this->taxnomony, $this->filters); } $this->logQueryCompletion($queryLog); if ($results === false) { return array(); } if (!is_array($results)) { $results = array($results); } return $results; }
/** * Used to express the contents of the model entity more clearly * when debugged. * @return array */ public function __debugInfo() { $objectVars = array(); if (!is_null($this)) { foreach (get_object_vars($this) as $key => $value) { $objectVars[$key] = Debugger::export($value); } } return array_merge($objectVars, $this->toArray()); }