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