Ticket #11838: 11838.3.diff
| File 11838.3.diff, 21.4 KB (added by dd32, 3 years ago) |
|---|
-
wp-admin/admin-ajax.php
610 610 exit; 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; 616 628 case 'get-tagcloud' : … … 862 874 $mid = (int) array_pop(array_keys($_POST['meta'])); 863 875 $key = $_POST['meta'][$mid]['key']; 864 876 $value = $_POST['meta'][$mid]['value']; 877 if ( '' == trim($value) ) 878 die(__('Please provide a custom field value.')); 865 879 if ( !$meta = get_post_meta_by_id( $mid ) ) 866 880 die('0'); // if meta doesn't exist 867 881 if ( !current_user_can( 'edit_post', $meta->post_id ) ) … … 1210 1224 if ( !$tag || is_wp_error( $tag ) ) 1211 1225 die( __('Tag not updated.') ); 1212 1226 1213 echo _tag_row($tag, '', $taxonomy);1227 echo _tag_row($tag, 0, '', $taxonomy); 1214 1228 } else { 1215 1229 die( __('Tag not updated.') ); 1216 1230 } -
wp-admin/edit-link-categories.php
226 226 </div><!-- /col-container --> 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'); ?> -
wp-admin/edit-tag-form.php
39 39 <tr class="form-field"> 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 43 </tr> 44 44 <?php } ?> 45 <?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> 45 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> 52 </tr> 53 <?php } ?> 54 <tr class="form-field"> 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); ?> 51 60 </table> -
wp-admin/edit-tags.php
44 44 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; 52 52 break; … … 65 65 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') ) 71 71 $location = $referer; … … 88 88 wp_delete_term( $tag_ID, $taxonomy); 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') ) 94 94 $location = $referer; … … 120 120 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') ) 126 126 $location = $referer; … … 200 200 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 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( 209 212 'base' => add_query_arg( 'pagenum', '%#%' ), … … 248 251 <tbody id="the-list" class="list:tag"> 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 ?> 255 256 </tbody> … … 312 313 <p><?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> 313 314 </div> 314 315 <?php } ?> 316 <?php if ( is_taxonomy_hierarchical($taxonomy) ) { ?> 315 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 } ?> 323 <div class="form-field"> 316 324 <label for="description"><?php _e('Description') ?></label> 317 325 <textarea name="description" id="description" rows="5" cols="40"></textarea> 318 326 <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> … … 329 337 </div><!-- /col-container --> 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 335 343 break; -
wp-admin/includes/dashboard.php
274 274 $num = number_format_i18n( $num_cats ); 275 275 $text = _n( 'Category', 'Categories', $num_cats ); 276 276 if ( current_user_can( 'manage_categories' ) ) { 277 $num = "<a href=' categories.php'>$num</a>";278 $text = "<a href=' categories.php'>$text</a>";277 $num = "<a href='edit-tags.php?taxonomy=category'>$num</a>"; 278 $text = "<a href='edit-tags.php?taxonomy=category'>$text</a>"; 279 279 } 280 280 echo '<td class="first b b-cats">' . $num . '</td>'; 281 281 echo '<td class="t cats">' . $text . '</td>'; -
wp-admin/includes/taxonomy.php
73 73 $cat_ids[] = $id; 74 74 } 75 75 76 if ( $post_id)76 if ( $post_id ) 77 77 wp_set_post_categories($post_id, $cat_ids); 78 78 79 79 return $cat_ids; -
wp-admin/includes/template.php
205 205 * 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) ) ); 219 219 $col_count = count($columns) - count($hidden); … … 236 236 </label> 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 242 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?> 244 243 </label> 245 244 246 <?php endif; // $ type?>245 <?php endif; // $hierarchical ?> 247 246 248 247 </div></fieldset> 249 248 … … 254 253 foreach ( $columns as $column_name => $column_display_name ) { 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 260 259 ?> 261 260 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="" /> 267 266 <span class="error" style="display:none;"></span> … … 671 670 * @param unknown_type $class 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"; 682 687 $out = ''; … … 694 699 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': 700 708 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />'; 701 709 $actions = array(); 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; 708 720 $out .= '<div class="row-actions">'; … … 714 726 $out .= '</div>'; 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': 720 733 $out .= "<td $attributes>$tag->description</td>"; … … 758 771 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 776 765 $tags = get_terms( $taxonomy, $args );766 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; 772 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 } 797 773 798 // filter and send to screen 774 799 echo $out; 775 800 return $count; 776 801 } 777 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; 851 } 852 778 853 // define the columns to display, the syntax is 'internal name' => 'display name' 779 854 /** 780 855 * {@internal Missing Short Description}} -
wp-admin/js/tags.dev.js
34 34 $('#ajax-response').append(r); 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 } 40 44 }); … … 42 46 return false; 43 47 }); 44 48 45 }); 49 }); 50 No newline at end of file -
wp-admin/js/tags.js
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})});2 No newline at end of file 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})}); 2 No newline at end of file -
wp-admin/menu.php
50 50 if ( ! in_array('post', (array) $tax->object_type, true) ) 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 60 56 $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top', 'menu-media', 'div' ); … … 90 86 if ( ! in_array($ptype, (array) $tax->object_type, true) ) 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 } 100 92 unset($ptype, $ptype_obj);