WordPress.org

Make WordPress Core

Changeset 13313


Ignore:
Timestamp:
02/22/2010 09:59:40 PM (8 years ago)
Author:
nacin
Message:

Order link categories by name, not count, on Add/Edit Link page. Fixes #10399 props pnettle, chrisscott.

File:
1 edited

Legend:

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

    r13289 r13313  
    416416
    417417    if ( $link_id ) {
    418         $checked_categories = wp_get_link_cats($link_id);
    419 
    420         if ( count( $checked_categories ) == 0 ) {
    421             // No selected categories, strange
     418        $checked_categories = wp_get_link_cats( $link_id );
     419        // No selected categories, strange
     420        if ( ! count( $checked_categories ) )
    422421            $checked_categories[] = $default;
    423         }
    424422    } else {
    425423        $checked_categories[] = $default;
    426424    }
    427425
    428     $categories = get_terms('link_category', array('orderby' => 'count', 'hide_empty' => 0));
    429 
    430     if ( empty($categories) )
     426    $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
     427
     428    if ( empty( $categories ) )
    431429        return;
    432430
    433431    foreach ( $categories as $category ) {
    434432        $cat_id = $category->term_id;
    435         $name = esc_html( apply_filters('the_category', $category->name));
    436         $checked = in_array( $cat_id, $checked_categories );
    437         echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
     433        $name = esc_html( apply_filters( 'the_category', $category->name ) );
     434        $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
     435        echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
    438436    }
    439437}
Note: See TracChangeset for help on using the changeset viewer.