Ticket #16415: 16415.5.diff
File 16415.5.diff, 3.8 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
1173 1173 $args->rewrite['with_front'] = true; 1174 1174 if ( ! isset( $args->rewrite['pages'] ) ) 1175 1175 $args->rewrite['pages'] = true; 1176 if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive)1176 if ( ! isset( $args->rewrite['feeds'] ) && isset( $args->has_archive ) ) 1177 1177 $args->rewrite['feeds'] = (bool) $args->has_archive; 1178 1178 if ( ! isset( $args->rewrite['ep_mask'] ) ) { 1179 1179 if ( isset( $args->permalink_epmask ) ) … … 1187 1187 else 1188 1188 add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 1189 1189 1190 $archive_slug = ( is_string( $args->has_archive ) && strlen( $args->has_archive ) ) ? $args->has_archive : $args->rewrite['slug']; 1191 if ( $args->rewrite['with_front'] ) 1192 $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; 1193 else 1194 $archive_slug = $wp_rewrite->root . $archive_slug; 1195 1196 if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { 1197 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; 1198 add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 1199 add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 1200 } 1201 1190 1202 if ( $args->has_archive ) { 1191 $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;1192 if ( $args->rewrite['with_front'] )1193 $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;1194 else1195 $archive_slug = $wp_rewrite->root . $archive_slug;1196 1197 1203 add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' ); 1198 if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {1199 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';1200 add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );1201 add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );1202 }1203 1204 if ( $args->rewrite['pages'] ) 1204 1205 add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); 1205 1206 } -
wp-includes/link-template.php
834 834 if ( ! $post_type_obj = get_post_type_object( $post_type ) ) 835 835 return false; 836 836 837 if ( ! $post_type_obj->has_archive )837 if ( ! $post_type_obj->has_archive && ! apply_filters( 'ignore_has_archive_' . $post_type, false ) ) 838 838 return false; 839 839 840 840 if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) { 841 $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;841 $struct = is_string( $post_type_obj->has_archive ) ? $post_type_obj->has_archive : $post_type_obj->rewrite['slug']; 842 842 if ( $post_type_obj->rewrite['with_front'] ) 843 843 $struct = $wp_rewrite->front . $struct; 844 844 else … … 865 865 if ( empty( $feed ) ) 866 866 $feed = $default_feed; 867 867 868 $has_filter = has_filter( 'ignore_has_archive_' . $post_type, '__return_true' ); 869 if ( !$has_filter ) 870 add_filter( 'ignore_has_archive_' . $post_type, '__return_true' ); 868 871 if ( ! $link = get_post_type_archive_link( $post_type ) ) 869 872 return false; 873 if ( !$has_filter ) 874 remove_filter( 'ignore_has_archive_' . $post_type, '__return_true' ); 870 875 $post_type_obj = get_post_type_object( $post_type ); 871 876 if ( $post_type_obj->rewrite['feeds'] && get_option( 'permalink_structure' ) ) { 872 877 $link = trailingslashit($link);