Make WordPress Core

Ticket #26268: 26268.9.diff

File 26268.9.diff, 3.3 KB (added by kraftbj, 10 years ago)

26268.8 without the bad intent on one line :)

  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    198198                        } else {
    199199                                $children = _get_term_hierarchy( $taxonomy );
    200200                        }
     201                        // Handle custom display of default category by showing it first in the list
     202
     203                        if ( 'category' == $taxonomy ) {
     204                                $default_category = get_term( get_option( 'default_category' ), 'category' );
     205                                $this->single_row( $default_category );
     206                        }
     207
    201208                        // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
    202209                        $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
    203210                } else {
    204211                        $terms = get_terms( $taxonomy, $args );
     212
     213                        // Handle custom display of default category by showing it first in the list
     214
     215                        $default_category_id = false;
     216                        if ( 'category' == $taxonomy ) {
     217                                $default_category = get_term( get_option( 'default_category' ), 'category' );
     218                                $this->single_row( $default_category );
     219                                $default_category_id = $default_category->term_id;
     220                        }
     221
    205222                        foreach ( $terms as $term ) {
     223                                if ( $default_category_id == $term->term_taxonomy_id ) {
     224                                        continue;
     225                                }
    206226                                $this->single_row( $term );
    207227                        }
    208228                }
     
    222242
    223243                $end = $start + $per_page;
    224244
     245                // Handle display of default category by showing it first in the list, capture default category id
     246
     247                $default_category_id = false;
     248                if ( 'category' == $taxonomy ) {
     249                        $default_category_id = get_option( 'default_category' );
     250                }
     251
    225252                foreach ( $terms as $key => $term ) {
    226253
    227254                        if ( $count >= $end )
     
    230257                        if ( $term->parent != $parent && empty( $_REQUEST['s'] ) )
    231258                                continue;
    232259
     260                        // Skip duplicating display of default category
     261                        if ( $default_category_id == $term->term_taxonomy_id ) {
     262                                continue;
     263                        }
     264
    233265                        // If the page starts in a subtree, print the parents.
    234266                        if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
    235267                                $my_parents = $parent_ids = array();
     
    306338
    307339                $default_term = get_option( 'default_' . $taxonomy );
    308340
     341                $default_term_label = '';
     342                if ( $tag->term_id == $default_term ) {
     343                        $default_term_label = ' - <span class="taxonomy-label"> ' . __( 'Default' ) . '</span>';
     344                }
     345
    309346                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
    310347
    311348                /**
     
    326363                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    327364                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    328365
    329                 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     366        $default_categories = array(
     367            'category',
     368            'link_category'
     369        );
    330370
     371                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a>' . $default_term_label . '</strong><br />';
     372
    331373                $actions = array();
    332374                if ( current_user_can( $tax->cap->edit_terms ) ) {
    333375                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';