Ticket #34988: 34988.5.patch
File 34988.5.patch, 13.0 KB (added by , 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
7 7 */ 8 8 9 9 // 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; 10 if ( ! defined( 'ABSPATH' ) ) { 11 die( '-1' ); 20 12 } 21 13 22 14 // Back compat hooks … … if ( 'category' == $taxonomy ) { 27 19 * @since 2.1.0 28 20 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 29 21 * 30 * @param object $t agCurrent category term object.22 * @param object $term Current category term object. 31 23 */ 32 do_action( 'edit_category_form_pre', $t ag);24 do_action( 'edit_category_form_pre', $term ); 33 25 } elseif ( 'link_category' == $taxonomy ) { 34 26 /** 35 27 * Fires before the Edit Link Category form. … … if ( 'category' == $taxonomy ) { 37 29 * @since 2.3.0 38 30 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 39 31 * 40 * @param object $t agCurrent link category term object.32 * @param object $term Current link category term object. 41 33 */ 42 do_action( 'edit_link_category_form_pre', $t ag);34 do_action( 'edit_link_category_form_pre', $term ); 43 35 } else { 44 36 /** 45 37 * Fires before the Edit Tag form. … … if ( 'category' == $taxonomy ) { 47 39 * @since 2.5.0 48 40 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 49 41 * 50 * @param object $t agCurrent tag term object.42 * @param object $term Current tag term object. 51 43 */ 52 do_action( 'edit_tag_form_pre', $t ag);44 do_action( 'edit_tag_form_pre', $term ); 53 45 } 54 46 55 47 /** … … if ( 'category' == $taxonomy ) { 57 49 */ 58 50 wp_reset_vars( array( 'wp_http_referer' ) ); 59 51 60 $wp_http_referer = remove_query_arg( array( 'action', 'message', 't ag_ID' ), $wp_http_referer );52 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'term_id' ), $wp_http_referer ); 61 53 62 54 /** Also used by Edit Tags */ 63 55 require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); … … require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); 70 62 * 71 63 * @since 3.0.0 72 64 * 73 * @param object $t agCurrent taxonomy term object.65 * @param object $term Current taxonomy term object. 74 66 * @param string $taxonomy Current $taxonomy slug. 75 67 */ 76 do_action( "{$taxonomy}_pre_edit_form", $t ag, $taxonomy ); ?>68 do_action( "{$taxonomy}_pre_edit_form", $term, $taxonomy ); ?> 77 69 78 70 <div class="wrap"> 79 71 <h1><?php echo $tax->labels->edit_item; ?></h1> … … do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?> 103 95 */ 104 96 do_action( "{$taxonomy}_term_edit_form_tag" ); 105 97 ?>> 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 102 wp_original_referer_field( true, 'previous' ); 103 wp_nonce_field( 'update-tag_' . $term_id ); 104 ?> 110 105 <table class="form-table"> 111 106 <tr class="form-field form-required term-name-wrap"> 112 107 <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( $t ag->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" /> 114 109 <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td> 115 110 </tr> 116 111 <?php if ( !global_terms_enabled() ) { ?> … … do_action( "{$taxonomy}_term_edit_form_tag" ); 124 119 * post URIs and term slugs. 125 120 * 126 121 * @since 2.6.0 127 * @since 4.4.0 The `$t ag` parameter was added.122 * @since 4.4.0 The `$term` parameter was added. 128 123 * 129 124 * @param string $slug The editable slug. Will be either a term slug or post URI depending 130 125 * upon the context in which it is evaluated. 131 * @param object|WP_Post $t agTerm or WP_Post object.126 * @param object|WP_Post $term Term or WP_Post object. 132 127 */ 133 $slug = isset( $t ag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag) : '';128 $slug = isset( $term->slug ) ? apply_filters( 'editable_slug', $term->slug, $term ) : ''; 134 129 ?> 135 130 <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" /> 136 131 <p class="description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td> 137 132 </tr> 138 133 <?php } ?> 139 <?php if ( is_taxonomy_hierarchical( $taxonomy) ) : ?>134 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?> 140 135 <tr class="form-field term-parent-wrap"> 141 136 <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th> 142 137 <td> … … do_action( "{$taxonomy}_term_edit_form_tag" ); 147 142 'taxonomy' => $taxonomy, 148 143 'name' => 'parent', 149 144 'orderby' => 'name', 150 'selected' => $t ag->parent,151 'exclude_tree' => $t ag->term_id,145 'selected' => $term->parent, 146 'exclude_tree' => $term->term_id, 152 147 'hierarchical' => true, 153 148 'show_option_none' => __( 'None' ), 154 149 ); … … do_action( "{$taxonomy}_term_edit_form_tag" ); 164 159 <?php endif; // is_taxonomy_hierarchical() ?> 165 160 <tr class="form-field term-description-wrap"> 166 161 <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 $t ag->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> 168 163 <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td> 169 164 </tr> 170 165 <?php … … do_action( "{$taxonomy}_term_edit_form_tag" ); 176 171 * @since 2.9.0 177 172 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 178 173 * 179 * @param object $t agCurrent category term object.174 * @param object $term Current category term object. 180 175 */ 181 do_action( 'edit_category_form_fields', $t ag);176 do_action( 'edit_category_form_fields', $term ); 182 177 } elseif ( 'link_category' == $taxonomy ) { 183 178 /** 184 179 * Fires after the Edit Link Category form fields are displayed. … … do_action( "{$taxonomy}_term_edit_form_tag" ); 186 181 * @since 2.9.0 187 182 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 188 183 * 189 * @param object $t agCurrent link category term object.184 * @param object $term Current link category term object. 190 185 */ 191 do_action( 'edit_link_category_form_fields', $t ag);186 do_action( 'edit_link_category_form_fields', $term ); 192 187 } else { 193 188 /** 194 189 * Fires after the Edit Tag form fields are displayed. … … do_action( "{$taxonomy}_term_edit_form_tag" ); 196 191 * @since 2.9.0 197 192 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 198 193 * 199 * @param object $t agCurrent tag term object.194 * @param object $term Current tag term object. 200 195 */ 201 do_action( 'edit_tag_form_fields', $t ag);196 do_action( 'edit_tag_form_fields', $term ); 202 197 } 203 198 /** 204 199 * Fires after the Edit Term form fields are displayed. … … do_action( "{$taxonomy}_term_edit_form_tag" ); 208 203 * 209 204 * @since 3.0.0 210 205 * 211 * @param object $t agCurrent taxonomy term object.206 * @param object $term Current taxonomy term object. 212 207 * @param string $taxonomy Current taxonomy slug. 213 208 */ 214 do_action( "{$taxonomy}_edit_form_fields", $t ag, $taxonomy );209 do_action( "{$taxonomy}_edit_form_fields", $term, $taxonomy ); 215 210 ?> 216 211 </table> 217 212 <?php 218 213 // Back compat hooks 219 214 if ( 'category' == $taxonomy ) { 220 215 /** This action is documented in wp-admin/edit-tags.php */ 221 do_action( 'edit_category_form', $t ag);216 do_action( 'edit_category_form', $term ); 222 217 } elseif ( 'link_category' == $taxonomy ) { 223 218 /** This action is documented in wp-admin/edit-tags.php */ 224 do_action( 'edit_link_category_form', $t ag);219 do_action( 'edit_link_category_form', $term ); 225 220 } else { 226 221 /** 227 222 * Fires at the end of the Edit Term form. … … if ( 'category' == $taxonomy ) { 229 224 * @since 2.5.0 230 225 * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead. 231 226 * 232 * @param object $t agCurrent taxonomy term object.227 * @param object $term Current taxonomy term object. 233 228 */ 234 do_action( 'edit_tag_form', $t ag);229 do_action( 'edit_tag_form', $term ); 235 230 } 236 231 /** 237 232 * Fires at the end of the Edit Term form for all taxonomies. … … if ( 'category' == $taxonomy ) { 240 235 * 241 236 * @since 3.0.0 242 237 * 243 * @param object $t agCurrent taxonomy term object.238 * @param object $term Current taxonomy term object. 244 239 * @param string $taxonomy Current taxonomy slug. 245 240 */ 246 do_action( "{$taxonomy}_edit_form", $t ag, $taxonomy );241 do_action( "{$taxonomy}_edit_form", $term, $taxonomy ); 247 242 248 243 submit_button( __('Update') ); 249 244 ?> -
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': 156 156 break; 157 157 } 158 158 159 $t ag_ID= (int) $_REQUEST['tag_ID'];159 $term_id = (int) $_REQUEST['tag_ID']; 160 160 161 $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' ); 162 if ( ! $tag ) 161 if ( ! get_term( $tag_ID ) ) { 163 162 wp_die( __( 'You attempted to edit an item that doesn’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 } 167 164 165 wp_safe_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) ); 168 166 exit; 169 167 170 168 case '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 */ 10 require_once( dirname( __FILE__ ) . '/admin.php' ); 11 12 if ( ! 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 19 if ( ! $term instanceof WP_Term ) { 20 wp_die( __( 'You attempted to edit an item that doesn’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 27 if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) || 28 ! current_user_can( $tax->cap->manage_terms ) 29 ) { 30 wp_die( 31 '<h1>' . __( 'Cheatin’ 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. 40 if ( empty( $post_type ) ) { 41 $post_type = reset( $tax->object_type ); 42 } 43 44 if ( '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&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 55 get_current_screen()->set_screen_reader_content( array( 56 'heading_pagination' => $tax->labels->items_list_navigation, 57 'heading_list' => $tax->labels->items_list, 58 ) ); 59 60 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 61 include( ABSPATH . 'wp-admin/edit-tag-form.php' ); 62 include( 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 = '' ) { 926 926 } 927 927 928 928 $args = array( 929 'action' => 'edit',930 929 'taxonomy' => $taxonomy, 931 't ag_ID'=> $term->term_id,930 'term_id' => $term->term_id, 932 931 ); 933 932 934 933 if ( $object_type ) { … … function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { 938 937 } 939 938 940 939 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' ) ); 942 941 } else { 943 942 $location = ''; 944 943 }