A not-so-pretty method to show pretty output ;-).
public static get_output ( mixed $var, string $title = '', boolean $escape = true, string $space = '', boolean $short = false, integer $depth ) : string | ||
$var | mixed | Variable to show. |
$title | string | (optional) Variable title. |
$escape | boolean | (optional) Whether to character escape the textual output. |
$space | string | (internal) Indentation spacing. |
$short | boolean | (internal) Short or normal annotation. |
$depth | integer | (internal) The depth of the current recursion. |
return | string |
/** * Create a property table for standard/custom properties. * * @since 1.2 * * @param array $properties Array of post type properties. * @param array $names Array of post type names. * @param string $table_name Translated name for this table. * @param bool $double Whether or not to repeat the row labels at the end of the table. */ protected function render_property_table($properties, $names, $table_name, $double) { /* Create header row. */ $header_row = ' <tr> <th>' . esc_html__('Property', self::DBPT_NAME) . '</th>'; foreach ($names as $name) { $header_row .= ' <th>' . esc_html($name) . '</th>'; } unset($name); if ($double === true) { $header_row .= ' <th class="' . self::DBPT_NAME . '-table-end">' . esc_html__('Property', self::DBPT_NAME) . '</th>'; } $header_row .= ' </tr>'; echo ' <h3>', esc_html($table_name), '</h3> <table class="debug-bar-table ', self::DBPT_NAME, '"> <thead> ', $header_row, ' </thead> <tfoot> ', $header_row, ' </tfoot> <tbody>'; unset($header_row); /* Sort. */ uksort($properties, 'strnatcasecmp'); /* Output. */ foreach ($properties as $key => $value) { echo ' <tr> <th>', esc_html($key), '</th>'; foreach ($names as $name) { echo ' <td>'; if (isset($value[$name])) { if (defined('Debug_Bar_Pretty_Output::VERSION')) { echo Debug_Bar_Pretty_Output::get_output($value[$name], '', true, '', true); // WPCS: XSS ok. } else { // An old version of the pretty output class was loaded. Debug_Bar_Pretty_Output::output($value[$name], '', true, '', true); } } else { echo ' '; } echo ' </td>'; } unset($name); if ($double === true) { echo ' <th class="', self::DBPT_NAME, '-table-end">', esc_html($key), '</th>'; // WPCS: XSS ok. } echo ' </tr>'; } unset($key, $value); echo ' </tbody> </table> '; }
/** * Print any type of variable with colour coding and a variable type indication. * * @param mixed $variable The variable to print. */ private function print_pretty_output($variable) { if (defined('Debug_Bar_Pretty_Output::VERSION')) { echo Debug_Bar_Pretty_Output::get_output($variable, '', true); // WPCS: XSS ok. } else { // An old version of the pretty output class was loaded. // Real possibility as there are several DB plugins using the pretty print class. Debug_Bar_Pretty_Output::output($variable, '', true); } }