Changeset 13086
- Timestamp:
- 02/13/2010 05:40:47 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r13046 r13086 539 539 $tax = get_taxonomy($taxonomy); 540 540 541 $x = new WP_Ajax_Response(); 542 541 543 if ( !current_user_can( $tax->edit_cap ) ) 542 544 die('-1'); … … 545 547 546 548 if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { 547 echo '<div class="error"><p>' . __('An error has occured. Please reload the page and try again.') . '</p></div>'; 548 exit; 549 $message = __('An error has occured. Please reload the page and try again.'); 550 if ( is_wp_error($tag) && $tag->get_error_message() ) 551 $message = $tag->get_error_message(); 552 553 $x->add( array( 554 'what' => 'taxonomy', 555 'data' => new WP_Error('error', $message ) 556 ) ); 557 $x->send(); 549 558 } 550 559 551 560 $level = 0; 552 561 $tag_full_name = false; 562 $tag_full_name = $tag->name; 553 563 if ( is_taxonomy_hierarchical($taxonomy) ) { 554 $tag_full_name = $tag->name;555 564 $_tag = $tag; 556 while ( $_tag->parent ) {565 while ( $_tag->parent ) { 557 566 $_tag = get_term( $_tag->parent, $taxonomy ); 558 567 $tag_full_name = $_tag->name . ' — ' . $tag_full_name; 559 568 $level++; 560 569 } 561 $tag_full_name = esc_attr($tag_full_name); 562 } 563 echo _tag_row( $tag, $level, $tag_full_name, $taxonomy ); 564 exit; 570 } 571 if ( is_taxonomy_hierarchical($taxonomy) ) 572 $noparents = _tag_row( $tag, $level, $taxonomy ); 573 $tag->name = $tag_full_name; 574 $parents = _tag_row( $tag, 0, $taxonomy); 575 576 $x->add( array( 577 'what' => 'taxonomy', 578 'supplemental' => compact('parents', 'noparents') 579 ) ); 580 $x->add( array( 581 'what' => 'term', 582 'position' => $level, 583 'supplemental' => get_term( $tag->term_id, $taxonomy, ARRAY_A ) //Refetch as $tag has been contaminated by the full name. 584 ) ); 585 $x->send(); 565 586 break; 566 587 case 'get-tagcloud' : -
trunk/wp-admin/includes/template.php
r13081 r13086 483 483 * @return unknown 484 484 */ 485 function _tag_row( $tag, $level, $class = '', $taxonomy = 'post_tag' ) { 485 function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { 486 static $row_class = ''; 487 $row_class = ($row_class == '' ? ' class="alternate"' : ''); 488 486 489 $count = number_format_i18n( $tag->count ); 487 490 if ( 'post_tag' == $taxonomy ) … … 497 500 498 501 $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 ); 500 503 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); 501 504 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; 502 505 503 506 $out = ''; 504 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; 507 $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>'; 508 505 509 506 510 $columns = get_column_headers('edit-tags'); … … 608 612 $children = _get_term_hierarchy($taxonomy); 609 613 610 // Some funky recursion to get the job done is contained within, Skip it for non-hierarchical taxonomies for performance sake614 // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake 611 615 $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count); 612 616 } else { 613 617 $terms = get_terms( $taxonomy, $args ); 614 618 foreach( $terms as $term ) 615 $out .= _tag_row( $term, 0, ++$count % 2 ? ' class="alternate"' : '',$taxonomy );619 $out .= _tag_row( $term, 0, $taxonomy ); 616 620 } 617 621 … … 649 653 650 654 $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.652 655 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 ); 654 657 $num_parents--; 655 658 } … … 657 660 658 661 if ( $count >= $start ) 659 $output .= "\t" . _tag_row( $term, $level, ++$count % 2 ? ' class="alternate"' : '',$taxonomy );660 else 661 662 $output .= "\t" . _tag_row( $term, $level, $taxonomy ); 663 664 ++$count; 662 665 663 666 unset($terms[$key]); 664 667 665 if ( isset($children[$term->term_id]) )668 if ( isset($children[$term->term_id]) && empty($_GET['s']) ) 666 669 $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 ); 667 670 } -
trunk/wp-admin/js/tags.dev.js
r12818 r13086 11 11 $('#ajax-response').empty(); 12 12 tr.fadeOut('normal', function(){ tr.remove(); }); 13 // Remove the term from the parent box and tag cloud 14 $('select#parent option[value=' + data.match(/tag_ID=(\d+)/)[1] + ']').remove(); 15 $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove(); 13 16 } else if ( '-1' == r ) { 14 17 $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>'); … … 31 34 32 35 $.post(ajaxurl, $('#addtag').serialize(), function(r){ 33 if ( r.indexOf('<div class="error"') === 0 ) { 34 $('#ajax-response').append(r); 35 } else { 36 $('#ajax-response').empty(); 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); 42 $('input[type="text"]:visible, textarea:visible', form).val(''); 36 $('#ajax-response').empty(); 37 var res = wpAjax.parseAjaxResponse(r, 'ajax-response'); 38 if ( ! res ) 39 return; 40 41 var parent = form.find('select#parent').val(); 42 43 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. 44 $('#the-list #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed 45 else 46 $('#the-list').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm 47 48 if ( form.find('select#parent') ) { 49 // Parents field exists, Add new term to the list. 50 var term = res.responses[1].supplemental; 51 52 // Create an indent for the Parent field 53 var indent = ''; 54 for ( var i = 0; i < res.responses[1].position; i++ ) 55 indent += ' '; 56 57 form.find('select#parent option:selected').after('<option value="' + term['term_id'] + '">' + indent + term['name'] + '</option>'); 43 58 } 59 60 $('input[type="text"]:visible, textarea:visible', form).val(''); 44 61 }); 45 62 -
trunk/wp-admin/js/tags.js
r12818 r13086 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})});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()});$("select#parent option[value="+data.match(/tag_ID=(\d+)/)[1]+"]").remove();$("a.tag-link-"+data.match(/tag_ID=(\d+)/)[1]).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){$("#ajax-response").empty();var res=wpAjax.parseAjaxResponse(r,"ajax-response");if(!res){return}var parent=form.find("select#parent").val();if(parent>0&&$("#tag-"+parent).length>0){$("#the-list #tag-"+parent).after(res.responses[0].supplemental.noparents)}else{$("#the-list").prepend(res.responses[0].supplemental.parents)}if(form.find("select#parent")){var term=res.responses[1].supplemental;var indent="";for(var i=0;i<res.responses[1].position;i++){indent+=" "}form.find("select#parent option:selected").after('<option value="'+term.term_id+'">'+indent+term.name+"</option>")}$('input[type="text"]:visible, textarea:visible',form).val("")});return false})}); -
trunk/wp-includes/category-template.php
r12798 r13086 365 365 else 366 366 $output = ''; 367 368 if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) { 369 $show_option_none = apply_filters( 'list_cats', $show_option_none ); 370 $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n"; 371 } 372 367 373 if ( ! empty( $categories ) ) { 368 374
Note: See TracChangeset
for help on using the changeset viewer.