WordPress.org

Make WordPress Core

Changeset 35500


Ignore:
Timestamp:
11/04/2015 04:29:39 AM (5 years ago)
Author:
westonruter
Message:

Customize: Add support for post_type_archive nav menu items.

Props celloexpressions, westonruter.
Fixes #16075.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-nav-menus.php

    r34487 r35500  
    110110            if ( ! get_post_type_object( $object ) ) {
    111111                return new WP_Error( 'nav_menus_invalid_post_type' );
     112            } else {
     113                $post_type = get_post_type_object( $object );
    112114            }
    113115
     
    121123                    'object'     => '',
    122124                    'url'        => home_url(),
     125                );
     126            } elseif ( 'post' !== $object && 0 === $page && $post_type->has_archive ) {
     127                // Add a post type archive link.
     128                $items[] = array(
     129                    'id'         => $object . '-archive',
     130                    'title'      => $post_type->labels->archives,
     131                    'type'       => 'post_type_archive',
     132                    'type_label' => __( 'Post Type Archive' ),
     133                    'object'     => $object,
     134                    'url'        => get_post_type_archive_link( $object ),
    123135                );
    124136            }
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r35385 r35500  
    325325        }
    326326
     327        if ( ! isset( $this->value['title'] ) ) {
     328            $this->value['title'] = '';
     329        }
     330
    327331        if ( ! isset( $this->value['_invalid'] ) ) {
    328             $this->value['_invalid'] = (
    329                 ( 'post_type' === $this->value['type'] && ! post_type_exists( $this->value['object'] ) )
     332            $this->value['_invalid'] = false;
     333            $is_known_invalid = (
     334                ( ( 'post_type' === $this->value['type'] || 'post_type_archive' === $this->value['type'] ) && ! post_type_exists( $this->value['object'] ) )
    330335                ||
    331336                ( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) )
    332337            );
     338            if ( $is_known_invalid ) {
     339                $this->value['_invalid'] = true;
     340            }
    333341        }
    334342
Note: See TracChangeset for help on using the changeset viewer.