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

git-svn-id: https://develop.svn.wordpress.org/trunk@14291 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-04-29 06:01:44 +00:00
parent 23cd92c6ff
commit ffc6b5e799

View File

@ -481,13 +481,16 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
// @todo transient caching of these results with proper invalidation on updating of a post of this type // @todo transient caching of these results with proper invalidation on updating of a post of this type
$get_posts = new WP_Query; $get_posts = new WP_Query;
$posts = $get_posts->query( $args ); $posts = $get_posts->query( $args );
$count_posts = (int) @count( $posts );
if ( ! $count_posts ) {
echo '<p>' . __( 'No items.' ) . '</p>';
return;
}
$post_type_object = get_post_type_object($post_type_name); $post_type_object = get_post_type_object($post_type_name);
$num_pages = $get_posts->max_num_pages; $num_pages = $get_posts->max_num_pages;
$count_posts = (int) @count( $posts );
if ( isset( $get_posts->found_posts ) && ( $get_posts->found_posts > $count_posts ) ) { if ( isset( $get_posts->found_posts ) && ( $get_posts->found_posts > $count_posts ) ) {
// somewhat like display_page_row(), let's make sure ancestors show up on paged display // somewhat like display_page_row(), let's make sure ancestors show up on paged display
$parent_ids = array(); $parent_ids = array();
@ -645,11 +648,15 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
*/ */
function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) { function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
$taxonomy_name = $taxonomy['args']->name; $taxonomy_name = $taxonomy['args']->name;
if ( ! $term_count = wp_count_terms( $taxonomy_name ) ) {
echo '<p>' . __( 'No items.' ) . '</p>';
return;
}
// paginate browsing for large numbers of objects // paginate browsing for large numbers of objects
$per_page = 50; $per_page = 50;
$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
$args = array( $args = array(
'child_of' => 0, 'child_of' => 0,
'exclude' => '', 'exclude' => '',
@ -664,7 +671,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
'pad_counts' => false, 'pad_counts' => false,
); );
$num_pages = ceil( wp_count_terms($taxonomy_name) / $per_page ); $num_pages = ceil( $term_count / $per_page );
$page_links = paginate_links( array( $page_links = paginate_links( array(
'base' => add_query_arg( 'base' => add_query_arg(