/** * Render the tab content. */ public function render() { $wp_post_types = $GLOBALS['wp_post_types']; $names = array_keys($wp_post_types); $custom_pt = array(); $properties = array(); $custom_prop = array(); $labels = array(); $caps = array(); $count = count($wp_post_types); $count_cpt = 0; $double = $count > 4 ? true : false; // Whether to repeat the row labels on the other side of the table. if (!class_exists('Debug_Bar_Pretty_Output')) { require_once plugin_dir_path(__FILE__) . 'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php'; } // Limit recursion depth if possible - method available since DBPO v1.4. if (method_exists('Debug_Bar_Pretty_Output', 'limit_recursion')) { Debug_Bar_Pretty_Output::limit_recursion(2); } echo ' <h2><span>', esc_html__('Total Post Types:', self::DBPT_NAME), '</span>', absint($count), '</h2>'; if (is_array($wp_post_types) && $count > 0) { /** * Put the relevant info in arrays. */ foreach ($wp_post_types as $name => $post_type_obj) { $props = get_object_vars($post_type_obj); if (is_array($props) && $props !== array()) { foreach ($props as $key => $value) { // Add to list of custom post_types. if ($key === '_builtin' && $value !== true) { $custom_pt[] = $name; } if (is_object($value) && in_array($key, array('cap', 'labels'), true)) { $object_vars = get_object_vars($value); if (is_array($object_vars) && $object_vars !== array()) { foreach ($object_vars as $k => $v) { if ($key === 'cap') { $caps[$v][$name] = $v; } else { if ($key === 'labels') { $labels[$k][$name] = $v; } } } unset($k, $v); } unset($object_vars); } else { // Standard properties. if (property_exists($wp_post_types['post'], $key)) { $properties[$key][$name] = $value; } else { $custom_prop[$key][$name] = $value; } } } unset($key, $value); } unset($props); } unset($name, $post_type_obj); if ($custom_pt !== array()) { $count_cpt = count($custom_pt); echo ' <h2><span>', esc_html__('Custom Post Types:', self::DBPT_NAME), '</span>', absint($count_cpt), '</h2>'; } /* Create the properties table for the standard properties. */ if (count($properties) > 0) { $this->render_property_table($properties, $names, __('Standard Post Type Properties:', self::DBPT_NAME), $double); } /* Create the properties table for the custom properties. */ if (count($custom_prop) > 0) { $this->render_property_table($custom_prop, $custom_pt, __('Custom Post Type Properties:', self::DBPT_NAME), $count_cpt > 4 ? true : false); } /* Create the capabilities table. */ if (count($caps) > 0) { $this->render_capability_table($caps, $names, $double); } /* Create the table for the defined labels. */ if (count($labels) > 0) { $this->render_property_table($labels, $names, __('Defined Labels:', self::DBPT_NAME), $double); } } else { echo '<p>', esc_html__('No post types found.', self::DBPT_NAME), '</p>'; } unset($names, $properties, $caps); // Unset recursion depth limit if possible - method available since DBPO v1.4. if (method_exists('Debug_Bar_Pretty_Output', 'unset_recursion_limit')) { Debug_Bar_Pretty_Output::unset_recursion_limit(); } }
/** * Unset recursion depth limit for the pretty output class. * * @internal Method available since DBPO v1.4. */ private function reset_debug_bar_pretty_output() { if (method_exists('Debug_Bar_Pretty_Output', 'unset_recursion_limit')) { Debug_Bar_Pretty_Output::unset_recursion_limit(); } }