use get_queried_object() wrappers throughout. See #14015
git-svn-id: http://svn.automattic.com/wordpress/trunk@16114 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d8eee3d47f
commit
e2efa78154
|
@ -173,9 +173,9 @@ function wp_admin_bar_shortlink_menu() {
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
function wp_admin_bar_edit_menu () {
|
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) )
|
if ( empty($current_object) )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -465,8 +465,6 @@ function wp_list_categories( $args = '' ) {
|
||||||
$output .= $show_option_none;
|
$output .= $show_option_none;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
global $wp_query;
|
|
||||||
|
|
||||||
if( !empty( $show_option_all ) )
|
if( !empty( $show_option_all ) )
|
||||||
if ( 'list' == $style )
|
if ( 'list' == $style )
|
||||||
$output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
|
$output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
|
||||||
|
@ -474,7 +472,7 @@ function wp_list_categories( $args = '' ) {
|
||||||
$output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
|
$output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
|
||||||
|
|
||||||
if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) )
|
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 )
|
if ( $hierarchical )
|
||||||
$depth = $r['depth'];
|
$depth = $r['depth'];
|
||||||
|
@ -1025,8 +1023,7 @@ function tag_description( $tag = 0 ) {
|
||||||
*/
|
*/
|
||||||
function term_description( $term = 0, $taxonomy = 'post_tag' ) {
|
function term_description( $term = 0, $taxonomy = 'post_tag' ) {
|
||||||
if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
|
if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
|
||||||
global $wp_query;
|
$term = get_queried_object();
|
||||||
$term = $wp_query->get_queried_object();
|
|
||||||
$taxonomy = $term->taxonomy;
|
$taxonomy = $term->taxonomy;
|
||||||
$term = $term->term_id;
|
$term = $term->term_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,7 @@ function get_current_blog_id() {
|
||||||
* @return string|null String on retrieve, null when displaying.
|
* @return string|null String on retrieve, null when displaying.
|
||||||
*/
|
*/
|
||||||
function wp_title($sep = '»', $display = true, $seplocation = '') {
|
function wp_title($sep = '»', $display = true, $seplocation = '') {
|
||||||
global $wpdb, $wp_locale, $wp_query;
|
global $wpdb, $wp_locale;
|
||||||
|
|
||||||
$m = get_query_var('m');
|
$m = get_query_var('m');
|
||||||
$year = get_query_var('year');
|
$year = get_query_var('year');
|
||||||
|
@ -555,7 +555,7 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
|
||||||
|
|
||||||
// If there's an author
|
// If there's an author
|
||||||
if ( is_author() ) {
|
if ( is_author() ) {
|
||||||
$author = $wp_query->get_queried_object();
|
$author = get_queried_object();
|
||||||
$title = $author->display_name;
|
$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.
|
* @return string|null Title when retrieving, null when displaying or failure.
|
||||||
*/
|
*/
|
||||||
function single_post_title($prefix = '', $display = true) {
|
function single_post_title($prefix = '', $display = true) {
|
||||||
global $wp_query, $post;
|
global $post;
|
||||||
|
|
||||||
if ( ! $post )
|
if ( ! $post )
|
||||||
$_post = $wp_query->get_queried_object();
|
$_post = get_queried_object();
|
||||||
else
|
else
|
||||||
$_post = $post;
|
$_post = $post;
|
||||||
|
|
||||||
|
@ -736,9 +736,7 @@ function single_tag_title( $prefix = '', $display = true ) {
|
||||||
* @return string|null Title when retrieving, null when displaying or failure.
|
* @return string|null Title when retrieving, null when displaying or failure.
|
||||||
*/
|
*/
|
||||||
function single_term_title( $prefix = '', $display = true ) {
|
function single_term_title( $prefix = '', $display = true ) {
|
||||||
global $wp_query;
|
$term = get_queried_object();
|
||||||
|
|
||||||
$term = $wp_query->get_queried_object();
|
|
||||||
|
|
||||||
if ( !$term )
|
if ( !$term )
|
||||||
return;
|
return;
|
||||||
|
@ -1630,8 +1628,6 @@ function feed_links( $args = array() ) {
|
||||||
* @param array $args Optional arguments.
|
* @param array $args Optional arguments.
|
||||||
*/
|
*/
|
||||||
function feed_links_extra( $args = array() ) {
|
function feed_links_extra( $args = array() ) {
|
||||||
global $wp_query;
|
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
/* translators: Separator between blog name and feed type in feed links */
|
/* translators: Separator between blog name and feed type in feed links */
|
||||||
'separator' => _x('»', 'feed link'),
|
'separator' => _x('»', 'feed link'),
|
||||||
|
@ -1657,12 +1653,12 @@ function feed_links_extra( $args = array() ) {
|
||||||
$href = get_post_comments_feed_link( $post->ID );
|
$href = get_post_comments_feed_link( $post->ID );
|
||||||
}
|
}
|
||||||
} elseif ( is_category() ) {
|
} 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 ));
|
$title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ));
|
||||||
$href = get_category_feed_link( $term->term_id );
|
$href = get_category_feed_link( $term->term_id );
|
||||||
} elseif ( is_tag() ) {
|
} 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 ));
|
$title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ));
|
||||||
$href = get_tag_feed_link( $term->term_id );
|
$href = get_tag_feed_link( $term->term_id );
|
||||||
|
|
|
@ -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 ) {
|
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
|
||||||
if ( is_null( $term ) ) {
|
if ( is_null( $term ) ) {
|
||||||
global $wp_query;
|
$term = get_queried_object();
|
||||||
$term = $wp_query->get_queried_object();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tax = get_taxonomy( $term->taxonomy );
|
$tax = get_taxonomy( $term->taxonomy );
|
||||||
|
|
|
@ -855,9 +855,7 @@ function get_category_template() {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_tag_template() {
|
function get_tag_template() {
|
||||||
global $wp_query;
|
$tag = get_queried_object();
|
||||||
|
|
||||||
$tag = $wp_query->get_queried_object();
|
|
||||||
$tag_name = $tag->slug;
|
$tag_name = $tag->slug;
|
||||||
$tag_id = $tag->term_id;
|
$tag_id = $tag->term_id;
|
||||||
|
|
||||||
|
@ -961,15 +959,13 @@ function get_front_page_template() {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_page_template() {
|
function get_page_template() {
|
||||||
global $wp_query;
|
$id = get_queried_object_id();
|
||||||
|
|
||||||
$id = (int) $wp_query->get_queried_object_id();
|
|
||||||
$template = get_post_meta($id, '_wp_page_template', true);
|
$template = get_post_meta($id, '_wp_page_template', true);
|
||||||
$pagename = get_query_var('pagename');
|
$pagename = get_query_var('pagename');
|
||||||
|
|
||||||
if ( !$pagename && $id > 0 ) {
|
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
|
// 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;
|
$pagename = $post->post_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,9 +1014,7 @@ function get_search_template() {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_single_template() {
|
function get_single_template() {
|
||||||
global $wp_query;
|
$object = get_queried_object();
|
||||||
|
|
||||||
$object = $wp_query->get_queried_object();
|
|
||||||
$templates = array('single-' . $object->post_type . '.php', 'single.php');
|
$templates = array('single-' . $object->post_type . '.php', 'single.php');
|
||||||
|
|
||||||
return get_query_template( 'single', $templates );
|
return get_query_template( 'single', $templates );
|
||||||
|
|
Loading…
Reference in New Issue