Changeset 12818 for trunk/wp-admin/includes/template.php
- Timestamp:
- 01/24/2010 11:00:27 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/template.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r12812 r12818 206 206 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. 207 207 * 208 * @param string $type "tag", "category" or "link-category" 208 * @param string $type "edit-tags", "categoried" or "edit-link-categories" 209 * @param string $taxonomy The taxonomy of the row. 209 210 * @return 210 211 */ 211 function inline_edit_term_row($type ) {212 function inline_edit_term_row($type, $taxonomy) { 212 213 213 214 if ( ! current_user_can( 'manage_categories' ) ) 214 215 return; 215 216 216 $is_tag = $type == 'edit-tags';217 217 $columns = get_column_headers($type); 218 218 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); … … 237 237 <?php } ?> 238 238 239 <?php if ( 'category' == $type ) : ?> 240 239 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> 241 240 <label> 242 241 <span class="title"><?php _e( 'Parent' ); ?></span> 243 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, ' show_option_none' => __('None'))); ?>242 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'taxonomy' => $taxonomy, 'show_option_none' => __('None'))); ?> 244 243 </label> 245 244 246 <?php endif; // $ type?>245 <?php endif; // $hierarchical ?> 247 246 248 247 </div></fieldset> … … 255 254 if ( isset( $core_columns[$column_name] ) ) 256 255 continue; 257 do_action( 'quick_edit_custom_box', $column_name, $type );256 do_action( 'quick_edit_custom_box', $column_name, $type, $taxonomy ); 258 257 } 259 258 … … 262 261 <p class="inline-edit-save submit"> 263 262 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a> 264 <?php $update_text = ( $is_tag) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>263 <?php $update_text = ( 'post_tag' == $taxonomy ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?> 265 264 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a> 266 265 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /> … … 672 671 * @return unknown 673 672 */ 674 function _tag_row( $tag, $ class = '', $taxonomy = 'post_tag' ) {673 function _tag_row( $tag, $level, $class = '', $taxonomy = 'post_tag' ) { 675 674 $count = number_format_i18n( $tag->count ); 676 $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy); 675 if ( 'post_tag' == $taxonomy ) 676 $tagsel = 'tag'; 677 elseif ( 'category' == $taxonomy ) 678 $tagsel = 'category_name'; 679 else 680 $tagsel = $taxonomy; 677 681 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count; 678 682 679 $name = apply_filters( 'term_name', $tag->name ); 683 $pad = str_repeat( '— ', max(0, $level) ); 684 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name ); 680 685 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); 681 686 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; … … 695 700 switch ($column_name) { 696 701 case 'cb': 697 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; 702 if ( $tag->term_id != get_option('default_' . $taxonomy) ) 703 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; 704 else 705 $out .= '<th scope="row" class="check-column"> </th>'; 698 706 break; 699 707 case 'name': … … 702 710 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; 703 711 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; 704 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; 712 if ( $tag->term_id != get_option('default_' . $taxonomy) ) 713 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; 714 705 715 $actions = apply_filters('tag_row_actions', $actions, $tag); 716 $actions = apply_filters("${taxonomy}_row_actions", $actions, $tag); 717 706 718 $action_count = count($actions); 707 719 $i = 0; … … 715 727 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; 716 728 $out .= '<div class="name">' . $qe_data->name . '</div>'; 717 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div></div></td>'; 729 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>'; 730 $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>'; 718 731 break; 719 732 case 'description': … … 759 772 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); 760 773 761 if ( !empty( $searchterms ) ) {774 if ( !empty( $searchterms ) ) 762 775 $args['search'] = $searchterms; 763 }764 765 $tags = get_terms( $taxonomy, $args );766 776 767 777 // convert it to table rows 768 778 $out = ''; 769 779 $count = 0; 770 foreach( $tags as $tag ) 771 $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 780 if ( is_taxonomy_hierarchical($taxonomy) ) { 781 // We'll need the full set of terms then. 782 $args['number'] = $args['offset'] = 0; 783 784 $terms = get_terms( $taxonomy, $args ); 785 if ( !empty( $searchterms ) ) // Ignore children on searches. 786 $children = array(); 787 else 788 $children = _get_term_hierarchy($taxonomy); 789 790 // Some funky recursion to get the job done is contained within, Skip it for non-hierarchical taxonomies for performance sake 791 $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count); 792 } else { 793 $terms = get_terms( $taxonomy, $args ); 794 foreach( $terms as $term ) 795 $out .= _tag_row( $term, 0, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 796 } 772 797 773 798 // filter and send to screen 774 799 echo $out; 775 800 return $count; 801 } 802 803 function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) { 804 805 $start = ($page - 1) * $per_page; 806 $end = $start + $per_page; 807 808 $output = ''; 809 foreach ( $terms as $key => $term ) { 810 811 if ( $count >= $end ) 812 break; 813 814 if ( $term->parent != $parent && empty($_GET['s']) ) 815 continue; 816 817 // If the page starts in a subtree, print the parents. 818 if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) { 819 $my_parents = $parent_ids = array(); 820 $p = $term->parent; 821 while ( $p ) { 822 $my_parent = get_term( $p, $taxonomy ); 823 $my_parents[] = $my_parent; 824 $p = $my_parent->parent; 825 if ( in_array($p, $parent_ids) ) // Prevent parent loops. 826 break; 827 $parent_ids[] = $p; 828 } 829 unset($parent_ids); 830 831 $num_parents = count($my_parents); 832 $count -= $num_parents; // Do not include parents in the per-page count, This is due to paging issues with unknown numbers of rows. 833 while ( $my_parent = array_pop($my_parents) ) { 834 $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 835 $num_parents--; 836 } 837 } 838 839 if ( $count >= $start ) 840 $output .= "\t" . _tag_row( $term, $level, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); 841 else 842 ++$count; 843 844 unset($terms[$key]); 845 846 if ( isset($children[$term->term_id]) ) 847 $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 ); 848 } 849 850 return $output; 776 851 } 777 852
Note: See TracChangeset
for help on using the changeset viewer.