Changeset 15819
- Timestamp:
- 10/15/2010 07:44:57 PM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r15771 r15819 548 548 } 549 549 550 // If there's a post type archive 551 if ( is_post_type_archive() ) 552 $title = post_type_archive_title( '', false ); 553 550 554 // If there's a month 551 555 if ( is_archive() && !empty($m) ) { … … 612 616 * 613 617 * @since 0.71 614 * @uses $wpdb615 618 * 616 619 * @param string $prefix Optional. What to display before the title. … … 636 639 } 637 640 641 /** 642 * Display or retrieve title for a post type archive. 643 * 644 * This is optimized for archive.php and archive-{$post_type}.php template files 645 * for displaying the title of the post type. 646 * 647 * @since 3.1.0 648 * 649 * @param string $prefix Optional. What to display before the title. 650 * @param bool $display Optional, default is true. Whether to display or retrieve title. 651 * @return string|null Title when retrieving, null when displaying or failure. 652 */ 653 function post_type_archive_title() { 654 if ( ! is_post_type_archive() ) 655 return; 656 657 658 $post_type_obj = get_post_type_object( get_query_var( 'post_type' ) ); 659 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); 660 661 if ( $display ) 662 echo $prefix . $title; 663 else 664 return $title; 665 } 666 638 667 /** 639 668 * Display or retrieve page title for category archive. -
trunk/wp-includes/link-template.php
r15817 r15819 40 40 41 41 // Note that $type_of_url can be one of following: 42 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged 42 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged, post_type_archive 43 43 $string = apply_filters('user_trailingslashit', $string, $type_of_url); 44 44 return $string; … … 826 826 827 827 /** 828 * Retrieve the permalink for a post type archive. 829 * 830 * @since 3.1.0 831 * 832 * @param string $post_type Post type 833 * @return string 834 */ 835 function get_post_type_archive_link( $post_type ) { 836 global $wp_rewrite; 837 if ( ! $post_type_obj = get_post_type_object( $post_type ) ) 838 return false; 839 840 if ( ! is_array( $post_type_obj->rewrite ) || false === $post_type_obj->rewrite['archive'] ) 841 return false; 842 843 if ( get_option( 'permalink_structure' ) ) { 844 $struct = ( true === $post_type_obj->rewrite['archive'] ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->rewrite['archive']; 845 if ( $post_type_obj->rewrite['with_front'] ) 846 $struct = $wp_rewrite->front . $struct; 847 $link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) ); 848 } else { 849 $link = home_url( '?post_type=' . $post_type ); 850 } 851 852 return apply_filters( 'post_type_archive_link', $link, $post_type ); 853 } 854 855 /** 856 * Retrieve the permalink for a post type archive feed. 857 * 858 * @since 3.1.0 859 * 860 * @param string $post_type Post type 861 * @param string $feed Optional. Feed type 862 * @return string 863 */ 864 function get_post_type_archive_feed_link( $post_type, $feed = '' ) { 865 $default_feed = get_default_feed(); 866 if ( empty( $feed ) ) 867 $feed = $default_feed; 868 869 if ( ! $link = get_post_type_archive_link( $post_type ) ) 870 return false; 871 $post_type_obj = get_post_type_object( $post_type ); 872 if ( $post_type_obj->rewrite['feeds'] && get_option( 'permalink_structure' ) ) { 873 $link = trailingslashit($link); 874 $link .= 'feed/'; 875 if ( $feed != $default_feed ) 876 $link .= "$feed/"; 877 } else { 878 $link = add_query_arg( 'feed', $feed, $link ); 879 } 880 881 return apply_filters( 'post_type_archive_feed_link', $link, $feed ); 882 } 883 884 /** 828 885 * Retrieve edit posts link for post. 829 886 * -
trunk/wp-includes/post-template.php
r15651 r15819 408 408 } 409 409 } elseif ( is_archive() ) { 410 if ( is_author() ) { 410 if ( is_post_type_archive() ) { 411 $classes[] = 'post-type-archive'; 412 $classes[] = 'post-type-archive-' . sanitize_html_class( get_query_var( 'post_type' ) ); 413 } else if ( is_author() ) { 411 414 $author = $wp_query->get_queried_object(); 412 415 $classes[] = 'author'; … … 473 476 elseif ( is_search() ) 474 477 $classes[] = 'search-paged-' . $page; 478 elseif ( is_post_type_archive() ) 479 $classes[] = 'post-type-paged-' . $page; 475 480 } 476 481 -
trunk/wp-includes/post.php
r15806 r15819 925 925 $args->rewrite['archive'] = false; 926 926 if ( !isset($args->rewrite['feeds']) || !$args->rewrite['archive'] ) 927 $args->rewrite['feeds'] = false;927 $args->rewrite['feeds'] = (bool) $args->rewrite['archive']; 928 928 929 929 if ( $args->hierarchical ) -
trunk/wp-includes/query.php
r15803 r15819 122 122 123 123 /** 124 * Is the query for a post type archive page? 125 * 126 * @see WP_Query::is_post_type_archive() 127 * @since 3.1.0 128 * @uses $wp_query 129 * 130 * @param mixed $post_types Optional. Post type or array of posts types to check against. 131 * @return bool 132 */ 133 function is_post_type_archive( $post_types = '' ) { 134 global $wp_query; 135 136 return $wp_query->is_post_type_archive( $post_types ); 137 } 138 139 /** 124 140 * Is the query for an attachment page? 125 141 * … … 1040 1056 */ 1041 1057 var $is_posts_page = false; 1058 1059 /** 1060 * Set if query is for a post type archive. 1061 * 1062 * @since 3.1.0 1063 * @access public 1064 * @var bool 1065 */ 1066 var $is_post_type_archive = false; 1042 1067 1043 1068 /** … … 1076 1101 $this->is_robots = false; 1077 1102 $this->is_posts_page = false; 1103 $this->is_post_type_archive = false; 1078 1104 } 1079 1105 … … 1235 1261 $this->is_single = false; 1236 1262 } else { 1237 // Look for archive queries. Dates, categories, authors, search .1263 // Look for archive queries. Dates, categories, authors, search, post type archives. 1238 1264 1239 1265 if ( !empty($qv['s']) ) { … … 1307 1333 $this->is_author = true; 1308 1334 1309 if ( !empty( $qv['post_type'] ) ) 1310 $this->is_archive = true; 1311 1312 if ( $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) 1335 if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) { 1336 $post_type_obj = get_post_type_object( $qv['post_type'] ); 1337 if ( is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['archive'] ) 1338 $this->is_post_type_archive = true; 1339 } 1340 1341 if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) 1313 1342 $this->is_archive = true; 1314 1343 } … … 2637 2666 2638 2667 /** 2668 * Is the query for a post type archive page? 2669 * 2670 * @since 3.1.0 2671 * 2672 * @param mixed $post_types Optional. Post type or array of posts types to check against. 2673 * @return bool 2674 */ 2675 function is_post_type_archive( $post_types = '' ) { 2676 if ( empty( $post_types ) || !$this->is_post_type_archive ) 2677 return (bool) $this->is_post_type_archive; 2678 2679 if ( ! isset( $this->posts[0] ) ) 2680 return false; 2681 2682 $post = $this->posts[0]; 2683 2684 return in_array( $post->post_type, (array) $post_types ); 2685 } 2686 2687 /** 2639 2688 * Is the query for an attachment page? 2640 2689 *
Note: See TracChangeset
for help on using the changeset viewer.