WordPress 4.4
[autoinstalls/wordpress.git] / 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 if ( empty($tag_ID) ) { ?>
14         <div id="message" class="updated notice is-dismissible"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
15 <?php
16         return;
17 }
18
19 // Back compat hooks
20 if ( 'category' == $taxonomy ) {
21         /**
22          * Fires before the Edit Category form.
23          *
24          * @since 2.1.0
25          * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
26          *
27          * @param object $tag Current category term object.
28          */
29         do_action( 'edit_category_form_pre', $tag );
30 } elseif ( 'link_category' == $taxonomy ) {
31         /**
32          * Fires before the Edit Link Category form.
33          *
34          * @since 2.3.0
35          * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
36          *
37          * @param object $tag Current link category term object.
38          */
39         do_action( 'edit_link_category_form_pre', $tag );
40 } else {
41         /**
42          * Fires before the Edit Tag form.
43          *
44          * @since 2.5.0
45          * @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
46          *
47          * @param object $tag Current tag term object.
48          */
49         do_action( 'edit_tag_form_pre', $tag );
50 }
51
52 /**
53  * Use with caution, see http://codex.wordpress.org/Function_Reference/wp_reset_vars
54  */
55 wp_reset_vars( array( 'wp_http_referer' ) );
56
57 $wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
58
59 /** Also used by Edit Tags */
60 require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
61
62 /**
63  * Fires before the Edit Term form for all taxonomies.
64  *
65  * The dynamic portion of the hook name, `$taxonomy`, refers to
66  * the taxonomy slug.
67  *
68  * @since 3.0.0
69  *
70  * @param object $tag      Current taxonomy term object.
71  * @param string $taxonomy Current $taxonomy slug.
72  */
73 do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
74
75 <div class="wrap">
76 <h1><?php echo $tax->labels->edit_item; ?></h1>
77
78 <?php if ( $message ) : ?>
79 <div id="message" class="updated">
80         <p><strong><?php echo $message; ?></strong></p>
81         <?php if ( $wp_http_referer ) { ?>
82         <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
83         <?php } else { ?>
84         <p><a href="<?php echo esc_url( wp_get_referer() ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
85         <?php } ?>
86 </div>
87 <?php endif; ?>
88
89 <div id="ajax-response"></div>
90
91 <form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
92 <?php
93 /**
94  * Fires inside the Edit Term form tag.
95  *
96  * The dynamic portion of the hook name, `$taxonomy`, refers to
97  * the taxonomy slug.
98  *
99  * @since 3.7.0
100  */
101 do_action( "{$taxonomy}_term_edit_form_tag" );
102 ?>>
103 <input type="hidden" name="action" value="editedtag" />
104 <input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_id) ?>" />
105 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy) ?>" />
106 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('update-tag_' . $tag_ID); ?>
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                          * Filter 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
153                                 /** This filter is documented in wp-admin/edit-tags.php */
154                                 $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
155                                 wp_dropdown_categories( $dropdown_args ); ?>
156                                 <?php if ( 'category' == $taxonomy ) : ?>
157                                 <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>
158                                 <?php endif; ?>
159                         </td>
160                 </tr>
161 <?php endif; // is_taxonomy_hierarchical() ?>
162                 <tr class="form-field term-description-wrap">
163                         <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
164                         <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
165                         <p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
166                 </tr>
167                 <?php
168                 // Back compat hooks
169                 if ( 'category' == $taxonomy ) {
170                         /**
171                          * Fires after the Edit Category form fields are displayed.
172                          *
173                          * @since 2.9.0
174                          * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
175                          *
176                          * @param object $tag Current category term object.
177                          */
178                         do_action( 'edit_category_form_fields', $tag );
179                 } elseif ( 'link_category' == $taxonomy ) {
180                         /**
181                          * Fires after the Edit Link Category form fields are displayed.
182                          *
183                          * @since 2.9.0
184                          * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
185                          *
186                          * @param object $tag Current link category term object.
187                          */
188                         do_action( 'edit_link_category_form_fields', $tag );
189                 } else {
190                         /**
191                          * Fires after the Edit Tag form fields are displayed.
192                          *
193                          * @since 2.9.0
194                          * @deprecated 3.0.0 Use {$taxonomy}_edit_form_fields instead.
195                          *
196                          * @param object $tag Current tag term object.
197                          */
198                         do_action( 'edit_tag_form_fields', $tag );
199                 }
200                 /**
201                  * Fires after the Edit Term form fields are displayed.
202                  *
203                  * The dynamic portion of the hook name, `$taxonomy`, refers to
204                  * the taxonomy slug.
205                  *
206                  * @since 3.0.0
207                  *
208                  * @param object $tag      Current taxonomy term object.
209                  * @param string $taxonomy Current taxonomy slug.
210                  */
211                 do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy );
212                 ?>
213         </table>
214 <?php
215 // Back compat hooks
216 if ( 'category' == $taxonomy ) {
217         /** This action is documented in wp-admin/edit-tags.php */
218         do_action( 'edit_category_form', $tag );
219 } elseif ( 'link_category' == $taxonomy ) {
220         /** This action is documented in wp-admin/edit-tags.php */
221         do_action( 'edit_link_category_form', $tag );
222 } else {
223         /**
224          * Fires at the end of the Edit Term form.
225          *
226          * @since 2.5.0
227          * @deprecated 3.0.0 Use {$taxonomy}_edit_form instead.
228          *
229          * @param object $tag Current taxonomy term object.
230          */
231         do_action( 'edit_tag_form', $tag );
232 }
233 /**
234  * Fires at the end of the Edit Term form for all taxonomies.
235  *
236  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
237  *
238  * @since 3.0.0
239  *
240  * @param object $tag      Current taxonomy term object.
241  * @param string $taxonomy Current taxonomy slug.
242  */
243 do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
244
245 submit_button( __('Update') );
246 ?>
247 </form>
248 </div>
249
250 <?php if ( ! wp_is_mobile() ) : ?>
251 <script type="text/javascript">
252 try{document.forms.edittag.name.focus();}catch(e){}
253 </script>
254 <?php endif;