WordPress.org

Make WordPress Core

Changeset 14291


Ignore:
Timestamp:
04/29/2010 06:01:44 AM (8 years ago)
Author:
nacin
Message:

Show 'no items' message in post/tax meta boxes for nav menu admin instead of empty tabs.

File:
1 edited

Legend:

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

    r14287 r14291  
    482482    $get_posts = new WP_Query;
    483483    $posts = $get_posts->query( $args );
     484    $count_posts = (int) @count( $posts );
     485    if ( ! $count_posts ) {
     486        echo '<p>' . __( 'No items.' ) . '</p>';
     487        return;
     488    }
    484489
    485490    $post_type_object = get_post_type_object($post_type_name);
    486491
    487492    $num_pages = $get_posts->max_num_pages;
    488 
    489     $count_posts = (int) @count( $posts );
    490493
    491494    if ( isset( $get_posts->found_posts ) && ( $get_posts->found_posts > $count_posts ) ) {
     
    646649function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
    647650    $taxonomy_name = $taxonomy['args']->name;
     651    if ( ! $term_count = wp_count_terms( $taxonomy_name ) ) {
     652        echo '<p>' . __( 'No items.' ) . '</p>';
     653        return;
     654    }
    648655    // paginate browsing for large numbers of objects
    649656    $per_page = 50;
    650657    $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
    651658    $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
    652    
     659
    653660    $args = array(
    654661        'child_of' => 0,
     
    665672    );
    666673
    667     $num_pages = ceil( wp_count_terms($taxonomy_name) / $per_page );
     674    $num_pages = ceil( $term_count / $per_page );
    668675
    669676    $page_links = paginate_links( array(
Note: See TracChangeset for help on using the changeset viewer.