Make WordPress Core

Ticket #34988: 34988.5.patch

File 34988.5.patch, 13.0 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..2579d0e 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 ) { 
    2719         * @since 2.1.0
    2820         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    2921         *
    30          * @param object $tag Current category term object.
     22         * @param object $term Current category term object.
    3123         */
    32         do_action( 'edit_category_form_pre', $tag );
     24        do_action( 'edit_category_form_pre', $term );
    3325} elseif ( 'link_category' == $taxonomy ) {
    3426        /**
    3527         * Fires before the Edit Link Category form.
    if ( 'category' == $taxonomy ) { 
    3729         * @since 2.3.0
    3830         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    3931         *
    40          * @param object $tag Current link category term object.
     32         * @param object $term Current link category term object.
    4133         */
    42         do_action( 'edit_link_category_form_pre', $tag );
     34        do_action( 'edit_link_category_form_pre', $term );
    4335} else {
    4436        /**
    4537         * Fires before the Edit Tag form.
    if ( 'category' == $taxonomy ) { 
    4739         * @since 2.5.0
    4840         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    4941         *
    50          * @param object $tag Current tag term object.
     42         * @param object $term Current tag term object.
    5143         */
    52         do_action( 'edit_tag_form_pre', $tag );
     44        do_action( 'edit_tag_form_pre', $term );
    5345}
    5446
    5547/**
    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' );
    require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); 
    7062 *
    7163 * @since 3.0.0
    7264 *
    73  * @param object $tag      Current taxonomy term object.
     65 * @param object $term     Current taxonomy term object.
    7466 * @param string $taxonomy Current $taxonomy slug.
    7567 */
    76 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
     68do_action( "{$taxonomy}_pre_edit_form", $term, $taxonomy ); ?>
    7769
    7870<div class="wrap">
    7971<h1><?php echo $tax->labels->edit_item; ?></h1>
    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>
    113                         <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
     108                        <td><input name="name" id="name" type="text" value="<?php if ( isset( $term->name ) ) echo esc_attr($term->name); ?>" size="40" aria-required="true" />
    114109                        <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
    115110                </tr>
    116111<?php if ( !global_terms_enabled() ) { ?>
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    124119                         * post URIs and term slugs.
    125120                         *
    126121                         * @since 2.6.0
    127                          * @since 4.4.0 The `$tag` parameter was added.
     122                         * @since 4.4.0 The `$term` parameter was added.
    128123                         *
    129124                         * @param string         $slug The editable slug. Will be either a term slug or post URI depending
    130125                         *                             upon the context in which it is evaluated.
    131                          * @param object|WP_Post $tag  Term or WP_Post object.
     126                         * @param object|WP_Post $term  Term or WP_Post object.
    132127                         */
    133                         $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
     128                        $slug = isset( $term->slug ) ? apply_filters( 'editable_slug', $term->slug, $term ) : '';
    134129                        ?>
    135130                        <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
    136131                        <p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
    137132                </tr>
    138133<?php } ?>
    139 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
     134<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
    140135                <tr class="form-field term-parent-wrap">
    141136                        <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
    142137                        <td>
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    147142                                        'taxonomy'         => $taxonomy,
    148143                                        'name'             => 'parent',
    149144                                        'orderby'          => 'name',
    150                                         'selected'         => $tag->parent,
    151                                         'exclude_tree'     => $tag->term_id,
     145                                        'selected'         => $term->parent,
     146                                        'exclude_tree'     => $term->term_id,
    152147                                        'hierarchical'     => true,
    153148                                        'show_option_none' => __( 'None' ),
    154149                                );
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    164159<?php endif; // is_taxonomy_hierarchical() ?>
    165160                <tr class="form-field term-description-wrap">
    166161                        <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
    167                         <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
     162                        <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $term->description; // textarea_escaped ?></textarea>
    168163                        <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
    169164                </tr>
    170165                <?php
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    176171                         * @since 2.9.0
    177172                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    178173                         *
    179                          * @param object $tag Current category term object.
     174                         * @param object $term Current category term object.
    180175                         */
    181                         do_action( 'edit_category_form_fields', $tag );
     176                        do_action( 'edit_category_form_fields', $term );
    182177                } elseif ( 'link_category' == $taxonomy ) {
    183178                        /**
    184179                         * Fires after the Edit Link Category form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    186181                         * @since 2.9.0
    187182                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    188183                         *
    189                          * @param object $tag Current link category term object.
     184                         * @param object $term Current link category term object.
    190185                         */
    191                         do_action( 'edit_link_category_form_fields', $tag );
     186                        do_action( 'edit_link_category_form_fields', $term );
    192187                } else {
    193188                        /**
    194189                         * Fires after the Edit Tag form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    196191                         * @since 2.9.0
    197192                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    198193                         *
    199                          * @param object $tag Current tag term object.
     194                         * @param object $term Current tag term object.
    200195                         */
    201                         do_action( 'edit_tag_form_fields', $tag );
     196                        do_action( 'edit_tag_form_fields', $term );
    202197                }
    203198                /**
    204199                 * Fires after the Edit Term form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    208203                 *
    209204                 * @since 3.0.0
    210205                 *
    211                  * @param object $tag      Current taxonomy term object.
     206                 * @param object $term     Current taxonomy term object.
    212207                 * @param string $taxonomy Current taxonomy slug.
    213208                 */
    214                 do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
     209                do_action( "{$taxonomy}_edit_form_fields", $term, $taxonomy );
    215210                ?>
    216211        </table>
    217212<?php
    218213// Back compat hooks
    219214if ( 'category' == $taxonomy ) {
    220215        /** This action is documented in wp-admin/edit-tags.php */
    221         do_action( 'edit_category_form', $tag );
     216        do_action( 'edit_category_form', $term );
    222217} elseif ( 'link_category' == $taxonomy ) {
    223218        /** This action is documented in wp-admin/edit-tags.php */
    224         do_action( 'edit_link_category_form', $tag );
     219        do_action( 'edit_link_category_form', $term );
    225220} else {
    226221        /**
    227222         * Fires at the end of the Edit Term form.
    if ( 'category' == $taxonomy ) { 
    229224         * @since 2.5.0
    230225         * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
    231226         *
    232          * @param object $tag Current taxonomy term object.
     227         * @param object $term Current taxonomy term object.
    233228         */
    234         do_action( 'edit_tag_form', $tag );
     229        do_action( 'edit_tag_form', $term );
    235230}
    236231/**
    237232 * Fires at the end of the Edit Term form for all taxonomies.
    if ( 'category' == $taxonomy ) { 
    240235 *
    241236 * @since 3.0.0
    242237 *
    243  * @param object $tag      Current taxonomy term object.
     238 * @param object $term      Current taxonomy term object.
    244239 * @param string $taxonomy Current taxonomy slug.
    245240 */
    246 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
     241do_action( "{$taxonomy}_edit_form", $term, $taxonomy );
    247242
    248243submit_button( __('Update') );
    249244?>
  • src/wp-admin/edit-tags.php

    diff --git src/wp-admin/edit-tags.php src/wp-admin/edit-tags.php
    index 846928c..2a025b6 100644
    case 'edit': 
    156156                break;
    157157        }
    158158
    159         $tag_ID = (int) $_REQUEST['tag_ID'];
     159        $term_id = (int) $_REQUEST['tag_ID'];
    160160
    161         $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
    162         if ( ! $tag )
     161        if ( ! get_term( $tag_ID ) ) {
    163162                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' );
     163        }
    167164
     165        wp_safe_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
    168166        exit;
    169167
    170168case '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..ffce133
    - +  
     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 ( ! isset( $_REQUEST['term_id'] ) ) {
     13        wp_die( __( 'You did not select an item for editing.' ) );
     14}
     15
     16$term_id = absint( $_REQUEST['term_id'] );
     17$term    = get_term( $term_id, $taxnow, OBJECT, 'edit' );
     18
     19if ( ! $term instanceof WP_Term ) {
     20        wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
     21}
     22
     23$tax      = get_taxonomy( $term->taxonomy );
     24$taxonomy = $tax->name;
     25$title    = $tax->labels->edit_item;
     26
     27if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
     28     ! current_user_can( $tax->cap->manage_terms )
     29) {
     30        wp_die(
     31                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     32                '<p>' . __( 'You are not allowed to manage this item.' ) . '</p>',
     33                403
     34        );
     35}
     36
     37$post_type = get_current_screen()->post_type;
     38
     39// Default to the first object_type associated with the taxonomy if no post type was passed.
     40if ( empty( $post_type ) ) {
     41        $post_type = reset( $tax->object_type );
     42}
     43
     44if ( 'post' != $post_type ) {
     45        $parent_file  = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
     46        $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
     47} elseif ( 'link_category' == $taxonomy ) {
     48        $parent_file  = 'link-manager.php';
     49        $submenu_file = 'edit-tags.php?taxonomy=link_category';
     50} else {
     51        $parent_file  = 'edit.php';
     52        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
     53}
     54
     55get_current_screen()->set_screen_reader_content( array(
     56        'heading_pagination' => $tax->labels->items_list_navigation,
     57        'heading_list'       => $tax->labels->items_list,
     58) );
     59
     60require_once( ABSPATH . 'wp-admin/admin-header.php' );
     61include( ABSPATH . 'wp-admin/edit-tag-form.php' );
     62include( 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 8476314..2fdd2af 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        }