WordPress.org

Make WordPress Core

Changeset 14797


Ignore:
Timestamp:
05/21/10 23:32:45 (4 years ago)
Author:
nacin
Message:

Most Recent tab for nav menu meta boxes for post types. props filosofo, see #13217.

File:
1 edited

Legend:

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

    r14767 r14797  
    557557        $error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>'; 
    558558 
    559     $current_tab = 'all'; 
     559    $walker = new Walker_Nav_Menu_Checklist; 
     560 
     561    $current_tab = 'most-recent'; 
    560562    if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) { 
    561563        $current_tab = $_REQUEST[$post_type_name . '-tab']; 
     
    578580    <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> 
    579581        <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> 
     582            <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"><?php _e('Most Recent'); ?></a></li> 
    580583            <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li> 
    581584            <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li> 
    582585        </ul> 
     586 
     587        <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php 
     588            echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); 
     589        ?>"> 
     590            <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> 
     591                <?php 
     592                $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'showposts' => 15 ) ); 
     593                $most_recent = $get_posts->query( $recent_args ); 
     594                $args['walker'] = $walker; 
     595                echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args ); 
     596                ?> 
     597            </ul> 
     598        </div><!-- /.tabs-panel --> 
    583599 
    584600        <div class="tabs-panel <?php 
     
    603619            <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> 
    604620                <?php 
    605                 $args['walker'] = new Walker_Nav_Menu_Checklist; 
     621                $args['walker'] = $walker; 
    606622                echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); 
    607623                ?> 
     
    623639            <ul id="<?php echo $post_type_name; ?>checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear"> 
    624640                <?php 
    625                 $args['walker'] = new Walker_Nav_Menu_Checklist; 
     641                $args['walker'] = $walker; 
    626642                $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args ); 
    627643 
     
    751767                $args['walker'] = $walker; 
    752768                echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args ); 
    753                 ?> 
    754                 <?php 
    755769                ?> 
    756770            </ul> 
     
    908922            return false; 
    909923 
    910         // pages should show most recent 
    911924        if ( 'page' == $object->name ) { 
    912925            $object->_default_query = array( 
Note: See TracChangeset for help on using the changeset viewer.