Make WordPress Core

Ticket #34988: 34988.4.patch

File 34988.4.patch, 12.1 KB (added by seanchayes, 9 years ago)
  • src/wp-admin/edit-tag-form.php

     
    1010if ( !defined('ABSPATH') )
    1111        die('-1');
    1212
    13 if ( empty($tag_ID) ) { ?>
     13if ( empty( $term_id ) ) { ?>
    1414<div class="wrap">
    1515        <h1><?php echo $tax->labels->edit_item; ?></h1>
    1616        <div id="message" class="notice notice-warning"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
     
    2727         * @since 2.1.0
    2828         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    2929         *
    30          * @param object $tag Current category term object.
     30         * @param object $term Current category term object.
    3131         */
    32         do_action( 'edit_category_form_pre', $tag );
     32        do_action( 'edit_category_form_pre', $term );
    3333} elseif ( 'link_category' == $taxonomy ) {
    3434        /**
    3535         * Fires before the Edit Link Category form.
     
    3737         * @since 2.3.0
    3838         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    3939         *
    40          * @param object $tag Current link category term object.
     40         * @param object $term Current link category term object.
    4141         */
    42         do_action( 'edit_link_category_form_pre', $tag );
     42        do_action( 'edit_link_category_form_pre', $term );
    4343} else {
    4444        /**
    4545         * Fires before the Edit Tag form.
     
    4747         * @since 2.5.0
    4848         * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    4949         *
    50          * @param object $tag Current tag term object.
     50         * @param object $term Current tag term object.
    5151         */
    52         do_action( 'edit_tag_form_pre', $tag );
     52        do_action( 'edit_tag_form_pre', $term );
    5353}
    5454
    5555/**
     
    5757 */
    5858wp_reset_vars( array( 'wp_http_referer' ) );
    5959
    60 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
     60$wp_http_referer = remove_query_arg( array( 'action', 'message', 'term_id' ), $wp_http_referer );
    6161
    6262/** Also used by Edit Tags */
    6363require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
     
    7070 *
    7171 * @since 3.0.0
    7272 *
    73  * @param object $tag      Current taxonomy term object.
     73 * @param object $term     Current taxonomy term object.
    7474 * @param string $taxonomy Current $taxonomy slug.
    7575 */
    76 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
     76do_action( "{$taxonomy}_pre_edit_form", $term, $taxonomy ); ?>
    7777
    7878<div class="wrap">
    7979<h1><?php echo $tax->labels->edit_item; ?></h1>
     
    103103 */
    104104do_action( "{$taxonomy}_term_edit_form_tag" );
    105105?>>
    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); ?>
     106<input type="hidden" name="action" value="editedtag"/>
     107<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $term_id ) ?>"/>
     108<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
     109<?php
     110wp_original_referer_field( true, 'previous' );
     111wp_nonce_field( 'update-tag_' . $term_id );
     112?>
    110113        <table class="form-table">
    111114                <tr class="form-field form-required term-name-wrap">
    112115                        <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" />
     116                        <td><input name="name" id="name" type="text" value="<?php if ( isset( $term->name ) ) echo esc_attr($term->name); ?>" size="40" aria-required="true" />
    114117                        <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
    115118                </tr>
    116119<?php if ( !global_terms_enabled() ) { ?>
     
    124127                         * post URIs and term slugs.
    125128                         *
    126129                         * @since 2.6.0
    127                          * @since 4.4.0 The `$tag` parameter was added.
     130                         * @since 4.4.0 The `$term` parameter was added.
    128131                         *
    129132                         * @param string         $slug The editable slug. Will be either a term slug or post URI depending
    130133                         *                             upon the context in which it is evaluated.
    131                          * @param object|WP_Post $tag  Term or WP_Post object.
     134                         * @param object|WP_Post $term  Term or WP_Post object.
    132135                         */
    133                         $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
     136                        $slug = isset( $term->slug ) ? apply_filters( 'editable_slug', $term->slug, $term ) : '';
    134137                        ?>
    135138                        <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
    136139                        <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>
    137140                </tr>
    138141<?php } ?>
    139 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
     142<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
    140143                <tr class="form-field term-parent-wrap">
    141144                        <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
    142145                        <td>
     
    147150                                        'taxonomy'         => $taxonomy,
    148151                                        'name'             => 'parent',
    149152                                        'orderby'          => 'name',
    150                                         'selected'         => $tag->parent,
    151                                         'exclude_tree'     => $tag->term_id,
     153                                        'selected'         => $term->parent,
     154                                        'exclude_tree'     => $term->term_id,
    152155                                        'hierarchical'     => true,
    153156                                        'show_option_none' => __( 'None' ),
    154157                                );
     
    164167<?php endif; // is_taxonomy_hierarchical() ?>
    165168                <tr class="form-field term-description-wrap">
    166169                        <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>
     170                        <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $term->description; // textarea_escaped ?></textarea>
    168171                        <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
    169172                </tr>
    170173                <?php
     
    176179                         * @since 2.9.0
    177180                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    178181                         *
    179                          * @param object $tag Current category term object.
     182                         * @param object $term Current category term object.
    180183                         */
    181                         do_action( 'edit_category_form_fields', $tag );
     184                        do_action( 'edit_category_form_fields', $term );
    182185                } elseif ( 'link_category' == $taxonomy ) {
    183186                        /**
    184187                         * Fires after the Edit Link Category form fields are displayed.
     
    186189                         * @since 2.9.0
    187190                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    188191                         *
    189                          * @param object $tag Current link category term object.
     192                         * @param object $term Current link category term object.
    190193                         */
    191                         do_action( 'edit_link_category_form_fields', $tag );
     194                        do_action( 'edit_link_category_form_fields', $term );
    192195                } else {
    193196                        /**
    194197                         * Fires after the Edit Tag form fields are displayed.
     
    196199                         * @since 2.9.0
    197200                         * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
    198201                         *
    199                          * @param object $tag Current tag term object.
     202                         * @param object $term Current tag term object.
    200203                         */
    201                         do_action( 'edit_tag_form_fields', $tag );
     204                        do_action( 'edit_tag_form_fields', $term );
    202205                }
    203206                /**
    204207                 * Fires after the Edit Term form fields are displayed.
     
    208211                 *
    209212                 * @since 3.0.0
    210213                 *
    211                  * @param object $tag      Current taxonomy term object.
     214                 * @param object $term     Current taxonomy term object.
    212215                 * @param string $taxonomy Current taxonomy slug.
    213216                 */
    214                 do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
     217                do_action( "{$taxonomy}_edit_form_fields", $term, $taxonomy );
    215218                ?>
    216219        </table>
    217220<?php
    218221// Back compat hooks
    219222if ( 'category' == $taxonomy ) {
    220223        /** This action is documented in wp-admin/edit-tags.php */
    221         do_action( 'edit_category_form', $tag );
     224        do_action( 'edit_category_form', $term );
    222225} elseif ( 'link_category' == $taxonomy ) {
    223226        /** This action is documented in wp-admin/edit-tags.php */
    224         do_action( 'edit_link_category_form', $tag );
     227        do_action( 'edit_link_category_form', $term );
    225228} else {
    226229        /**
    227230         * Fires at the end of the Edit Term form.
     
    229232         * @since 2.5.0
    230233         * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
    231234         *
    232          * @param object $tag Current taxonomy term object.
     235         * @param object $term Current taxonomy term object.
    233236         */
    234         do_action( 'edit_tag_form', $tag );
     237        do_action( 'edit_tag_form', $term );
    235238}
    236239/**
    237240 * Fires at the end of the Edit Term form for all taxonomies.
     
    240243 *
    241244 * @since 3.0.0
    242245 *
    243  * @param object $tag      Current taxonomy term object.
     246 * @param object $term      Current taxonomy term object.
    244247 * @param string $taxonomy Current taxonomy slug.
    245248 */
    246 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
     249do_action( "{$taxonomy}_edit_form", $term, $taxonomy );
    247250
    248251submit_button( __('Update') );
    249252?>
  • src/wp-admin/edit-tags.php

     
    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( get_edit_term_link( $term_id, $taxonomy, $post_type ) );
    168166        exit;
    169167
    170168case 'editedtag':
  • src/wp-admin/term.php

     
     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 term' ) );
     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&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

     
    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 ) {
     
    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        }