WordPress.org

Make WordPress Core

Changeset 13213


Ignore:
Timestamp:
02/19/10 09:54:18 (4 years ago)
Author:
dd32
Message:

Fix $post_type handling/passing in the Taxonomy edit links. Fix the Tag selection query var for edit.php in the Posts links. See #12270, See #11838

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-tags.php

    r13160 r13213  
    4646 
    4747    $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); 
    48     if ( $ret && !is_wp_error( $ret ) ) { 
    49         wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=1#addtag"); 
    50     } else { 
    51         wp_redirect("edit-tags.php?taxonomy=$taxonomy&message=4#addtag"); 
    52     } 
     48    $location = 'edit-tags.php?taxonomy=' . $taxonomy; 
     49    if ( 'post' != $post_type ) 
     50        $location .= '&post_type=' . $post_type; 
     51 
     52    if ( $referer = wp_get_original_referer() ) { 
     53        if ( false !== strpos($referer, 'edit-tags.php') ) 
     54            $location = $referer; 
     55    } 
     56 
     57    if ( $ret && !is_wp_error( $ret ) ) 
     58        $location = add_query_arg('message', 1, $location); 
     59    else 
     60        $location = add_query_arg('message', 4, $location); 
    5361    exit; 
    5462break; 
    5563 
    5664case 'delete': 
    57     if ( !isset( $_GET['tag_ID'] ) ) { 
    58         wp_redirect("edit-tags.php?taxonomy=$taxonomy"); 
    59         exit; 
    60     } 
    61  
    62     $tag_ID = (int) $_GET['tag_ID']; 
    63     check_admin_referer('delete-tag_' .  $tag_ID); 
    64  
    65     if ( !current_user_can($tax->delete_cap) ) 
    66         wp_die(__('Cheatin’ uh?')); 
    67  
    68     wp_delete_term( $tag_ID, $taxonomy); 
    69  
    7065    $location = 'edit-tags.php?taxonomy=' . $taxonomy; 
     66    if ( 'post' != $post_type ) 
     67        $location .= '&post_type=' . $post_type; 
    7168    if ( $referer = wp_get_referer() ) { 
    7269        if ( false !== strpos($referer, 'edit-tags.php') ) 
     
    7471    } 
    7572 
     73    if ( !isset( $_GET['tag_ID'] ) ) { 
     74        wp_redirect($location); 
     75        exit; 
     76    } 
     77 
     78    $tag_ID = (int) $_GET['tag_ID']; 
     79    check_admin_referer('delete-tag_' .  $tag_ID); 
     80 
     81    if ( !current_user_can($tax->delete_cap) ) 
     82        wp_die(__('Cheatin’ uh?')); 
     83 
     84    wp_delete_term( $tag_ID, $taxonomy); 
     85 
    7686    $location = add_query_arg('message', 2, $location); 
    7787    wp_redirect($location); 
     
    92102 
    93103    $location = 'edit-tags.php?taxonomy=' . $taxonomy; 
     104    if ( 'post' != $post_type ) 
     105        $location .= '&post_type=' . $post_type; 
    94106    if ( $referer = wp_get_referer() ) { 
    95107        if ( false !== strpos($referer, 'edit-tags.php') ) 
     
    124136 
    125137    $location = 'edit-tags.php?taxonomy=' . $taxonomy; 
     138    if ( 'post' != $post_type ) 
     139        $location .= '&post_type=' . $post_type; 
     140 
    126141    if ( $referer = wp_get_original_referer() ) { 
    127142        if ( false !== strpos($referer, 'edit-tags.php') ) 
  • trunk/wp-admin/includes/template.php

    r13197 r13213  
    453453 */ 
    454454function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) { 
     455        global $post_type; 
    455456        static $row_class = ''; 
    456457        $row_class = ($row_class == '' ? ' class="alternate"' : ''); 
    457458 
    458459        $count = number_format_i18n( $tag->count ); 
    459         if ( 'post_tag' == $taxonomy ) 
     460        $tax = get_taxonomy($taxonomy); 
     461 
     462        if ( 'post_tag' == $taxonomy ) { 
    460463            $tagsel = 'tag'; 
    461         elseif ( 'category' == $taxonomy ) 
     464        } elseif ( 'category' == $taxonomy ) { 
    462465            $tagsel = 'category_name'; 
    463         else 
     466        } elseif ( ! empty($tax->query_var) ) { 
     467            $tagsel = $tax->query_var; 
     468        } else { 
    464469            $tagsel = $taxonomy; 
    465  
    466         $tax = get_taxonomy($taxonomy); 
    467  
    468         $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count; 
     470        } 
     471 
     472        $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug&amp;post_type=$post_type'>$count</a>" : $count; 
    469473 
    470474        $pad = str_repeat( '&#8212; ', max(0, $level) ); 
    471475        $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); 
    472476        $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); 
    473         $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id"; 
     477        $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;post_type=$post_type&amp;tag_ID=$tag->term_id"; 
    474478 
    475479        $out = ''; 
     
    587591        foreach( $terms as $term ) 
    588592            $out .= _tag_row( $term, 0, $taxonomy ); 
     593        $count = $pagesize; // Only displaying a single page. 
    589594    } 
    590595 
     
    32843289                <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 
    32853290                <input type="text" id="find-posts-input" name="ps" value="" /> 
    3286                 <input type="button" onClick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 
     3291                <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 
    32873292 
    32883293                <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> 
     
    32943299        </div> 
    32953300        <div class="find-box-buttons"> 
    3296             <input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> 
     3301            <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> 
    32973302            <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" /> 
    32983303        </div> 
  • trunk/wp-includes/link-template.php

    r13212 r13213  
    620620 */ 
    621621function get_edit_tag_link( $tag_id = 0, $taxonomy = 'post_tag' ) { 
     622    global $post_type; 
    622623    $tax = get_taxonomy($taxonomy); 
    623624    if ( !current_user_can($tax->edit_cap) ) 
    624625        return; 
    625      
     626 
    626627    $tag = get_term($tag_id, $taxonomy); 
    627628 
    628     $location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;tag_ID=' . $tag->term_id); 
     629    $location = admin_url('edit-tags.php?action=edit&amp;taxonomy=' . $taxonomy . '&amp;' . (!empty($post_type) ? 'post_type=' . $post_type .'&amp;' : '') .'tag_ID=' . $tag->term_id); 
    629630    return apply_filters( 'get_edit_tag_link', $location ); 
    630631} 
Note: See TracChangeset for help on using the changeset viewer.