You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

266 lines
8.5 KiB

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