Changeset 15803
- Timestamp:
- 10/14/2010 10:39:47 AM (14 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r15779 r15803 922 922 if ( !isset($args->rewrite['with_front']) ) 923 923 $args->rewrite['with_front'] = true; 924 if ( !isset($args->rewrite['archive']) ) 925 $args->rewrite['archive'] = false; 926 if ( !isset($args->rewrite['feeds']) || !$args->rewrite['archive'] ) 927 $args->rewrite['feeds'] = false; 928 924 929 if ( $args->hierarchical ) 925 930 $wp_rewrite->add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 926 931 else 927 932 $wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 928 $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask); 933 934 if ( $args->rewrite['archive'] ) { 935 $archive_slug = $args->rewrite['archive'] === true ? $args->rewrite['slug'] : $args->rewrite['archive']; 936 $wp_rewrite->add_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' ); 937 if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { 938 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; 939 $wp_rewrite->add_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 940 $wp_rewrite->add_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 941 } 942 $wp_rewrite->add_rule( "{$archive_slug}/page/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); 943 } 944 945 $wp_rewrite->add_permastruct($post_type, "{$archive_slug}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask); 929 946 } 930 947 -
trunk/wp-includes/query.php
r15795 r15803 103 103 * Month, Year, Category, Author, ... 104 104 * 105 * If the $post_types parameter is specified, this function will additionally 106 * check if the query is for exactly one of the post types specified. If a plugin 107 * is causing multiple post types to appear in the query, specifying a post type 108 * will cause this check to return false. 109 * 105 110 * @see WP_Query::is_archive() 106 111 * @since 1.5.0 107 112 * @uses $wp_query 108 113 * 114 * @param mixed $post_types Optional. Post type or array of post types 109 115 * @return bool 110 116 */ 111 function is_archive( ) {112 global $wp_query; 113 114 return $wp_query->is_archive( );117 function is_archive( $post_types = '' ) { 118 global $wp_query; 119 120 return $wp_query->is_archive( $post_types ); 115 121 } 116 122 … … 1298 1304 } 1299 1305 1300 if ( '' != $qv['author_name'] ) {1306 if ( '' != $qv['author_name'] ) 1301 1307 $this->is_author = true; 1302 } 1303 1304 if ( ($this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax) ) 1308 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 ) 1305 1313 $this->is_archive = true; 1306 1314 } … … 2606 2614 * Month, Year, Category, Author, ... 2607 2615 * 2616 * If the $post_types parameter is specified, this function will additionally 2617 * check if the query is for exactly one of the post types specified. If a plugin 2618 * is causing multiple post types to appear in the query, specifying a post type 2619 * will cause this check to return false. 2620 * 2608 2621 * @since 3.1.0 2609 2622 * 2623 * @param mixed $post_types Optional. Post type or array of post types 2610 2624 * @return bool 2611 2625 */ 2612 function is_archive() { 2613 return (bool) $this->is_archive; 2626 function is_archive( $post_types ) { 2627 if ( empty( $post_types ) || !$this->is_archive ) 2628 return (bool) $this->is_archive; 2629 2630 if ( ! isset( $this->posts[0] ) ) 2631 return false; 2632 2633 $post = $this->posts[0]; 2634 2635 return in_array( $post->post_type, (array) $post_types ); 2614 2636 } 2615 2637 … … 3003 3025 function is_singular( $post_types = '' ) { 3004 3026 if ( empty( $post_types ) || !$this->is_singular ) 3005 return $this->is_singular;3027 return (bool) $this->is_singular; 3006 3028 3007 3029 $post_obj = $this->get_queried_object(); -
trunk/wp-includes/theme.php
r15771 r15803 782 782 */ 783 783 function get_archive_template() { 784 return get_query_template('archive'); 784 $post_type = get_query_var( 'post_type' ); 785 786 $templates = array(); 787 788 if ( $post_type ) 789 $templates[] = "archive-{$post_type}.php"; 790 $templates[] = 'archive.php'; 791 792 return get_query_template( 'archive', $templates ); 785 793 } 786 794
Note: See TracChangeset
for help on using the changeset viewer.