wp/wp-admin/edit-tag-form.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    12 }
    12 }
    13 
    13 
    14 // Back compat hooks
    14 // Back compat hooks
    15 if ( 'category' == $taxonomy ) {
    15 if ( 'category' == $taxonomy ) {
    16 	/**
    16 	/**
    17  	 * Fires before the Edit Category form.
    17 	 * Fires before the Edit Category form.
    18 	 *
    18 	 *
    19 	 * @since 2.1.0
    19 	 * @since 2.1.0
    20 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    20 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    21 	 *
    21 	 *
    22 	 * @param object $tag Current category term object.
    22 	 * @param WP_Term $tag Current category term object.
    23 	 */
    23 	 */
    24 	do_action( 'edit_category_form_pre', $tag );
    24 	do_action( 'edit_category_form_pre', $tag );
    25 } elseif ( 'link_category' == $taxonomy ) {
    25 } elseif ( 'link_category' == $taxonomy ) {
    26 	/**
    26 	/**
    27 	 * Fires before the Edit Link Category form.
    27 	 * Fires before the Edit Link Category form.
    28 	 *
    28 	 *
    29 	 * @since 2.3.0
    29 	 * @since 2.3.0
    30 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    30 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    31 	 *
    31 	 *
    32 	 * @param object $tag Current link category term object.
    32 	 * @param WP_Term $tag Current link category term object.
    33 	 */
    33 	 */
    34 	do_action( 'edit_link_category_form_pre', $tag );
    34 	do_action( 'edit_link_category_form_pre', $tag );
    35 } else {
    35 } else {
    36 	/**
    36 	/**
    37 	 * Fires before the Edit Tag form.
    37 	 * Fires before the Edit Tag form.
    38 	 *
    38 	 *
    39 	 * @since 2.5.0
    39 	 * @since 2.5.0
    40 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    40 	 * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
    41 	 *
    41 	 *
    42 	 * @param object $tag Current tag term object.
    42 	 * @param WP_Term $tag Current tag term object.
    43 	 */
    43 	 */
    44 	do_action( 'edit_tag_form_pre', $tag );
    44 	do_action( 'edit_tag_form_pre', $tag );
    45 }
    45 }
    46 
    46 
    47 /**
    47 /**
    60  * The dynamic portion of the hook name, `$taxonomy`, refers to
    60  * The dynamic portion of the hook name, `$taxonomy`, refers to
    61  * the taxonomy slug.
    61  * the taxonomy slug.
    62  *
    62  *
    63  * @since 3.0.0
    63  * @since 3.0.0
    64  *
    64  *
    65  * @param object $tag      Current taxonomy term object.
    65  * @param WP_Term $tag      Current taxonomy term object.
    66  * @param string $taxonomy Current $taxonomy slug.
    66  * @param string  $taxonomy Current $taxonomy slug.
    67  */
    67  */
    68 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
    68 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
    69 
    69 
    70 <div class="wrap">
    70 <div class="wrap">
    71 <h1><?php echo $tax->labels->edit_item; ?></h1>
    71 <h1><?php echo $tax->labels->edit_item; ?></h1>
    72 
    72 
    73 <?php if ( $message ) : ?>
    73 <?php
    74 <div id="message" class="updated">
    74 $class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success';
       
    75 
       
    76 if ( $message ) {
       
    77 	?>
       
    78 <div id="message" class="notice notice-<?php echo $class; ?>">
    75 	<p><strong><?php echo $message; ?></strong></p>
    79 	<p><strong><?php echo $message; ?></strong></p>
    76 	<?php if ( $wp_http_referer ) { ?>
    80 	<?php if ( $wp_http_referer ) { ?>
    77 	<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>"><?php
    81 	<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>">
    78 		echo esc_html( $tax->labels->back_to_items );
    82 		<?php echo esc_html( $tax->labels->back_to_items ); ?>
    79 	?></a></p>
    83 	</a></p>
    80 	<?php } ?>
    84 	<?php } ?>
    81 </div>
    85 </div>
    82 <?php endif; ?>
    86 	<?php
       
    87 }
       
    88 ?>
    83 
    89 
    84 <div id="ajax-response"></div>
    90 <div id="ajax-response"></div>
    85 
    91 
    86 <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"<?php
    92 <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
       
    93 <?php
    87 /**
    94 /**
    88  * Fires inside the Edit Term form tag.
    95  * Fires inside the Edit Term form tag.
    89  *
    96  *
    90  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    97  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    91  *
    98  *
    92  * @since 3.7.0
    99  * @since 3.7.0
    93  */
   100  */
    94 do_action( "{$taxonomy}_term_edit_form_tag" );
   101 do_action( "{$taxonomy}_term_edit_form_tag" );
    95 ?>>
   102 ?>
       
   103 >
    96 <input type="hidden" name="action" value="editedtag"/>
   104 <input type="hidden" name="action" value="editedtag"/>
    97 <input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ) ?>"/>
   105 <input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ); ?>"/>
    98 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
   106 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>"/>
    99 <?php
   107 <?php
   100 wp_original_referer_field( true, 'previous' );
   108 wp_original_referer_field( true, 'previous' );
   101 wp_nonce_field( 'update-tag_' . $tag_ID );
   109 wp_nonce_field( 'update-tag_' . $tag_ID );
   102 
   110 
   103 /**
   111 /**
   107  *
   115  *
   108  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   116  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   109  *
   117  *
   110  * @since 4.5.0
   118  * @since 4.5.0
   111  *
   119  *
   112  * @param object $tag      Current taxonomy term object.
   120  * @param WP_Term $tag      Current taxonomy term object.
   113  * @param string $taxonomy Current $taxonomy slug.
   121  * @param string  $taxonomy Current $taxonomy slug.
   114  */
   122  */
   115 do_action( "{$taxonomy}_term_edit_form_top", $tag, $taxonomy );
   123 do_action( "{$taxonomy}_term_edit_form_top", $tag, $taxonomy );
   116 ?>
   124 
   117 	<table class="form-table">
   125 $tag_name_value = '';
       
   126 if ( isset( $tag->name ) ) {
       
   127 	$tag_name_value = esc_attr( $tag->name );
       
   128 }
       
   129 ?>
       
   130 	<table class="form-table" role="presentation">
   118 		<tr class="form-field form-required term-name-wrap">
   131 		<tr class="form-field form-required term-name-wrap">
   119 			<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
   132 			<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
   120 			<td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
   133 			<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" />
   121 			<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
   134 			<p class="description"><?php _e( 'The name is how it appears on your site.' ); ?></p></td>
   122 		</tr>
   135 		</tr>
   123 <?php if ( !global_terms_enabled() ) { ?>
   136 <?php if ( ! global_terms_enabled() ) { ?>
   124 		<tr class="form-field term-slug-wrap">
   137 		<tr class="form-field term-slug-wrap">
   125 			<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
   138 			<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
   126 			<?php
   139 			<?php
   127 			/**
   140 			/**
   128 			 * Filters the editable slug.
   141 			 * Filters the editable slug.
   131 			 * post URIs and term slugs.
   144 			 * post URIs and term slugs.
   132 			 *
   145 			 *
   133 			 * @since 2.6.0
   146 			 * @since 2.6.0
   134 			 * @since 4.4.0 The `$tag` parameter was added.
   147 			 * @since 4.4.0 The `$tag` parameter was added.
   135 			 *
   148 			 *
   136 			 * @param string         $slug The editable slug. Will be either a term slug or post URI depending
   149 			 * @param string          $slug The editable slug. Will be either a term slug or post URI depending
   137 			 *                             upon the context in which it is evaluated.
   150 			 *                              upon the context in which it is evaluated.
   138 			 * @param object|WP_Post $tag  Term or WP_Post object.
   151 			 * @param WP_Term|WP_Post $tag  Term or WP_Post object.
   139 			 */
   152 			 */
   140 			$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
   153 			$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
   141 			?>
   154 			?>
   142 			<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
   155 			<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
   143 			<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>
   156 			<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>
   144 		</tr>
   157 		</tr>
   145 <?php } ?>
   158 <?php } ?>
   146 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
   159 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
   147 		<tr class="form-field term-parent-wrap">
   160 		<tr class="form-field term-parent-wrap">
   148 			<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>
   161 			<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>
   149 			<td>
   162 			<td>
   150 				<?php
   163 				<?php
   151 				$dropdown_args = array(
   164 				$dropdown_args = array(
   160 					'show_option_none' => __( 'None' ),
   173 					'show_option_none' => __( 'None' ),
   161 				);
   174 				);
   162 
   175 
   163 				/** This filter is documented in wp-admin/edit-tags.php */
   176 				/** This filter is documented in wp-admin/edit-tags.php */
   164 				$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
   177 				$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
   165 				wp_dropdown_categories( $dropdown_args ); ?>
   178 				wp_dropdown_categories( $dropdown_args );
       
   179 				?>
   166 				<?php if ( 'category' == $taxonomy ) : ?>
   180 				<?php if ( 'category' == $taxonomy ) : ?>
   167 					<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>
   181 					<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>
   168 				<?php else : ?>
   182 				<?php else : ?>
   169 					<p class="description"><?php _e( 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.' ); ?></p>
   183 					<p class="description"><?php _e( 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.' ); ?></p>
   170 				<?php endif; ?>
   184 				<?php endif; ?>
   172 		</tr>
   186 		</tr>
   173 <?php endif; // is_taxonomy_hierarchical() ?>
   187 <?php endif; // is_taxonomy_hierarchical() ?>
   174 		<tr class="form-field term-description-wrap">
   188 		<tr class="form-field term-description-wrap">
   175 			<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
   189 			<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
   176 			<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
   190 			<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
   177 			<p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
   191 			<p class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p></td>
   178 		</tr>
   192 		</tr>
   179 		<?php
   193 		<?php
   180 		// Back compat hooks
   194 		// Back compat hooks
   181 		if ( 'category' == $taxonomy ) {
   195 		if ( 'category' == $taxonomy ) {
   182 			/**
   196 			/**
   183 			 * Fires after the Edit Category form fields are displayed.
   197 			 * Fires after the Edit Category form fields are displayed.
   184 			 *
   198 			 *
   185 			 * @since 2.9.0
   199 			 * @since 2.9.0
   186 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   200 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   187 			 *
   201 			 *
   188 			 * @param object $tag Current category term object.
   202 			 * @param WP_Term $tag Current category term object.
   189 			 */
   203 			 */
   190 			do_action( 'edit_category_form_fields', $tag );
   204 			do_action( 'edit_category_form_fields', $tag );
   191 		} elseif ( 'link_category' == $taxonomy ) {
   205 		} elseif ( 'link_category' == $taxonomy ) {
   192 			/**
   206 			/**
   193 			 * Fires after the Edit Link Category form fields are displayed.
   207 			 * Fires after the Edit Link Category form fields are displayed.
   194 			 *
   208 			 *
   195 			 * @since 2.9.0
   209 			 * @since 2.9.0
   196 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   210 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   197 			 *
   211 			 *
   198 			 * @param object $tag Current link category term object.
   212 			 * @param WP_Term $tag Current link category term object.
   199 			 */
   213 			 */
   200 			do_action( 'edit_link_category_form_fields', $tag );
   214 			do_action( 'edit_link_category_form_fields', $tag );
   201 		} else {
   215 		} else {
   202 			/**
   216 			/**
   203 			 * Fires after the Edit Tag form fields are displayed.
   217 			 * Fires after the Edit Tag form fields are displayed.
   204 			 *
   218 			 *
   205 			 * @since 2.9.0
   219 			 * @since 2.9.0
   206 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   220 			 * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
   207 			 *
   221 			 *
   208 			 * @param object $tag Current tag term object.
   222 			 * @param WP_Term $tag Current tag term object.
   209 			 */
   223 			 */
   210 			do_action( 'edit_tag_form_fields', $tag );
   224 			do_action( 'edit_tag_form_fields', $tag );
   211 		}
   225 		}
   212 		/**
   226 		/**
   213 		 * Fires after the Edit Term form fields are displayed.
   227 		 * Fires after the Edit Term form fields are displayed.
   215 		 * The dynamic portion of the hook name, `$taxonomy`, refers to
   229 		 * The dynamic portion of the hook name, `$taxonomy`, refers to
   216 		 * the taxonomy slug.
   230 		 * the taxonomy slug.
   217 		 *
   231 		 *
   218 		 * @since 3.0.0
   232 		 * @since 3.0.0
   219 		 *
   233 		 *
   220 		 * @param object $tag      Current taxonomy term object.
   234 		 * @param WP_Term $tag      Current taxonomy term object.
   221 		 * @param string $taxonomy Current taxonomy slug.
   235 		 * @param string  $taxonomy Current taxonomy slug.
   222 		 */
   236 		 */
   223 		do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
   237 		do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
   224 		?>
   238 		?>
   225 	</table>
   239 	</table>
   226 <?php
   240 <?php
   236 	 * Fires at the end of the Edit Term form.
   250 	 * Fires at the end of the Edit Term form.
   237 	 *
   251 	 *
   238 	 * @since 2.5.0
   252 	 * @since 2.5.0
   239 	 * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
   253 	 * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
   240 	 *
   254 	 *
   241 	 * @param object $tag Current taxonomy term object.
   255 	 * @param WP_Term $tag Current taxonomy term object.
   242 	 */
   256 	 */
   243 	do_action( 'edit_tag_form', $tag );
   257 	do_action( 'edit_tag_form', $tag );
   244 }
   258 }
   245 /**
   259 /**
   246  * Fires at the end of the Edit Term form for all taxonomies.
   260  * Fires at the end of the Edit Term form for all taxonomies.
   247  *
   261  *
   248  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   262  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   249  *
   263  *
   250  * @since 3.0.0
   264  * @since 3.0.0
   251  *
   265  *
   252  * @param object $tag      Current taxonomy term object.
   266  * @param WP_Term $tag      Current taxonomy term object.
   253  * @param string $taxonomy Current taxonomy slug.
   267  * @param string  $taxonomy Current taxonomy slug.
   254  */
   268  */
   255 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
   269 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
   256 ?>
   270 ?>
   257 
   271 
   258 <div class="edit-tag-actions">
   272 <div class="edit-tag-actions">
   259 
   273 
   260 	<?php submit_button( __( 'Update' ), 'primary', null, false ); ?>
   274 	<?php submit_button( __( 'Update' ), 'primary', null, false ); ?>
   261 
   275 
   262 	<?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?>
   276 	<?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?>
   263 		<span id="delete-link">
   277 		<span id="delete-link">
   264 			<a class="delete" href="<?php echo admin_url( wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) ) ?>"><?php _e( 'Delete' ); ?></a>
   278 			<a class="delete" href="<?php echo admin_url( wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) ); ?>"><?php _e( 'Delete' ); ?></a>
   265 		</span>
   279 		</span>
   266 	<?php endif; ?>
   280 	<?php endif; ?>
   267 
   281 
   268 </div>
   282 </div>
   269 
   283 
   272 
   286 
   273 <?php if ( ! wp_is_mobile() ) : ?>
   287 <?php if ( ! wp_is_mobile() ) : ?>
   274 <script type="text/javascript">
   288 <script type="text/javascript">
   275 try{document.forms.edittag.name.focus();}catch(e){}
   289 try{document.forms.edittag.name.focus();}catch(e){}
   276 </script>
   290 </script>
   277 <?php endif;
   291 	<?php
       
   292 endif;