Ticket #9702: edit_term_link.2.patch
File edit_term_link.2.patch, 3.2 KB (added by , 15 years ago) |
---|
-
wp-includes/link-template.php
652 652 * @return string 653 653 */ 654 654 function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { 655 global $post_type; 655 return apply_filters( 'get_edit_tag_link', get_edit_term_url( $tag_id, $taxonomy ) ); 656 } 657 658 /** 659 * Display or retrieve edit tag link with formatting. 660 * 661 * @since 2.7.0 662 * 663 * @param string $link Optional. Anchor text. 664 * @param string $before Optional. Display before edit link. 665 * @param string $after Optional. Display after edit link. 666 * @param int|object $tag Tag object or ID 667 * @return string HTML content. 668 */ 669 function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { 670 $link = edit_term_link( $link, '', '', false, $tag ); 671 echo $before . apply_filters( 'edit_tag_link', $link ) . $after; 672 } 673 674 /** 675 * Retrieve edit tag link. 676 * 677 * @since 3.1 678 * 679 * @param int $term_id Term ID 680 * @param int $taxonomy Taxonomy 681 * @return string 682 */ 683 function get_edit_term_url( $term_id = 0, $taxonomy = 'post_tag' ) { 656 684 $tax = get_taxonomy($taxonomy); 657 685 if ( !current_user_can($tax->cap->edit_terms) ) 658 686 return; 659 687 660 $t ag = get_term($tag_id, $taxonomy);688 $term = get_term($term_id, $taxonomy); 661 689 662 $location = admin_url('edit-tags.php?action=edit&taxonomy=' . $taxonomy . '&' . (!empty($post_type) ? 'post_type=' . $post_type .'&' : '') .'tag_ID=' . $tag->term_id); 663 return apply_filters( 'get_edit_tag_link', $location ); 690 $location = admin_url('edit-tags.php?action=edit&taxonomy=' . $taxonomy .'&tag_ID=' . $term->term_id); 691 692 return apply_filters( 'get_edit_term_url', $location ); 664 693 } 665 694 666 695 /** 667 * Display or retrieve edit t aglink with formatting.696 * Display or retrieve edit term link with formatting. 668 697 * 669 * @since 2.7.0698 * @since 3.1 670 699 * 671 700 * @param string $link Optional. Anchor text. 672 701 * @param string $before Optional. Display before edit link. 673 702 * @param string $after Optional. Display after edit link. 674 * @param int|object $tag Tag object or ID675 * @return string |null HTML content, if $echo is set to false.703 * @param object $term Term object 704 * @return string HTML content. 676 705 */ 677 function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { 678 $tax = get_taxonomy('post_tag'); 706 function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { 707 708 if ( $term == null ) { 709 global $wp_query; 710 $term = $wp_query->get_queried_object(); 711 } 712 713 $tax = get_taxonomy( $term->taxonomy ); 679 714 if ( !current_user_can($tax->cap->edit_terms) ) 680 715 return; 681 716 682 $tag = get_term($tag, 'post_tag');683 684 717 if ( empty($link) ) 685 718 $link = __('Edit This'); 686 719 687 $link = '<a href="' . get_edit_tag_link( $tag->term_id ) . '" title="' . __( 'Edit Tag' ) . '">' . $link . '</a>'; 688 echo $before . apply_filters( 'edit_tag_link', $link, $tag->term_id ) . $after; 720 $link = '<a href="' . get_edit_term_url( $term->term_id, $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>'; 721 $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; 722 723 if ( $echo ) 724 echo $link; 725 else 726 return $link; 689 727 } 690 728 691 729 /**