wp/wp-admin/edit-tag-form.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    42 	 * @param WP_Term $tag Current tag term object.
    42 	 * @param WP_Term $tag Current tag term object.
    43 	 */
    43 	 */
    44 	do_action_deprecated( 'edit_tag_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    44 	do_action_deprecated( 'edit_tag_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' );
    45 }
    45 }
    46 
    46 
    47 /**
    47 $wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_text_field( $_REQUEST['wp_http_referer'] ) : '';
    48  * Use with caution, see https://developer.wordpress.org/reference/functions/wp_reset_vars/
       
    49  */
       
    50 wp_reset_vars( array( 'wp_http_referer' ) );
       
    51 
       
    52 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
    48 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
    53 
    49 
    54 // Also used by Edit Tags.
    50 // Also used by Edit Tags.
    55 require_once ABSPATH . 'wp-admin/includes/edit-tag-messages.php';
    51 require_once ABSPATH . 'wp-admin/includes/edit-tag-messages.php';
    56 
    52 
    77 
    73 
    78 <?php
    74 <?php
    79 $class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success';
    75 $class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success';
    80 
    76 
    81 if ( $message ) {
    77 if ( $message ) {
    82 	?>
    78 	$message = '<p><strong>' . $message . '</strong></p>';
    83 <div id="message" class="notice notice-<?php echo $class; ?>">
    79 	if ( $wp_http_referer ) {
    84 	<p><strong><?php echo $message; ?></strong></p>
    80 		$message .= '<p><a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ) . '">' . esc_html( $tax->labels->back_to_items ) . '</a></p>';
    85 	<?php if ( $wp_http_referer ) { ?>
    81 	}
    86 	<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>">
    82 	wp_admin_notice(
    87 		<?php echo esc_html( $tax->labels->back_to_items ); ?>
    83 		$message,
    88 	</a></p>
    84 		array(
    89 	<?php } ?>
    85 			'type'           => $class,
    90 </div>
    86 			'id'             => 'message',
    91 	<?php
    87 			'paragraph_wrap' => false,
       
    88 		)
       
    89 	);
    92 }
    90 }
    93 ?>
    91 ?>
    94 
    92 
    95 <div id="ajax-response"></div>
    93 <div id="ajax-response"></div>
    96 
    94 
   143 }
   141 }
   144 ?>
   142 ?>
   145 	<table class="form-table" role="presentation">
   143 	<table class="form-table" role="presentation">
   146 		<tr class="form-field form-required term-name-wrap">
   144 		<tr class="form-field form-required term-name-wrap">
   147 			<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
   145 			<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
   148 			<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" />
   146 			<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" aria-describedby="name-description" />
   149 			<p class="description"><?php echo $tax->labels->name_field_description; ?></p></td>
   147 			<p class="description" id="name-description"><?php echo $tax->labels->name_field_description; ?></p></td>
   150 		</tr>
   148 		</tr>
   151 <?php if ( ! global_terms_enabled() ) { ?>
       
   152 		<tr class="form-field term-slug-wrap">
   149 		<tr class="form-field term-slug-wrap">
   153 			<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
   150 			<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
   154 			<?php
   151 			<?php
   155 			/**
   152 			/**
   156 			 * Filters the editable slug for a post or term.
   153 			 * Filters the editable slug for a post or term.
   165 			 *                              upon the context in which it is evaluated.
   162 			 *                              upon the context in which it is evaluated.
   166 			 * @param WP_Term|WP_Post $tag  Term or post object.
   163 			 * @param WP_Term|WP_Post $tag  Term or post object.
   167 			 */
   164 			 */
   168 			$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
   165 			$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
   169 			?>
   166 			?>
   170 			<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
   167 			<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" aria-describedby="slug-description" />
   171 			<p class="description"><?php echo $tax->labels->slug_field_description; ?></p></td>
   168 			<p class="description" id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p></td>
   172 		</tr>
   169 		</tr>
   173 <?php } ?>
       
   174 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
   170 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
   175 		<tr class="form-field term-parent-wrap">
   171 		<tr class="form-field term-parent-wrap">
   176 			<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>
   172 			<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>
   177 			<td>
   173 			<td>
   178 				<?php
   174 				<?php
   184 					'orderby'          => 'name',
   180 					'orderby'          => 'name',
   185 					'selected'         => $tag->parent,
   181 					'selected'         => $tag->parent,
   186 					'exclude_tree'     => $tag->term_id,
   182 					'exclude_tree'     => $tag->term_id,
   187 					'hierarchical'     => true,
   183 					'hierarchical'     => true,
   188 					'show_option_none' => __( 'None' ),
   184 					'show_option_none' => __( 'None' ),
       
   185 					'aria_describedby' => 'parent-description',
   189 				);
   186 				);
   190 
   187 
   191 				/** This filter is documented in wp-admin/edit-tags.php */
   188 				/** This filter is documented in wp-admin/edit-tags.php */
   192 				$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
   189 				$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
   193 				wp_dropdown_categories( $dropdown_args );
   190 				wp_dropdown_categories( $dropdown_args );
   194 				?>
   191 				?>
   195 				<?php if ( 'category' === $taxonomy ) : ?>
   192 				<?php if ( 'category' === $taxonomy ) : ?>
   196 					<p class="description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
   193 					<p class="description" id="parent-description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
   197 				<?php else : ?>
   194 				<?php else : ?>
   198 					<p class="description"><?php echo $tax->labels->parent_field_description; ?></p>
   195 					<p class="description" id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p>
   199 				<?php endif; ?>
   196 				<?php endif; ?>
   200 			</td>
   197 			</td>
   201 		</tr>
   198 		</tr>
   202 <?php endif; // is_taxonomy_hierarchical() ?>
   199 <?php endif; // is_taxonomy_hierarchical() ?>
   203 		<tr class="form-field term-description-wrap">
   200 		<tr class="form-field term-description-wrap">
   204 			<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
   201 			<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
   205 			<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
   202 			<td><textarea name="description" id="description" rows="5" cols="50" class="large-text" aria-describedby="description-description"><?php echo $tag->description; // textarea_escaped ?></textarea>
   206 			<p class="description"><?php echo $tax->labels->desc_field_description; ?></p></td>
   203 			<p class="description" id="description-description"><?php echo $tax->labels->desc_field_description; ?></p></td>
   207 		</tr>
   204 		</tr>
   208 		<?php
   205 		<?php
   209 		// Back compat hooks.
   206 		// Back compat hooks.
   210 		if ( 'category' === $taxonomy ) {
   207 		if ( 'category' === $taxonomy ) {
   211 			/**
   208 			/**