title( __('WP Query', 'debug-bar') ); } function prerender() { $this->set_visible( defined('SAVEQUERIES') && SAVEQUERIES ); } function render() { global $template, $wp_query; $queried_object = get_queried_object(); if ( $queried_object && isset( $queried_object->post_type ) ) $post_type_object = get_post_type_object( $queried_object->post_type ); echo "
"; echo '

Queried Object ID:' . get_queried_object_id() . "

\n"; // Determine the query type. Follows the template loader order. $type = ''; if ( is_404() ) $type = '404'; elseif ( is_search() ) $type = 'Search'; elseif ( is_tax() ) $type = 'Taxonomy'; elseif ( is_front_page() ) $type = 'Front Page'; elseif ( is_home() ) $type = 'Home'; elseif ( is_attachment() ) $type = 'Attachment'; elseif ( is_single() ) $type = 'Single'; elseif ( is_page() ) $type = 'Page'; elseif ( is_category() ) $type = 'Category'; elseif ( is_tag() ) $type = 'Tag'; elseif ( is_author() ) $type = 'Author'; elseif ( is_date() ) $type = 'Date'; elseif ( is_archive() ) $type = 'Archive'; elseif ( is_paged() ) $type = 'Paged'; if ( !empty($type) ) echo '

Query Type:' . $type . "

\n"; if ( !empty($template) ) echo '

Query Template:' . basename($template) . "

\n"; $show_on_front = get_option( 'show_on_front' ); $page_on_front = get_option( 'page_on_front' ); $page_for_posts = get_option( 'page_for_posts' ); echo '

Show on Front:' . $show_on_front . "

\n"; if ( 'page' == $show_on_front ) { echo '

Page for Posts:' . $page_for_posts . "

\n"; echo '

Page on Front:' . $page_on_front . "

\n"; } if ( isset( $post_type_object ) ) echo '

Post Type:' . $post_type_object->labels->singular_name . "

\n"; echo '
'; if ( empty($wp_query->query) ) $query = 'None'; else $query = http_build_query( $wp_query->query ); echo '

Query Arguments:

'; echo '

' . esc_html( $query ) . '

'; if ( ! empty($wp_query->request) ) { echo '

Query SQL:

'; echo '

' . esc_html( $wp_query->request ) . '

'; } if ( ! is_null( $queried_object ) ) { echo '

Queried Object:

'; echo '
    '; foreach ($queried_object as $key => $value) { // See: http://wordpress.org/support/topic/plugin-debug-bar-custom-post-type-archive-catchable-fatal-error // TODO: Fix better if ( is_object( $value ) ) { echo '
  1. ' . $key . ' =>
      '; foreach ( $value as $_key => $_value ) echo '
    1. ' . $_key . ' => ' . $_value . '
    2. '; echo '
  2. '; } else { echo '
  3. ' . $key . ' => ' . $value . '
  4. '; } } echo '
'; } echo '
'; } }