WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/13/2010 05:40:47 AM (10 years ago)
Author:
dd32
Message:

Convert Terms page to use WP_Ajax_Response(), hierarchical terms will now appear under their parent OR have the parents prefixed, Terms will be removed from tag cloud/parent list upon deletion, Terms will be added to Parent list in correct order upon ajax creation, Errors on term creation flow back to UI, clean up _tag_row() alternate class handling, Show None text in Category dropdown if empty and show_if_empty = true. See #11838

File:
1 edited

Legend:

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

    r13081 r13086  
    483483 * @return unknown
    484484 */
    485 function _tag_row( $tag, $level, $class = '', $taxonomy = 'post_tag' ) {
     485function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
     486        static $row_class = '';
     487        $row_class = ($row_class == '' ? ' class="alternate"' : '');
     488
    486489        $count = number_format_i18n( $tag->count );
    487490        if ( 'post_tag' == $taxonomy )
     
    497500
    498501        $pad = str_repeat( '— ', max(0, $level) );
    499         $name = apply_filters( 'term_name', $pad . ' ' . $tag->name );
     502        $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
    500503        $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
    501504        $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id";
    502505
    503506        $out = '';
    504         $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
     507        $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
     508
    505509
    506510        $columns = get_column_headers('edit-tags');
     
    608612            $children = _get_term_hierarchy($taxonomy);
    609613
    610         // Some funky recursion to get the job done is contained within, Skip it for non-hierarchical taxonomies for performance sake
     614        // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake
    611615        $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count);
    612616    } else {
    613617        $terms = get_terms( $taxonomy, $args );
    614618        foreach( $terms as $term )
    615             $out .= _tag_row( $term, 0, ++$count % 2 ? ' class="alternate"' : '', $taxonomy );
     619            $out .= _tag_row( $term, 0, $taxonomy );
    616620    }
    617621
     
    649653
    650654            $num_parents = count($my_parents);
    651             $count -= $num_parents; // Do not include parents in the per-page count, This is due to paging issues with unknown numbers of rows.
    652655            while ( $my_parent = array_pop($my_parents) ) {
    653                 $output .=  "\t" . _tag_row( $my_parent, $level - $num_parents, ++$count % 2 ? ' class="alternate"' : '', $taxonomy );
     656                $output .=  "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy );
    654657                $num_parents--;
    655658            }
     
    657660
    658661        if ( $count >= $start )
    659             $output .= "\t" . _tag_row( $term, $level, ++$count % 2 ? ' class="alternate"' : '', $taxonomy );
    660         else
    661             ++$count;
     662            $output .= "\t" . _tag_row( $term, $level, $taxonomy );
     663
     664        ++$count;
    662665
    663666        unset($terms[$key]);
    664667
    665         if ( isset($children[$term->term_id]) )
     668        if ( isset($children[$term->term_id]) && empty($_GET['s']) )
    666669            $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 );
    667670    }
Note: See TracChangeset for help on using the changeset viewer.