Make WordPress Core

Changeset 36308


Ignore:
Timestamp:
01/15/2016 08:26:06 AM (9 years ago)
Author:
swissspidy
Message:

Taxonomy: Introduce wp-admin/term.php for editing single terms.

This is similar to edit.php -> post.php and users.php -> user-edit.php and fixes a bug where screen options for the list table were shown while editing a term.

Fixes #34988.

Location:
trunk/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-tag-form.php

    r35875 r36308  
    88
    99// don't load directly
    10 if ( !defined('ABSPATH') )
    11     die('-1');
    12 
    13 if ( empty($tag_ID) ) { ?>
    14 <div class="wrap">
    15     <h1><?php echo $tax->labels->edit_item; ?></h1>
    16     <div id="message" class="notice notice-warning"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
    17 </div>
    18 <?php
    19     return;
     10if ( ! defined( 'ABSPATH' ) ) {
     11    die( '-1' );
    2012}
    2113
     
    5850wp_reset_vars( array( 'wp_http_referer' ) );
    5951
    60 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
     52$wp_http_referer = remove_query_arg( array( 'action', 'message', 'term_id' ), $wp_http_referer );
    6153
    6254/** Also used by Edit Tags */
     
    10496do_action( "{$taxonomy}_term_edit_form_tag" );
    10597?>>
    106 <input type="hidden" name="action" value="editedtag" />
    107 <input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_id) ?>" />
    108 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
    109 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
     98<input type="hidden" name="action" value="editedtag"/>
     99<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $term_id ) ?>"/>
     100<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
     101<?php
     102wp_original_referer_field( true, 'previous' );
     103wp_nonce_field( 'update-tag_' . $term_id );
     104?>
    110105    <table class="form-table">
    111106        <tr class="form-field form-required term-name-wrap">
  • trunk/src/wp-admin/edit-tags.php

    r36302 r36308  
    151151
    152152case 'edit':
    153     $title = $tax->labels->edit_item;
    154 
    155153    if ( ! isset( $_REQUEST['tag_ID'] ) ) {
    156154        break;
    157155    }
    158156
    159     $tag_ID = (int) $_REQUEST['tag_ID'];
    160 
    161     $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
    162     if ( ! $tag )
     157    $term_id = (int) $_REQUEST['tag_ID'];
     158    $term    = get_term( $term_id );
     159
     160    if ( ! $term instanceof WP_Term ) {
    163161        wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
    164     require_once( ABSPATH . 'wp-admin/admin-header.php' );
    165     include( ABSPATH . 'wp-admin/edit-tag-form.php' );
    166     include( ABSPATH . 'wp-admin/admin-footer.php' );
    167 
     162    }
     163
     164    wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
    168165    exit;
    169166
  • trunk/src/wp-includes/link-template.php

    r36300 r36308  
    927927
    928928    $args = array(
    929         'action' => 'edit',
    930929        'taxonomy' => $taxonomy,
    931         'tag_ID' => $term->term_id,
     930        'term_id' => $term->term_id,
    932931    );
    933932
     
    939938
    940939    if ( $tax->show_ui ) {
    941         $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) );
     940        $location = add_query_arg( $args, admin_url( 'term.php' ) );
    942941    } else {
    943942        $location = '';
Note: See TracChangeset for help on using the changeset viewer.