Make WordPress Core

Ticket #16415: 16415.6.diff

File 16415.6.diff, 4.0 KB (added by wonderboymusic, 11 years ago)
  • wp-includes/link-template.php

    diff --git wp-includes/link-template.php wp-includes/link-template.php
    index 5fb6172..16d1ef3 100644
    function get_post_type_archive_link( $post_type ) { 
    834834        if ( ! $post_type_obj = get_post_type_object( $post_type ) )
    835835                return false;
    836836
    837         if ( ! $post_type_obj->has_archive )
     837        if ( ! $post_type_obj->has_archive && ! apply_filters( 'ignore_has_archive_' . $post_type, false ) )
    838838                return false;
    839839
    840840        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'];
    842842                if ( $post_type_obj->rewrite['with_front'] )
    843843                        $struct = $wp_rewrite->front . $struct;
    844844                else
    function get_post_type_archive_feed_link( $post_type, $feed = '' ) { 
    865865        if ( empty( $feed ) )
    866866                $feed = $default_feed;
    867867
     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
    868872        if ( ! $link = get_post_type_archive_link( $post_type ) )
    869873                return false;
    870874
     875        if ( ! $has_filter )
     876                remove_filter( 'ignore_has_archive_' . $post_type, '__return_true' );
     877
    871878        $post_type_obj = get_post_type_object( $post_type );
    872879        if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
    873880                $link = trailingslashit( $link );
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 4179e7f..86a7ef5 100644
    function register_post_type( $post_type, $args = array() ) { 
    12391239                        $args->rewrite['with_front'] = true;
    12401240                if ( ! isset( $args->rewrite['pages'] ) )
    12411241                        $args->rewrite['pages'] = true;
    1242                 if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
     1242                if ( ! isset( $args->rewrite['feeds'] ) && isset( $args->has_archive ) )
    12431243                        $args->rewrite['feeds'] = (bool) $args->has_archive;
    12441244                if ( ! isset( $args->rewrite['ep_mask'] ) ) {
    12451245                        if ( isset( $args->permalink_epmask ) )
    function register_post_type( $post_type, $args = array() ) { 
    12531253                else
    12541254                        add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
    12551255
    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;
    12621261
     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 ) {
    12631269                        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                         }
    12691270                        if ( $args->rewrite['pages'] )
    12701271                                add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
    12711272                }