WordPress.org

Make WordPress Core

Changeset 15800


Ignore:
Timestamp:
10/14/10 07:35:13 (7 years ago)
Author:
scribu
Message:

get_edit_term_link() improvements:

  • add optional $object_type parameter
  • make $term_id and $taxonomy parameters mandatory
  • pass all relevant information to the filter
  • use in WP_Terms_Table

See #9702

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/default-list-tables.php

    r15759 r15800  
    16551655        $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); 
    16561656        $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); 
    1657         $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&post_type=$post_type&tag_ID=$tag->term_id"; 
     1657        $edit_link = get_edit_term_url( $tag->term_id, $taxonomy, $post_type ); 
    16581658 
    16591659        $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />'; 
  • trunk/wp-includes/link-template.php

    r15792 r15800  
    650650 * 
    651651 * @param int $tag_id Tag ID 
    652  * @return string 
    653  */ 
    654 function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { 
     652 * @param string $taxonomy Taxonomy 
     653 * @return string 
     654 */ 
     655function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { 
    655656    return apply_filters( 'get_edit_tag_link', get_edit_term_url( $tag_id, $taxonomy ) ); 
    656657} 
     
    678679 * 
    679680 * @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' ) { 
    684     $tax = get_taxonomy($taxonomy); 
    685     if ( !current_user_can($tax->cap->edit_terms) ) 
    686         return; 
    687  
    688     $term = get_term($term_id, $taxonomy); 
    689  
    690     $location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy .'&amp;tag_ID=' . $term->term_id); 
    691  
    692     return apply_filters( 'get_edit_term_url', $location ); 
     681 * @param string $taxonomy Taxonomy 
     682 * @param string $object_type The object type 
     683 * @return string 
     684 */ 
     685function get_edit_term_url( $term_id, $taxonomy, $object_type = '' ) { 
     686    $tax = get_taxonomy( $taxonomy ); 
     687    if ( !current_user_can( $tax->cap->edit_terms ) ) 
     688        return; 
     689 
     690    $term = get_term( $term_id, $taxonomy ); 
     691 
     692    $args = array( 
     693        'action' => 'edit', 
     694        'taxonomy' => $taxonomy, 
     695        'tag_ID' => $term->term_id, 
     696    ); 
     697 
     698    if ( $object_type ) 
     699        $args['post_type'] = $object_type; 
     700 
     701    $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); 
     702 
     703    return apply_filters( 'get_edit_term_url', $location, $term_id, $taxonomy, $object_type ); 
    693704} 
    694705 
     
    705716 */ 
    706717function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { 
    707      
    708     if ( $term == null ) { 
     718    if ( is_null( $term ) ) { 
    709719        global $wp_query; 
    710720        $term = $wp_query->get_queried_object(); 
    711721    } 
    712      
     722 
    713723    $tax = get_taxonomy( $term->taxonomy ); 
    714724    if ( !current_user_can($tax->cap->edit_terms) ) 
    715725        return; 
    716726 
    717     if ( empty($link) ) 
     727    if ( empty( $link ) ) 
    718728        $link = __('Edit This'); 
    719729 
    720730    $link = '<a href="' . get_edit_term_url( $term->term_id, $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>'; 
    721731    $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; 
    722      
     732 
    723733    if ( $echo ) 
    724734        echo $link; 
Note: See TracChangeset for help on using the changeset viewer.