Make WordPress Core

Ticket #34988: 34988.3.patch

File 34988.3.patch, 12.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 8b5c61b..556c554 100644
     
    1010if ( !defined('ABSPATH') )
    1111        die('-1');
    1212
    13 if ( empty($tag_ID) ) { ?>
     13if ( empty( $term_id ) ) { ?>
    1414        <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
    1515<?php
    1616        return;
    if ( 'category' == $taxonomy ) { 
    2424         * @since 2.1.0
    2525         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    2626         *
    27          * @param object $tag Current category term object.
     27         * @param object $term Current category term object.
    2828         */
    29         do_action( 'edit_category_form_pre', $tag );
     29        do_action( 'edit_category_form_pre', $term );
    3030} elseif ( 'link_category' == $taxonomy ) {
    3131        /**
    3232         * Fires before the Edit Link Category form.
    if ( 'category' == $taxonomy ) { 
    3434         * @since 2.3.0
    3535         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    3636         *
    37          * @param object $tag Current link category term object.
     37         * @param object $term Current link category term object.
    3838         */
    39         do_action( 'edit_link_category_form_pre', $tag );
     39        do_action( 'edit_link_category_form_pre', $term );
    4040} else {
    4141        /**
    4242         * Fires before the Edit Tag form.
    if ( 'category' == $taxonomy ) { 
    4444         * @since 2.5.0
    4545         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    4646         *
    47          * @param object $tag Current tag term object.
     47         * @param object $term Current tag term object.
    4848         */
    49         do_action( 'edit_tag_form_pre', $tag );
     49        do_action( 'edit_tag_form_pre', $term );
    5050}
    5151
    5252/**
    if ( 'category' == $taxonomy ) { 
    5454 */
    5555wp_reset_vars( array( 'wp_http_referer' ) );
    5656
    57 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
     57$wp_http_referer = remove_query_arg( array( 'action', 'message', 'term_id' ), $wp_http_referer );
    5858
    5959/** Also used by Edit Tags */
    6060require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
    require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); 
    6767 *
    6868 * @since 3.0.0
    6969 *
    70  * @param object $tag      Current taxonomy term object.
     70 * @param object $term     Current taxonomy term object.
    7171 * @param string $taxonomy Current $taxonomy slug.
    7272 */
    73 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
     73do_action( "{$taxonomy}_pre_edit_form", $term, $taxonomy ); ?>
    7474
    7575<div class="wrap">
    7676<h1><?php echo $tax->labels->edit_item; ?></h1>
    do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?> 
    100100 */
    101101do_action( "{$taxonomy}_term_edit_form_tag" );
    102102?>>
    103 <input type="hidden" name="action" value="editedtag" />
    104 <input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_id) ?>" />
    105 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
    106 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
     103<input type="hidden" name="action" value="editedtag"/>
     104<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $term_id ) ?>"/>
     105<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
     106<?php
     107wp_original_referer_field( true, 'previous' );
     108wp_nonce_field( 'update-tag_' . $term_id );
     109?>
    107110        <table class="form-table">
    108111                <tr class="form-field form-required term-name-wrap">
    109112                        <th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
    110                         <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
     113                        <td><input name="name" id="name" type="text" value="<?php if ( isset( $term->name ) ) echo esc_attr($term->name); ?>" size="40" aria-required="true" />
    111114                        <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
    112115                </tr>
    113116<?php if ( !global_terms_enabled() ) { ?>
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    121124                         * post URIs and term slugs.
    122125                         *
    123126                         * @since 2.6.0
    124                          * @since 4.4.0 The `$tag` parameter was added.
     127                         * @since 4.4.0 The `$term` parameter was added.
    125128                         *
    126129                         * @param string         $slug The editable slug. Will be either a term slug or post URI depending
    127130                         *                             upon the context in which it is evaluated.
    128                          * @param object|WP_Post $tag  Term or WP_Post object.
     131                         * @param object|WP_Post $term  Term or WP_Post object.
    129132                         */
    130                         $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
     133                        $slug = isset( $term->slug ) ? apply_filters( 'editable_slug', $term->slug, $term ) : '';
    131134                        ?>
    132135                        <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
    133136                        <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>
    134137                </tr>
    135138<?php } ?>
    136 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
     139<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
    137140                <tr class="form-field term-parent-wrap">
    138141                        <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
    139142                        <td>
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    144147                                        'taxonomy'         => $taxonomy,
    145148                                        'name'             => 'parent',
    146149                                        'orderby'          => 'name',
    147                                         'selected'         => $tag->parent,
    148                                         'exclude_tree'     => $tag->term_id,
     150                                        'selected'         => $term->parent,
     151                                        'exclude_tree'     => $term->term_id,
    149152                                        'hierarchical'     => true,
    150153                                        'show_option_none' => __( 'None' ),
    151154                                );
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    161164<?php endif; // is_taxonomy_hierarchical() ?>
    162165                <tr class="form-field term-description-wrap">
    163166                        <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
    164                         <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
     167                        <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $term->description; // textarea_escaped ?></textarea>
    165168                        <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
    166169                </tr>
    167170                <?php
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    173176                         * @since 2.9.0
    174177                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    175178                         *
    176                          * @param object $tag Current category term object.
     179                         * @param object $term Current category term object.
    177180                         */
    178                         do_action( 'edit_category_form_fields', $tag );
     181                        do_action( 'edit_category_form_fields', $term );
    179182                } elseif ( 'link_category' == $taxonomy ) {
    180183                        /**
    181184                         * Fires after the Edit Link Category form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    183186                         * @since 2.9.0
    184187                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    185188                         *
    186                          * @param object $tag Current link category term object.
     189                         * @param object $term Current link category term object.
    187190                         */
    188                         do_action( 'edit_link_category_form_fields', $tag );
     191                        do_action( 'edit_link_category_form_fields', $term );
    189192                } else {
    190193                        /**
    191194                         * Fires after the Edit Tag form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    193196                         * @since 2.9.0
    194197                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    195198                         *
    196                          * @param object $tag Current tag term object.
     199                         * @param object $term Current tag term object.
    197200                         */
    198                         do_action( 'edit_tag_form_fields', $tag );
     201                        do_action( 'edit_tag_form_fields', $term );
    199202                }
    200203                /**
    201204                 * Fires after the Edit Term form fields are displayed.
    do_action( "{$taxonomy}_term_edit_form_tag" ); 
    205208                 *
    206209                 * @since 3.0.0
    207210                 *
    208                  * @param object $tag      Current taxonomy term object.
     211                 * @param object $term     Current taxonomy term object.
    209212                 * @param string $taxonomy Current taxonomy slug.
    210213                 */
    211                 do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
     214                do_action( "{$taxonomy}_edit_form_fields", $term, $taxonomy );
    212215                ?>
    213216        </table>
    214217<?php
    215218// Back compat hooks
    216219if ( 'category' == $taxonomy ) {
    217220        /** This action is documented in wp-admin/edit-tags.php */
    218         do_action( 'edit_category_form', $tag );
     221        do_action( 'edit_category_form', $term );
    219222} elseif ( 'link_category' == $taxonomy ) {
    220223        /** This action is documented in wp-admin/edit-tags.php */
    221         do_action( 'edit_link_category_form', $tag );
     224        do_action( 'edit_link_category_form', $term );
    222225} else {
    223226        /**
    224227         * Fires at the end of the Edit Term form.
    if ( 'category' == $taxonomy ) { 
    226229         * @since 2.5.0
    227230         * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
    228231         *
    229          * @param object $tag Current taxonomy term object.
     232         * @param object $term Current taxonomy term object.
    230233         */
    231         do_action( 'edit_tag_form', $tag );
     234        do_action( 'edit_tag_form', $term );
    232235}
    233236/**
    234237 * Fires at the end of the Edit Term form for all taxonomies.
    if ( 'category' == $taxonomy ) { 
    237240 *
    238241 * @since 3.0.0
    239242 *
    240  * @param object $tag      Current taxonomy term object.
     243 * @param object $term      Current taxonomy term object.
    241244 * @param string $taxonomy Current taxonomy slug.
    242245 */
    243 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
     246do_action( "{$taxonomy}_edit_form", $term, $taxonomy );
    244247
    245248submit_button( __('Update') );
    246249?>
  • src/wp-admin/edit-tags.php

    diff --git src/wp-admin/edit-tags.php src/wp-admin/edit-tags.php
    index 6ff9e37..b73c16d 100644
    case 'bulk-delete': 
    152152case 'edit':
    153153        $title = $tax->labels->edit_item;
    154154
    155         $tag_ID = (int) $_REQUEST['tag_ID'];
     155        $term_id = (int) $_REQUEST['tag_ID'];
    156156
    157         $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
    158         if ( ! $tag )
     157        if ( ! get_term( $tag_ID ) ) {
    159158                wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
    160         require_once( ABSPATH . 'wp-admin/admin-header.php' );
    161         include( ABSPATH . 'wp-admin/edit-tag-form.php' );
    162         include( ABSPATH . 'wp-admin/admin-footer.php' );
     159        }
    163160
     161        wp_safe_redirect( get_edit_term_link( $term_id, $taxonomy, $post_type ) );
    164162        exit;
    165163
    166164case '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..8579cdd
    - +  
     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 ( ! $taxnow ) {
     13        wp_die( __( 'Invalid taxonomy' ) );
     14}
     15
     16$tax = get_taxonomy( $taxnow );
     17
     18if ( ! $tax ) {
     19        wp_die( __( 'Invalid taxonomy' ) );
     20}
     21
     22$taxonomy = $tax->name;
     23
     24if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ) {
     25        wp_die( __( 'You are not allowed to manage this item.' ) );
     26}
     27
     28if ( ! current_user_can( $tax->cap->manage_terms ) ) {
     29        wp_die(
     30                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     31                '<p>' . __( 'You are not allowed to manage this item.' ) . '</p>',
     32                403
     33        );
     34}
     35
     36$post_type = get_current_screen()->post_type;
     37
     38if ( 'post' != $post_type ) {
     39        $parent_file  = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
     40        $submenu_file = "edit-tags.php?taxonomy=$taxonomy->name&amp;post_type=$post_type";
     41} elseif ( 'link_category' == $taxonomy ) {
     42        $parent_file  = 'link-manager.php';
     43        $submenu_file = 'edit-tags.php?taxonomy=link_category';
     44} else {
     45        $parent_file  = 'edit.php';
     46        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
     47}
     48
     49get_current_screen()->set_screen_reader_content( array(
     50        'heading_pagination' => $tax->labels->items_list_navigation,
     51        'heading_list'       => $tax->labels->items_list,
     52) );
     53
     54$term_id = (int) $_REQUEST['term_id'];
     55$term    = get_term( $term_id, $taxonomy, OBJECT, 'edit' );
     56
     57if ( ! $term ) {
     58        wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
     59}
     60
     61require_once( ABSPATH . 'wp-admin/admin-header.php' );
     62include( ABSPATH . 'wp-admin/edit-tag-form.php' );
     63include( 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 5aabffa..4a689f4 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        }