Make WordPress Core

Ticket #34988: 34988.diff

File 34988.diff, 5.8 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/edit-tag-form.php

    diff --git src/wp-admin/edit-tag-form.php src/wp-admin/edit-tag-form.php
    index b8d2340..ea92a2d 100644
     
    77 */
    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
    2214// Back compat hooks
    if ( 'category' == $taxonomy ) { 
    5749 */
    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 */
    6355require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
    do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?> 
    10395 */
    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">
    112107                        <th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
  • src/wp-admin/edit-tags.php

    diff --git src/wp-admin/edit-tags.php src/wp-admin/edit-tags.php
    index 713c8b9..b953da6 100644
    case 'bulk-delete': 
    150150        break;
    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'];
     157        $term_id = (int) $_REQUEST['tag_ID'];
     158        $term    = get_term( $term_id );
    160159
    161         $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
    162         if ( ! $tag )
     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' );
     162        }
    167163
     164        wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
    168165        exit;
    169166
    170167case 'editedtag':
  • new file src/wp-admin/term.php

    diff --git src/wp-admin/term.php src/wp-admin/term.php
    new file mode 100644
    index 0000000..76990f7
    - +  
     1<?php
     2/**
     3 * Edit Term Administration Screen.
     4 *
     5 * @package    WordPress
     6 * @subpackage Administration
     7 */
     8
     9/** WordPress Administration Bootstrap */
     10require_once( dirname( __FILE__ ) . '/admin.php' );
     11
     12if ( empty( $_REQUEST['term_id'] ) ) {
     13        $sendback = admin_url( 'edit-tags.php' );
     14        if ( ! empty( $taxnow ) ) {
     15                $sendback = add_query_arg( array( 'taxonomy' => $taxnow ), $sendback );
     16        }
     17        wp_redirect( esc_url( $sendback ) );
     18        exit;
     19}
     20
     21$term_id = absint( $_REQUEST['term_id'] );
     22$tag    = get_term( $term_id, $taxnow, OBJECT, 'edit' );
     23
     24if ( ! $tag instanceof WP_Term ) {
     25        wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
     26}
     27
     28$tax      = get_taxonomy( $tag->taxonomy );
     29$taxonomy = $tax->name;
     30$title    = $tax->labels->edit_item;
     31
     32if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
     33     ! current_user_can( $tax->cap->manage_terms )
     34) {
     35        wp_die(
     36                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     37                '<p>' . __( 'You are not allowed to manage this item.' ) . '</p>',
     38                403
     39        );
     40}
     41
     42$post_type = get_current_screen()->post_type;
     43
     44// Default to the first object_type associated with the taxonomy if no post type was passed.
     45if ( empty( $post_type ) ) {
     46        $post_type = reset( $tax->object_type );
     47}
     48
     49if ( 'post' != $post_type ) {
     50        $parent_file  = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
     51        $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
     52} elseif ( 'link_category' == $taxonomy ) {
     53        $parent_file  = 'link-manager.php';
     54        $submenu_file = 'edit-tags.php?taxonomy=link_category';
     55} else {
     56        $parent_file  = 'edit.php';
     57        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
     58}
     59
     60get_current_screen()->set_screen_reader_content( array(
     61        'heading_pagination' => $tax->labels->items_list_navigation,
     62        'heading_list'       => $tax->labels->items_list,
     63) );
     64
     65require_once( ABSPATH . 'wp-admin/admin-header.php' );
     66include( ABSPATH . 'wp-admin/edit-tag-form.php' );
     67include( ABSPATH . 'wp-admin/admin-footer.php' );
  • src/wp-includes/link-template.php

    diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
    index 4176db1..2351f7c 100644
    function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { 
    926926        }
    927927
    928928        $args = array(
    929                 'action' => 'edit',
    930929                'taxonomy' => $taxonomy,
    931                 'tag_ID' => $term->term_id,
     930                'term_id' => $term->term_id,
    932931        );
    933932
    934933        if ( $object_type ) {
    function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { 
    938937        }
    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 = '';
    944943        }