Move checks for `post_type` being an array inline. See [25291], [25292], #18614.

Built from https://develop.svn.wordpress.org/trunk@25312


git-svn-id: http://core.svn.wordpress.org/trunk@25274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2013-09-10 03:02:10 +00:00
parent 7af06e7ab3
commit 8bd9659d0d
4 changed files with 27 additions and 9 deletions

View File

@ -579,7 +579,10 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
// If there's a post type archive
if ( is_post_type_archive() ) {
$post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object->has_archive )
$title = post_type_archive_title( '', false );
}
@ -706,7 +709,11 @@ function post_type_archive_title( $prefix = '', $display = true ) {
if ( ! is_post_type_archive() )
return;
$post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$post_type_obj = get_post_type_object( $post_type );
$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
if ( $display )
@ -1689,7 +1696,11 @@ function feed_links_extra( $args = array() ) {
$href = get_post_comments_feed_link( $post->ID );
}
} elseif ( is_post_type_archive() ) {
$post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$post_type_obj = get_post_type_object( $post_type );
$title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
$href = get_post_type_archive_feed_link( $post_type_obj->name );
} elseif ( is_category() ) {

View File

@ -1058,9 +1058,6 @@ function get_post_type( $post = null ) {
function get_post_type_object( $post_type ) {
global $wp_post_types;
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
if ( empty($wp_post_types[$post_type]) )
return null;

View File

@ -3076,7 +3076,10 @@ class WP_Query {
_make_cat_compat( $this->queried_object );
}
} elseif ( $this->is_post_type_archive ) {
$this->queried_object = get_post_type_object( $this->get('post_type') );
$post_type = $this->get( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$this->queried_object = get_post_type_object( $post_type );
} elseif ( $this->is_posts_page ) {
$page_for_posts = get_option('page_for_posts');
$this->queried_object = get_post( $page_for_posts );
@ -3152,7 +3155,10 @@ class WP_Query {
if ( empty( $post_types ) || ! $this->is_post_type_archive )
return (bool) $this->is_post_type_archive;
$post_type_object = get_post_type_object( $this->get( 'post_type' ) );
$post_type = $this->get( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$post_type_object = get_post_type_object( $post_type );
return in_array( $post_type_object->name, (array) $post_types );
}

View File

@ -80,7 +80,11 @@ function get_archive_template() {
* @return string
*/
function get_post_type_archive_template() {
$obj = get_post_type_object( get_query_var( 'post_type' ) );
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) )
$post_type = reset( $post_type );
$obj = get_post_type_object( $post_type );
if ( ! $obj->has_archive )
return '';