Make WordPress Core

Ticket #18614: 18614.2.diff

File 18614.2.diff, 4.2 KB (added by nacin, 13 years ago)
  • wp-includes/template-loader.php

     
    2222        $template = false;
    2323        if     ( is_404()            && $template = get_404_template()            ) :
    2424        elseif ( is_search()         && $template = get_search_template()         ) :
     25        elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    2526        elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    2627        elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    2728        elseif ( is_home()           && $template = get_home_template()           ) :
  • wp-includes/theme.php

     
    793793}
    794794
    795795/**
     796 * Retrieve path of post type archive template in current or parent template.
     797 *
     798 * @since 3.4.0
     799 *
     800 * @return string
     801 */
     802function get_post_type_archive_template() {
     803        $obj = get_post_type_object( get_query_var( 'post_type' ) );
     804        if ( ! $obj->has_archive )
     805                return '';
     806
     807        return get_archive_template();
     808}
     809
     810/**
    796811 * Retrieve path of author template in current or parent template.
    797812 *
    798813 * @since 1.5.0
  • wp-includes/query.php

     
    30233023                if ( empty( $post_types ) || !$this->is_post_type_archive )
    30243024                        return (bool) $this->is_post_type_archive;
    30253025
    3026                 $post_type_object = $this->get_queried_object();
     3026                $post_type_object = get_post_type_object( $this->get('post_type') );
    30273027
    30283028                return in_array( $post_type_object->name, (array) $post_types );
    30293029        }
  • wp-includes/general-template.php

     
    542542                $title = single_post_title( '', false );
    543543        }
    544544
     545        // If there's a post type archive
     546        if ( is_post_type_archive() ) {
     547                $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
     548                if ( ! $post_type_object->has_archive )
     549                        $title = post_type_archive_title( '', false );
     550        }
     551
    545552        // If there's a category or tag
    546553        if ( is_category() || is_tag() ) {
    547554                $title = single_term_title( '', false );
     
    560567                $title = $author->display_name;
    561568        }
    562569
    563         // If there's a post type archive
    564         if ( is_post_type_archive() )
     570        // Post type archives with has_archive should override terms.
     571        if ( is_post_type_archive() && $post_type_object->has_archive ) {
    565572                $title = post_type_archive_title( '', false );
     573        }
    566574
    567575        // If there's a month
    568576        if ( is_archive() && !empty($m) ) {
     
    661669        if ( ! is_post_type_archive() )
    662670                return;
    663671
    664         $post_type_obj = get_queried_object();
     672        $post_type_obj = get_post_type_object( get_query_var('post_type') );
     673
    665674        $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
    666675
    667676        if ( $display )
     
    16331642                'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
    16341643                /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
    16351644                'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
     1645                /* translators: 1: blog name, 2: separator(raquo), 3: generic feed */
     1646                'generic'     => __('%1$s %2$s %3$s Feed'),
    16361647        );
    16371648
    16381649        $args = wp_parse_args( $args, $defaults );
    16391650
    1640         if ( is_single() || is_page() ) {
     1651        if ( is_singular() ) {
    16411652                $id = 0;
    16421653                $post = &get_post( $id );
    16431654
     
    16451656                        $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );
    16461657                        $href = get_post_comments_feed_link( $post->ID );
    16471658                }
     1659        } elseif ( is_post_type_archive() ) {
     1660                $post_type_obj = get_post_type_object( get_query_var('post_type') );
     1661
     1662                $title = sprintf( $args['generic'], get_bloginfo('name'), $args['separator'], $post_type_obj->labels->name );
     1663                $href = get_post_type_archive_feed_link( $post_type_obj->name );
    16481664        } elseif ( is_category() ) {
    16491665                $term = get_queried_object();
    16501666