| 1 | Index: wp-admin/includes/template.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/includes/template.php (revision 12833) |
|---|
| 4 | +++ wp-admin/includes/template.php (working copy) |
|---|
| 5 | @@ -671,7 +671,10 @@ |
|---|
| 6 | * @param unknown_type $class |
|---|
| 7 | * @return unknown |
|---|
| 8 | */ |
|---|
| 9 | -function _tag_row( $tag, $level, $class = '', $taxonomy = 'post_tag' ) { |
|---|
| 10 | +function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { |
|---|
| 11 | + static $row_class = ''; |
|---|
| 12 | + $row_class = ($row_class == '' ? ' class="alternate"' : ''); |
|---|
| 13 | + |
|---|
| 14 | $count = number_format_i18n( $tag->count ); |
|---|
| 15 | if ( 'post_tag' == $taxonomy ) |
|---|
| 16 | $tagsel = 'tag'; |
|---|
| 17 | @@ -685,13 +688,14 @@ |
|---|
| 18 | $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count; |
|---|
| 19 | |
|---|
| 20 | $pad = str_repeat( '— ', max(0, $level) ); |
|---|
| 21 | - $name = apply_filters( 'term_name', $pad . ' ' . $tag->name ); |
|---|
| 22 | + $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); |
|---|
| 23 | $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); |
|---|
| 24 | $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; |
|---|
| 25 | |
|---|
| 26 | $out = ''; |
|---|
| 27 | - $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; |
|---|
| 28 | + $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>'; |
|---|
| 29 | |
|---|
| 30 | + |
|---|
| 31 | $columns = get_column_headers('edit-tags'); |
|---|
| 32 | $hidden = get_hidden_columns('edit-tags'); |
|---|
| 33 | $default_term = get_option('default_' . $taxonomy); |
|---|
| 34 | @@ -780,8 +784,10 @@ |
|---|
| 35 | |
|---|
| 36 | $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); |
|---|
| 37 | |
|---|
| 38 | - if ( !empty( $searchterms ) ) |
|---|
| 39 | + if ( !empty( $searchterms ) ) { |
|---|
| 40 | $args['search'] = $searchterms; |
|---|
| 41 | + add_filter('term_name', '_tag_rows_prepend_parents', 20, 2); |
|---|
| 42 | + } |
|---|
| 43 | |
|---|
| 44 | // convert it to table rows |
|---|
| 45 | $out = ''; |
|---|
| 46 | @@ -791,23 +797,36 @@ |
|---|
| 47 | $args['number'] = $args['offset'] = 0; |
|---|
| 48 | |
|---|
| 49 | $terms = get_terms( $taxonomy, $args ); |
|---|
| 50 | - if ( !empty( $searchterms ) ) // Ignore children on searches. |
|---|
| 51 | - $children = array(); |
|---|
| 52 | - else |
|---|
| 53 | - $children = _get_term_hierarchy($taxonomy); |
|---|
| 54 | + $children = _get_term_hierarchy($taxonomy); |
|---|
| 55 | |
|---|
| 56 | - // Some funky recursion to get the job done is contained within, Skip it for non-hierarchical taxonomies for performance sake |
|---|
| 57 | + // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake |
|---|
| 58 | $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count); |
|---|
| 59 | } else { |
|---|
| 60 | $terms = get_terms( $taxonomy, $args ); |
|---|
| 61 | foreach( $terms as $term ) |
|---|
| 62 | - $out .= _tag_row( $term, 0, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); |
|---|
| 63 | + $out .= _tag_row( $term, 0, $taxonomy ); |
|---|
| 64 | } |
|---|
| 65 | + remove_filter('term_name', '_tag_rows_prepend_parents', 20, 2); |
|---|
| 66 | |
|---|
| 67 | echo $out; |
|---|
| 68 | return $count; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | +function _tag_rows_prepend_parents($name, $term) { |
|---|
| 72 | + $parent_ids = array(); |
|---|
| 73 | + $p = $term->parent; |
|---|
| 74 | + while ( $p ) { |
|---|
| 75 | + $my_parent = get_term( $p, $term->taxonomy ); |
|---|
| 76 | + $p = $my_parent->parent; |
|---|
| 77 | + if ( in_array($p, $parent_ids) ) // Prevent parent loops. |
|---|
| 78 | + break; |
|---|
| 79 | + $parent_ids[] = $p; |
|---|
| 80 | + $name = $my_parent->name . ' — ' . $name; |
|---|
| 81 | + } |
|---|
| 82 | + |
|---|
| 83 | + return $name; |
|---|
| 84 | +} |
|---|
| 85 | + |
|---|
| 86 | function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) { |
|---|
| 87 | |
|---|
| 88 | $start = ($page - 1) * $per_page; |
|---|
| 89 | @@ -837,21 +856,20 @@ |
|---|
| 90 | unset($parent_ids); |
|---|
| 91 | |
|---|
| 92 | $num_parents = count($my_parents); |
|---|
| 93 | - $count -= $num_parents; // Do not include parents in the per-page count, This is due to paging issues with unknown numbers of rows. |
|---|
| 94 | while ( $my_parent = array_pop($my_parents) ) { |
|---|
| 95 | - $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); |
|---|
| 96 | + $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy ); |
|---|
| 97 | $num_parents--; |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | if ( $count >= $start ) |
|---|
| 102 | - $output .= "\t" . _tag_row( $term, $level, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); |
|---|
| 103 | - else |
|---|
| 104 | - ++$count; |
|---|
| 105 | + $output .= "\t" . _tag_row( $term, $level, $taxonomy ); |
|---|
| 106 | |
|---|
| 107 | + ++$count; |
|---|
| 108 | + |
|---|
| 109 | unset($terms[$key]); |
|---|
| 110 | |
|---|
| 111 | - if ( isset($children[$term->term_id]) ) |
|---|
| 112 | + if ( isset($children[$term->term_id]) && empty($_GET['s']) ) |
|---|
| 113 | $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 ); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | @@ -2690,7 +2708,7 @@ |
|---|
| 117 | ?> |
|---|
| 118 | </select> |
|---|
| 119 | <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> |
|---|
| 120 | -<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
|---|
| 121 | +<a href="#postcustomstuff" class="hide-if-no-js" onClick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
|---|
| 122 | <span id="enternew"><?php _e('Enter new'); ?></span> |
|---|
| 123 | <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> |
|---|
| 124 | <?php } else { ?> |
|---|
| 125 | @@ -3367,7 +3385,7 @@ |
|---|
| 126 | <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
|---|
| 127 | <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
|---|
| 128 | <input type="text" id="find-posts-input" name="ps" value="" /> |
|---|
| 129 | - <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
|---|
| 130 | + <input type="button" onClick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
|---|
| 131 | |
|---|
| 132 | <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> |
|---|
| 133 | <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label> |
|---|
| 134 | @@ -3377,7 +3395,7 @@ |
|---|
| 135 | <div id="find-posts-response"></div> |
|---|
| 136 | </div> |
|---|
| 137 | <div class="find-box-buttons"> |
|---|
| 138 | - <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> |
|---|
| 139 | + <input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> |
|---|
| 140 | <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" /> |
|---|
| 141 | </div> |
|---|
| 142 | </div> |
|---|