From e692640c1161805a448fe022762ce26a7dc2a59e Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 22 Feb 2010 21:59:40 +0000 Subject: [PATCH] Order link categories by name, not count, on Add/Edit Link page. Fixes #10399 props pnettle, chrisscott. git-svn-id: http://svn.automattic.com/wordpress/trunk@13313 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 81a257ca8..dc03bd4fe 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -415,26 +415,24 @@ function wp_link_category_checklist( $link_id = 0 ) { $default = 1; if ( $link_id ) { - $checked_categories = wp_get_link_cats($link_id); - - if ( count( $checked_categories ) == 0 ) { - // No selected categories, strange + $checked_categories = wp_get_link_cats( $link_id ); + // No selected categories, strange + if ( ! count( $checked_categories ) ) $checked_categories[] = $default; - } } else { $checked_categories[] = $default; } - $categories = get_terms('link_category', array('orderby' => 'count', 'hide_empty' => 0)); + $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); - if ( empty($categories) ) + if ( empty( $categories ) ) return; foreach ( $categories as $category ) { $cat_id = $category->term_id; - $name = esc_html( apply_filters('the_category', $category->name)); - $checked = in_array( $cat_id, $checked_categories ); - echo '"; + $name = esc_html( apply_filters( 'the_category', $category->name ) ); + $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; + echo '"; } }