Changeset 12818
- Timestamp:
- 01/24/2010 11:00:27 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
wp-admin/admin-ajax.php (modified) (2 diffs)
-
wp-admin/edit-link-categories.php (modified) (1 diff)
-
wp-admin/edit-tag-form.php (modified) (2 diffs)
-
wp-admin/edit-tags.php (modified) (8 diffs)
-
wp-admin/includes/taxonomy.php (modified) (1 diff)
-
wp-admin/includes/template.php (modified) (9 diffs)
-
wp-admin/js/tags.dev.js (modified) (1 diff)
-
wp-admin/js/tags.js (modified) (1 diff)
-
wp-admin/menu.php (modified) (2 diffs)
-
wp-includes/taxonomy.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r12798 r12818 611 611 } 612 612 613 echo _tag_row( $tag, '', $taxonomy ); 613 $level = 0; 614 $tag_full_name = false; 615 if ( is_taxonomy_hierarchical($taxonomy) ) { 616 $tag_full_name = $tag->name; 617 $_tag = $tag; 618 while ( $_tag->parent ) { 619 $_tag = get_term( $_tag->parent, $taxonomy ); 620 $tag_full_name = $_tag->name . ' — ' . $tag_full_name; 621 $level++; 622 } 623 $tag_full_name = esc_attr($tag_full_name); 624 } 625 echo _tag_row( $tag, $level, $tag_full_name, $taxonomy ); 614 626 exit; 615 627 break; … … 1211 1223 die( __('Tag not updated.') ); 1212 1224 1213 echo _tag_row($tag, '', $taxonomy);1225 echo _tag_row($tag, 0, '', $taxonomy); 1214 1226 } else { 1215 1227 die( __('Tag not updated.') ); -
trunk/wp-admin/edit-link-categories.php
r12736 r12818 227 227 </div><!-- /wrap --> 228 228 229 <?php inline_edit_term_row('edit-link-categories' ); ?>229 <?php inline_edit_term_row('edit-link-categories', 'link_category'); ?> 230 230 <?php include('admin-footer.php'); ?> -
trunk/wp-admin/edit-tag-form.php
r12712 r12818 40 40 <th scope="row" valign="top"><label for="slug"><?php _e('Tag slug') ?></label></th> 41 41 <td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" /> 42 <p class="description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td> 42 <p class="description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td> 43 </tr> 44 <?php } ?> 45 <?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> 46 <tr class="form-field"> 47 <th scope="row" valign="top"><label for="parent"><?php _e('Category Parent') ?></label></th> 48 <td> 49 <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?><br /> 50 <span class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></span> 51 </td> 43 52 </tr> 44 53 <?php } ?> … … 46 55 <th scope="row" valign="top"><label for="description"><?php _e('Description') ?></label></th> 47 56 <td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo esc_html($tag->description); ?></textarea><br /> 48 <span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td>57 <span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td> 49 58 </tr> 50 59 <?php do_action('edit_tag_form_fields', $tag); ?> -
trunk/wp-admin/edit-tags.php
r12816 r12818 45 45 $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); 46 46 if ( $ret && !is_wp_error( $ret ) ) { 47 wp_redirect( 'edit-tags.php?message=1#addtag');47 wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=1#addtag"); 48 48 } else { 49 wp_redirect( 'edit-tags.php?message=4#addtag');49 wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=4#addtag"); 50 50 } 51 51 exit; … … 66 66 wp_delete_term( $tag_ID, $taxonomy); 67 67 68 $location = 'edit-tags.php ';68 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 69 69 if ( $referer = wp_get_referer() ) { 70 70 if ( false !== strpos($referer, 'edit-tags.php') ) … … 89 89 } 90 90 91 $location = 'edit-tags.php ';91 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 92 92 if ( $referer = wp_get_referer() ) { 93 93 if ( false !== strpos($referer, 'edit-tags.php') ) … … 121 121 $ret = wp_update_term($tag_ID, $taxonomy, $_POST); 122 122 123 $location = 'edit-tags.php ';123 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 124 124 if ( $referer = wp_get_original_referer() ) { 125 125 if ( false !== strpos($referer, 'edit-tags.php') ) … … 201 201 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 202 202 203 if ( !empty($_GET['s']) ) 204 $total_terms = count( get_terms( $taxonomy, array( 'search' => trim(stripslashes($_GET['s'])), 'number' => 0, 'hide_empty' => 0 ) ) ); 205 else 203 if ( !empty($_GET['s']) ) { 204 $searchterms = trim(stripslashes($_GET['s'])); 205 $total_terms = count( get_terms( $taxonomy, array( 'search' => $searchterms, 'number' => 0, 'hide_empty' => 0 ) ) ); 206 } else { 207 $searchterms = ''; 206 208 $total_terms = wp_count_terms($taxonomy); 209 } 207 210 208 211 $page_links = paginate_links( array( … … 249 252 <?php 250 253 251 $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '';252 253 254 $count = tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); 254 255 ?> … … 313 314 </div> 314 315 <?php } ?> 316 <?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> 317 <div class="form-field"> 318 <label for="category_parent"><?php _e('Category Parent') ?></label> 319 <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?> 320 <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> 321 </div> 322 <?php } ?> 315 323 <div class="form-field"> 316 324 <label for="description"><?php _e('Description') ?></label> … … 330 338 </div><!-- /wrap --> 331 339 332 <?php inline_edit_term_row('edit-tags' ); ?>340 <?php inline_edit_term_row('edit-tags', $taxonomy); ?> 333 341 334 342 <?php -
trunk/wp-admin/includes/taxonomy.php
r12694 r12818 74 74 } 75 75 76 if ( $post_id)76 if ( $post_id ) 77 77 wp_set_post_categories($post_id, $cat_ids); 78 78 -
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 -
trunk/wp-admin/js/tags.dev.js
r11676 r12818 35 35 } else { 36 36 $('#ajax-response').empty(); 37 $('#the-list').prepend(r); 37 var parent = form.find('select#parent').val(); 38 if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list. 39 $('#the-list #tag-' + parent).after(r); 40 else 41 $('#the-list').prepend(r); 38 42 $('input[type="text"]:visible, textarea:visible', form).val(''); 39 43 } -
trunk/wp-admin/js/tags.js
r11676 r12818 1 jQuery(document).ready(function( a){a(".delete-tag").live("click",function(g){var b=a(this),f=b.parents("tr"),c=true,d;if("undefined"!=showNotice){c=showNotice.warn()}if(c){d=b.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");a.post(ajaxurl,d,function(e){if("1"==e){a("#ajax-response").empty();f.fadeOut("normal",function(){f.remove()})}else{if("-1"==e){a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");f.children().css("backgroundColor","")}else{a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");f.children().css("backgroundColor","")}}});f.children().css("backgroundColor","#f33")}return false});a("#submit").click(function(){var b=a(this).parents("form");if(!validateForm(b)){return false}a.post(ajaxurl,a("#addtag").serialize(),function(c){if(c.indexOf('<div class="error"')===0){a("#ajax-response").append(c)}else{a("#ajax-response").empty();a("#the-list").prepend(c);a('input[type="text"]:visible, textarea:visible',b).val("")}});return false})});1 jQuery(document).ready(function($){$(".delete-tag").live("click",function(e){var t=$(this),tr=t.parents("tr"),r=true,data;if("undefined"!=showNotice){r=showNotice.warn()}if(r){data=t.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");$.post(ajaxurl,data,function(r){if("1"==r){$("#ajax-response").empty();tr.fadeOut("normal",function(){tr.remove()})}else{if("-1"==r){$("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");tr.children().css("backgroundColor","")}else{$("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");tr.children().css("backgroundColor","")}}});tr.children().css("backgroundColor","#f33")}return false});$("#submit").click(function(){var form=$(this).parents("form");if(!validateForm(form)){return false}$.post(ajaxurl,$("#addtag").serialize(),function(r){if(r.indexOf('<div class="error"')===0){$("#ajax-response").append(r)}else{$("#ajax-response").empty();var parent=form.find("select#parent").val();if(parent>0&&$("#tag-"+parent).length>0){$("#the-list #tag-"+parent).after(r)}else{$("#the-list").prepend(r)}$('input[type="text"]:visible, textarea:visible',form).val("")}});return false})}); -
trunk/wp-admin/menu.php
r12789 r12818 51 51 continue; 52 52 53 if ( $tax->hierarchical ) 54 $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'categories.php?taxonomy=' . $tax->name ); 55 else 56 $submenu['edit.php'][$i] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name ); 57 ++$i; 53 $submenu['edit.php'][$i++] = array( esc_attr($tax->label), 'manage_categories', 'edit-tags.php?taxonomy=' . $tax->name ); 58 54 } 59 55 … … 91 87 continue; 92 88 93 if ( $tax->hierarchical ) 94 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "categories.php?taxonomy=$tax->name&post_type=$ptype" ); 95 else 96 $submenu["edit.php?post_type=$ptype"][$i] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 97 ++$i; 89 $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), 'manage_categories', "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" ); 98 90 } 99 91 } -
trunk/wp-includes/taxonomy.php
r12798 r12818 787 787 // don't limit the query results when we have to descend the family tree 788 788 if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' === $parent ) { 789 if ( $offset )789 if ( $offset ) 790 790 $limit = 'LIMIT ' . $offset . ',' . $number; 791 791 else 792 792 $limit = 'LIMIT ' . $number; 793 794 } else 793 } else { 795 794 $limit = ''; 795 } 796 796 797 797 if ( !empty($search) ) { … … 2447 2447 } 2448 2448 2449 2449 2450 ?>
Note: See TracChangeset
for help on using the changeset viewer.