Make WordPress Core

Ticket #18614: 18614.3.diff

File 18614.3.diff, 4.2 KB (added by wonderboymusic, 11 years ago)
  • wp-includes/general-template.php

    diff --git wp-includes/general-template.php wp-includes/general-template.php
    index b586762..2d83d64 100644
    function wp_title($sep = '»', $display = true, $seplocation = '') { 
    577577                $title = single_post_title( '', false );
    578578        }
    579579
     580        // If there's a post type archive
     581        if ( is_post_type_archive() ) {
     582                $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
     583                if ( ! $post_type_object->has_archive )
     584                        $title = post_type_archive_title( '', false );
     585        }
     586
    580587        // If there's a category or tag
    581588        if ( is_category() || is_tag() ) {
    582589                $title = single_term_title( '', false );
    function wp_title($sep = '»', $display = true, $seplocation = '') { 
    595602                $title = $author->display_name;
    596603        }
    597604
    598         // If there's a post type archive
    599         if ( is_post_type_archive() )
     605        // Post type archives with has_archive should override terms.
     606        if ( is_post_type_archive() && $post_type_object->has_archive )
    600607                $title = post_type_archive_title( '', false );
    601608
    602609        // If there's a month
    function post_type_archive_title( $prefix = '', $display = true ) { 
    696703        if ( ! is_post_type_archive() )
    697704                return;
    698705
    699         $post_type_obj = get_queried_object();
     706        $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
    700707        $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
    701708
    702709        if ( $display )
    function feed_links_extra( $args = array() ) { 
    16701677
    16711678        $args = wp_parse_args( $args, $defaults );
    16721679
    1673         if ( is_single() || is_page() ) {
     1680        if ( is_singular() ) {
    16741681                $id = 0;
    16751682                $post = get_post( $id );
    16761683
    function feed_links_extra( $args = array() ) { 
    16781685                        $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );
    16791686                        $href = get_post_comments_feed_link( $post->ID );
    16801687                }
     1688        } elseif ( is_post_type_archive() ) {
     1689                $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) );
     1690                $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
     1691                $href = get_post_type_archive_feed_link( $post_type_obj->name );
    16811692        } elseif ( is_category() ) {
    16821693                $term = get_queried_object();
    16831694
  • wp-includes/query.php

    diff --git wp-includes/query.php wp-includes/query.php
    index 04286aa..d5e0b67 100644
    class WP_Query { 
    30993099         * @return bool
    31003100         */
    31013101        function is_post_type_archive( $post_types = '' ) {
    3102                 if ( empty( $post_types ) || !$this->is_post_type_archive )
     3102                if ( empty( $post_types ) || ! $this->is_post_type_archive )
    31033103                        return (bool) $this->is_post_type_archive;
    31043104
    3105                 $post_type_object = $this->get_queried_object();
     3105                $post_type_object = get_post_type_object( $this->get( 'post_type' ) );
    31063106
    31073107                return in_array( $post_type_object->name, (array) $post_types );
    31083108        }
  • wp-includes/template-loader.php

    diff --git wp-includes/template-loader.php wp-includes/template-loader.php
    index 7051f34..81de956 100644
    if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : 
    2626        $template = false;
    2727        if     ( is_404()            && $template = get_404_template()            ) :
    2828        elseif ( is_search()         && $template = get_search_template()         ) :
     29        elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
    2930        elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    3031        elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    3132        elseif ( is_home()           && $template = get_home_template()           ) :
  • wp-includes/template.php

    diff --git wp-includes/template.php wp-includes/template.php
    index 5bee8ad..78557e8 100644
    function get_archive_template() { 
    7373}
    7474
    7575/**
     76 * Retrieve path of post type archive template in current or parent template.
     77 *
     78 * @since 3.7.0
     79 *
     80 * @return string
     81 */
     82function get_post_type_archive_template() {
     83        $obj = get_post_type_object( get_query_var( 'post_type' ) );
     84        if ( ! $obj->has_archive )
     85                return '';
     86
     87        return get_archive_template();
     88}
     89
     90/**
    7691 * Retrieve path of author template in current or parent template.
    7792 *
    7893 * @since 1.5.0