Make WordPress Core


Ignore:
Timestamp:
10/24/2015 05:45:11 PM (9 years ago)
Author:
wonderboymusic
Message:

Nav Menus: show custom post type Archive item at the top of the View All tab for the post type on the legacy Nav Menu screen.

Props aaroncampbell, DrewAPicture, seanchayes, hlashbrooke, paulwilde, ericlewis, raulillana
See #16075.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r34769 r35382  
    404404            $original_parent = (int) $original_object->post_parent;
    405405            $original_title = $original_object->post_title;
     406        } elseif ( 'post_type_archive' == $args['menu-item-type'] ) {
     407            $original_object = get_post_type_object( $args['menu-item-object'] );
     408            $original_title = $original_object->labels->archives;
    406409        }
    407410
     
    732735                $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
    733736
     737            } elseif ( 'post_type_archive' == $menu_item->type ) {
     738                $object =  get_post_type_object( $menu_item->object );
     739                if ( $object ) {
     740                    $menu_item->title = '' == $menu_item->post_title ? $object->labels->archives : $menu_item->post_title;
     741                } else {
     742                    $menu_item->_invalid = true;
     743                }
     744
     745                $menu_item->type_label = __( 'Post Type Archive' );
     746                $menu_item->description = '';
     747                $menu_item->url = get_post_type_archive_link( $menu_item->object );
    734748            } elseif ( 'taxonomy' == $menu_item->type ) {
    735749                $object = get_taxonomy( $menu_item->object );
Note: See TracChangeset for help on using the changeset viewer.