/wp-admin/edit-tag-form.php

  1. <?php 
  2. /** 
  3. * Edit tag form for inclusion in administration panels. 
  4. * 
  5. * @package WordPress 
  6. * @subpackage Administration 
  7. */ 
  8.  
  9. // don't load directly 
  10. if ( ! defined( 'ABSPATH' ) ) { 
  11. die( '-1' ); 
  12.  
  13. // Back compat hooks 
  14. if ( 'category' == $taxonomy ) { 
  15. /** 
  16. * Fires before the Edit Category form. 
  17. * 
  18. * @since 2.1.0 
  19. * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 
  20. * 
  21. * @param object $tag Current category term object. 
  22. */ 
  23. do_action( 'edit_category_form_pre', $tag ); 
  24. } elseif ( 'link_category' == $taxonomy ) { 
  25. /** 
  26. * Fires before the Edit Link Category form. 
  27. * 
  28. * @since 2.3.0 
  29. * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 
  30. * 
  31. * @param object $tag Current link category term object. 
  32. */ 
  33. do_action( 'edit_link_category_form_pre', $tag ); 
  34. } else { 
  35. /** 
  36. * Fires before the Edit Tag form. 
  37. * 
  38. * @since 2.5.0 
  39. * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead. 
  40. * 
  41. * @param object $tag Current tag term object. 
  42. */ 
  43. do_action( 'edit_tag_form_pre', $tag ); 
  44.  
  45. /** 
  46. * Use with caution, see https://codex.wordpress.org/Function_Reference/wp_reset_vars 
  47. */ 
  48. wp_reset_vars( array( 'wp_http_referer' ) ); 
  49.  
  50. $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer ); 
  51.  
  52. /** Also used by Edit Tags */ 
  53. require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' ); 
  54.  
  55. /** 
  56. * Fires before the Edit Term form for all taxonomies. 
  57. * 
  58. * The dynamic portion of the hook name, `$taxonomy`, refers to 
  59. * the taxonomy slug. 
  60. * 
  61. * @since 3.0.0 
  62. * 
  63. * @param object $tag Current taxonomy term object. 
  64. * @param string $taxonomy Current $taxonomy slug. 
  65. */ 
  66. do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?> 
  67.  
  68. <div class="wrap"> 
  69. <h1><?php echo $tax->labels->edit_item; ?></h1> 
  70.  
  71. <?php if ( $message ) : ?> 
  72. <div id="message" class="updated"> 
  73. <p><strong><?php echo $message; ?></strong></p> 
  74. <?php if ( $wp_http_referer ) { ?> 
  75. <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php 
  76. /** translators: %s: taxonomy name */ 
  77. printf( _x( '← Back to %s', 'admin screen' ), $tax->labels->name ); 
  78. ?></a></p> 
  79. <?php } ?> 
  80. </div> 
  81. <?php endif; ?> 
  82.  
  83. <div id="ajax-response"></div> 
  84.  
  85. <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"<?php 
  86. /** 
  87. * Fires inside the Edit Term form tag. 
  88. * 
  89. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. 
  90. * 
  91. * @since 3.7.0 
  92. */ 
  93. do_action( "{$taxonomy}_term_edit_form_tag" ); 
  94. ?>> 
  95. <input type="hidden" name="action" value="editedtag"/> 
  96. <input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ) ?>"/> 
  97. <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/> 
  98. <?php 
  99. wp_original_referer_field( true, 'previous' ); 
  100. wp_nonce_field( 'update-tag_' . $tag_ID ); 
  101.  
  102. /** 
  103. * Fires at the beginning of the Edit Term form. 
  104. * 
  105. * At this point, the required hidden fields and nonces have already been output. 
  106. * 
  107. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. 
  108. * 
  109. * @since 4.5.0 
  110. * 
  111. * @param object $tag Current taxonomy term object. 
  112. * @param string $taxonomy Current $taxonomy slug. 
  113. */ 
  114. do_action( "{$taxonomy}_term_edit_form_top", $tag, $taxonomy ); 
  115. ?> 
  116. <table class="form-table"> 
  117. <tr class="form-field form-required term-name-wrap"> 
  118. <th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th> 
  119. <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" /> 
  120. <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td> 
  121. </tr> 
  122. <?php if ( !global_terms_enabled() ) { ?> 
  123. <tr class="form-field term-slug-wrap"> 
  124. <th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th> 
  125. <?php 
  126. /** 
  127. * Filters the editable slug. 
  128. * 
  129. * Note: This is a multi-use hook in that it is leveraged both for editable 
  130. * post URIs and term slugs. 
  131. * 
  132. * @since 2.6.0 
  133. * @since 4.4.0 The `$tag` parameter was added. 
  134. * 
  135. * @param string $slug The editable slug. Will be either a term slug or post URI depending 
  136. * upon the context in which it is evaluated. 
  137. * @param object|WP_Post $tag Term or WP_Post object. 
  138. */ 
  139. $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : ''; 
  140. ?> 
  141. <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" /> 
  142. <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> 
  143. </tr> 
  144. <?php } ?> 
  145. <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> 
  146. <tr class="form-field term-parent-wrap"> 
  147. <th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th> 
  148. <td> 
  149. <?php 
  150. $dropdown_args = array( 
  151. 'hide_empty' => 0,  
  152. 'hide_if_empty' => false,  
  153. 'taxonomy' => $taxonomy,  
  154. 'name' => 'parent',  
  155. 'orderby' => 'name',  
  156. 'selected' => $tag->parent,  
  157. 'exclude_tree' => $tag->term_id,  
  158. 'hierarchical' => true,  
  159. 'show_option_none' => __( 'None' ),  
  160. ); 
  161.  
  162. /** This filter is documented in wp-admin/edit-tags.php */ 
  163. $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' ); 
  164. wp_dropdown_categories( $dropdown_args ); ?> 
  165. <?php if ( 'category' == $taxonomy ) : ?> 
  166. <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> 
  167. <?php endif; ?> 
  168. </td> 
  169. </tr> 
  170. <?php endif; // is_taxonomy_hierarchical() ?> 
  171. <tr class="form-field term-description-wrap"> 
  172. <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th> 
  173. <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea> 
  174. <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td> 
  175. </tr> 
  176. <?php 
  177. // Back compat hooks 
  178. if ( 'category' == $taxonomy ) { 
  179. /** 
  180. * Fires after the Edit Category form fields are displayed. 
  181. * 
  182. * @since 2.9.0 
  183. * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 
  184. * 
  185. * @param object $tag Current category term object. 
  186. */ 
  187. do_action( 'edit_category_form_fields', $tag ); 
  188. } elseif ( 'link_category' == $taxonomy ) { 
  189. /** 
  190. * Fires after the Edit Link Category form fields are displayed. 
  191. * 
  192. * @since 2.9.0 
  193. * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 
  194. * 
  195. * @param object $tag Current link category term object. 
  196. */ 
  197. do_action( 'edit_link_category_form_fields', $tag ); 
  198. } else { 
  199. /** 
  200. * Fires after the Edit Tag form fields are displayed. 
  201. * 
  202. * @since 2.9.0 
  203. * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead. 
  204. * 
  205. * @param object $tag Current tag term object. 
  206. */ 
  207. do_action( 'edit_tag_form_fields', $tag ); 
  208. /** 
  209. * Fires after the Edit Term form fields are displayed. 
  210. * 
  211. * The dynamic portion of the hook name, `$taxonomy`, refers to 
  212. * the taxonomy slug. 
  213. * 
  214. * @since 3.0.0 
  215. * 
  216. * @param object $tag Current taxonomy term object. 
  217. * @param string $taxonomy Current taxonomy slug. 
  218. */ 
  219. do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy ); 
  220. ?> 
  221. </table> 
  222. <?php 
  223. // Back compat hooks 
  224. if ( 'category' == $taxonomy ) { 
  225. /** This action is documented in wp-admin/edit-tags.php */ 
  226. do_action( 'edit_category_form', $tag ); 
  227. } elseif ( 'link_category' == $taxonomy ) { 
  228. /** This action is documented in wp-admin/edit-tags.php */ 
  229. do_action( 'edit_link_category_form', $tag ); 
  230. } else { 
  231. /** 
  232. * Fires at the end of the Edit Term form. 
  233. * 
  234. * @since 2.5.0 
  235. * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead. 
  236. * 
  237. * @param object $tag Current taxonomy term object. 
  238. */ 
  239. do_action( 'edit_tag_form', $tag ); 
  240. /** 
  241. * Fires at the end of the Edit Term form for all taxonomies. 
  242. * 
  243. * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. 
  244. * 
  245. * @since 3.0.0 
  246. * 
  247. * @param object $tag Current taxonomy term object. 
  248. * @param string $taxonomy Current taxonomy slug. 
  249. */ 
  250. do_action( "{$taxonomy}_edit_form", $tag, $taxonomy ); 
  251.  
  252. submit_button( __('Update') ); 
  253. ?> 
  254. </form> 
  255. </div> 
  256.  
  257. <?php if ( ! wp_is_mobile() ) : ?> 
  258. <script type="text/javascript"> 
  259. try{document.forms.edittag.name.focus();}catch(e) {} 
  260. </script> 
  261. <?php endif; 
.