Render the table output.
public static render_table ( array $array, string $col1, string $col2, string | array $class = null, string $deprecated = null ) : void | ||
$array | array | Array to be shown in the table. |
$col1 | string | Label for the first table column. |
$col2 | string | Label for the second table column. |
$class | string | array | One or more CSS classes to add to the table. |
$deprecated | string | ==Deprecated argument. |
return | void |
/** * Helper method to render the output in a table * * @param array $array Array to be shown in the table * @param string $col1 Label for the first table column * @param string $col2 Label for the second table column * @param string|array $class One or more CSS classes to add to the table */ public function dbc_render_table($array, $col1 = null, $col2 = null, $class = null) { $classes = self::DBC_NAME; if (isset($class)) { if (is_string($class) && $class !== '') { $classes .= ' ' . $class; } else { if (is_array($class) && $class !== array()) { $classes = $classes . ' ' . implode(' ', $class); } } } $col1 = isset($col1) ? $col1 : __('Name', self::DBC_NAME); $col2 = isset($col2) ? $col2 : __('Value', self::DBC_NAME); uksort($array, 'strnatcasecmp'); if (defined('Debug_Bar_Pretty_Output::VERSION')) { echo Debug_Bar_Pretty_Output::get_table($array, $col1, $col2, $classes); // xss: ok } else { // An old version of the pretty output class was loaded Debug_Bar_Pretty_Output::render_table($array, $col1, $col2, $classes); } }
/** * Render the screen info. * * @return string */ public function screen_info_render() { /* Set parentage of current page Isn't set yet as it is set from admin_header.php which is run after the admin bar has loaded on the admin side */ if (isset($GLOBALS['current_screen']) && is_object($GLOBALS['current_screen']) && (isset($GLOBALS['parent_file']) && is_string($GLOBALS['parent_file']) && $GLOBALS['parent_file'] !== '')) { $GLOBALS['current_screen']->set_parentage($GLOBALS['parent_file']); } $screen = get_current_screen(); if (isset($screen) && is_object($screen)) { $properties = get_object_vars($screen); if (is_array($properties) && $properties !== array()) { $output = ' <h2><span>' . esc_html__('Screen:', $this->plugin_slug) . '</span>' . esc_html($screen->id) . '</h2> <h2><span>' . esc_html__('Properties:', $this->plugin_slug) . '</span>' . count($properties) . '</h2>'; uksort($properties, 'strnatcasecmp'); if (!class_exists('Debug_Bar_Pretty_Output')) { require_once plugin_dir_path(__FILE__) . 'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php'; } if (defined('Debug_Bar_Pretty_Output::VERSION')) { add_filter('db_pretty_output_table_header', array($this, 'filter_pretty_output_table_header_row')); add_filter('db_pretty_output_table_body_row', array($this, 'filter_pretty_output_table_body_row'), 10, 2); $output .= Debug_Bar_Pretty_Output::get_table($properties, __('Property', $this->plugin_slug), __('Value', $this->plugin_slug), $this->plugin_slug); remove_filter('db_pretty_output_table_header', array($this, 'filter_pretty_output_table_header_row')); remove_filter('db_pretty_output_table_body_row', array($this, 'filter_pretty_output_table_body_row'), 10, 2); } else { /* An old version of the pretty output class was loaded, the explanations will not be added to the table */ ob_start(); Debug_Bar_Pretty_Output::render_table($properties, __('Property', $this->plugin_slug), __('Value', $this->plugin_slug), $this->plugin_slug); $output .= ob_get_contents(); ob_end_clean(); } } } else { $output = '<h2>' . esc_html__('No Screen Info Found', $this->plugin_slug) . '</h2>'; } $output .= '<p>' . sprintf(esc_html__('For more information, see the %sCodex on WP_Screen', $this->plugin_slug), '<a href="http://codex.wordpress.org/Class_Reference/WP_Screen" target="_blank" title="' . esc_attr__('View the WordPress codex on WP Screen', $this->plugin_slug) . '">') . '</a></p>'; return $output; }