diff --git wp-includes/link-template.php wp-includes/link-template.php
index 5fb6172..16d1ef3 100644
|
|
function get_post_type_archive_link( $post_type ) { |
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 |
… |
… |
function get_post_type_archive_feed_link( $post_type, $feed = '' ) { |
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' ); |
| 871 | |
868 | 872 | if ( ! $link = get_post_type_archive_link( $post_type ) ) |
869 | 873 | return false; |
870 | 874 | |
| 875 | if ( ! $has_filter ) |
| 876 | remove_filter( 'ignore_has_archive_' . $post_type, '__return_true' ); |
| 877 | |
871 | 878 | $post_type_obj = get_post_type_object( $post_type ); |
872 | 879 | if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { |
873 | 880 | $link = trailingslashit( $link ); |
diff --git wp-includes/post.php wp-includes/post.php
index 4179e7f..86a7ef5 100644
|
|
function register_post_type( $post_type, $args = array() ) { |
1239 | 1239 | $args->rewrite['with_front'] = true; |
1240 | 1240 | if ( ! isset( $args->rewrite['pages'] ) ) |
1241 | 1241 | $args->rewrite['pages'] = true; |
1242 | | if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive ) |
| 1242 | if ( ! isset( $args->rewrite['feeds'] ) && isset( $args->has_archive ) ) |
1243 | 1243 | $args->rewrite['feeds'] = (bool) $args->has_archive; |
1244 | 1244 | if ( ! isset( $args->rewrite['ep_mask'] ) ) { |
1245 | 1245 | if ( isset( $args->permalink_epmask ) ) |
… |
… |
function register_post_type( $post_type, $args = array() ) { |
1253 | 1253 | else |
1254 | 1254 | add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); |
1255 | 1255 | |
1256 | | if ( $args->has_archive ) { |
1257 | | $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive; |
1258 | | if ( $args->rewrite['with_front'] ) |
1259 | | $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; |
1260 | | else |
1261 | | $archive_slug = $wp_rewrite->root . $archive_slug; |
| 1256 | $archive_slug = ( is_string( $args->has_archive ) && strlen( $args->has_archive ) ) ? $args->has_archive : $args->rewrite['slug']; |
| 1257 | if ( $args->rewrite['with_front'] ) |
| 1258 | $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; |
| 1259 | else |
| 1260 | $archive_slug = $wp_rewrite->root . $archive_slug; |
1262 | 1261 | |
| 1262 | if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { |
| 1263 | $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; |
| 1264 | add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); |
| 1265 | add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); |
| 1266 | } |
| 1267 | |
| 1268 | if ( $args->has_archive ) { |
1263 | 1269 | add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' ); |
1264 | | if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { |
1265 | | $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; |
1266 | | add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); |
1267 | | add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); |
1268 | | } |
1269 | 1270 | if ( $args->rewrite['pages'] ) |
1270 | 1271 | add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); |
1271 | 1272 | } |