From e2efa781545868014a0678ccadcf6b95638d0f82 Mon Sep 17 00:00:00 2001 From: scribu Date: Sun, 31 Oct 2010 11:02:17 +0000 Subject: [PATCH] use get_queried_object() wrappers throughout. See #14015 git-svn-id: http://svn.automattic.com/wordpress/trunk@16114 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/admin-bar.php | 4 ++-- wp-includes/category-template.php | 7 ++----- wp-includes/general-template.php | 18 +++++++----------- wp-includes/link-template.php | 3 +-- wp-includes/theme.php | 14 ++++---------- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index 796d91fad3..2bdcc71f10 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -173,9 +173,9 @@ function wp_admin_bar_shortlink_menu() { * @since 3.1.0 */ function wp_admin_bar_edit_menu () { - global $wp_admin_bar, $wp_query; + global $wp_admin_bar; - $current_object = $wp_query->get_queried_object(); + $current_object = get_queried_object(); if ( empty($current_object) ) return; diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 349e0134b2..caf93632a7 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -465,8 +465,6 @@ function wp_list_categories( $args = '' ) { $output .= $show_option_none; } } else { - global $wp_query; - if( !empty( $show_option_all ) ) if ( 'list' == $style ) $output .= '
  • ' . $show_option_all . '
  • '; @@ -474,7 +472,7 @@ function wp_list_categories( $args = '' ) { $output .= '' . $show_option_all . ''; if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) ) - $r['current_category'] = $wp_query->get_queried_object_id(); + $r['current_category'] = get_queried_object_id(); if ( $hierarchical ) $depth = $r['depth']; @@ -1025,8 +1023,7 @@ function tag_description( $tag = 0 ) { */ function term_description( $term = 0, $taxonomy = 'post_tag' ) { if ( !$term && ( is_tax() || is_tag() || is_category() ) ) { - global $wp_query; - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); $taxonomy = $term->taxonomy; $term = $term->term_id; } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 62234d4b4f..be6967e2c1 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -526,7 +526,7 @@ function get_current_blog_id() { * @return string|null String on retrieve, null when displaying. */ function wp_title($sep = '»', $display = true, $seplocation = '') { - global $wpdb, $wp_locale, $wp_query; + global $wpdb, $wp_locale; $m = get_query_var('m'); $year = get_query_var('year'); @@ -555,7 +555,7 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { // If there's an author if ( is_author() ) { - $author = $wp_query->get_queried_object(); + $author = get_queried_object(); $title = $author->display_name; } @@ -633,10 +633,10 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { * @return string|null Title when retrieving, null when displaying or failure. */ function single_post_title($prefix = '', $display = true) { - global $wp_query, $post; + global $post; if ( ! $post ) - $_post = $wp_query->get_queried_object(); + $_post = get_queried_object(); else $_post = $post; @@ -736,9 +736,7 @@ function single_tag_title( $prefix = '', $display = true ) { * @return string|null Title when retrieving, null when displaying or failure. */ function single_term_title( $prefix = '', $display = true ) { - global $wp_query; - - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); if ( !$term ) return; @@ -1630,8 +1628,6 @@ function feed_links( $args = array() ) { * @param array $args Optional arguments. */ function feed_links_extra( $args = array() ) { - global $wp_query; - $defaults = array( /* translators: Separator between blog name and feed type in feed links */ 'separator' => _x('»', 'feed link'), @@ -1657,12 +1653,12 @@ function feed_links_extra( $args = array() ) { $href = get_post_comments_feed_link( $post->ID ); } } elseif ( is_category() ) { - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name )); $href = get_category_feed_link( $term->term_id ); } elseif ( is_tag() ) { - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name )); $href = get_tag_feed_link( $term->term_id ); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 5444df55fc..cfcdfd2abc 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -716,8 +716,7 @@ function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { */ function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { if ( is_null( $term ) ) { - global $wp_query; - $term = $wp_query->get_queried_object(); + $term = get_queried_object(); } $tax = get_taxonomy( $term->taxonomy ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 2eebafe815..2608edcbf6 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -855,9 +855,7 @@ function get_category_template() { * @return string */ function get_tag_template() { - global $wp_query; - - $tag = $wp_query->get_queried_object(); + $tag = get_queried_object(); $tag_name = $tag->slug; $tag_id = $tag->term_id; @@ -961,15 +959,13 @@ function get_front_page_template() { * @return string */ function get_page_template() { - global $wp_query; - - $id = (int) $wp_query->get_queried_object_id(); + $id = get_queried_object_id(); $template = get_post_meta($id, '_wp_page_template', true); $pagename = get_query_var('pagename'); if ( !$pagename && $id > 0 ) { // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object - $post = $wp_query->get_queried_object(); + $post = get_queried_object(); $pagename = $post->post_name; } @@ -1018,9 +1014,7 @@ function get_search_template() { * @return string */ function get_single_template() { - global $wp_query; - - $object = $wp_query->get_queried_object(); + $object = get_queried_object(); $templates = array('single-' . $object->post_type . '.php', 'single.php'); return get_query_template( 'single', $templates );