author | ymh <ymh.work@gmail.com> |
Wed, 21 Sep 2022 18:19:35 +0200 | |
changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Edit tag form for inclusion in administration panels. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
16 | 9 |
// Don't load directly. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
if ( ! defined( 'ABSPATH' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
die( '-1' ); |
0 | 12 |
} |
13 |
||
16 | 14 |
// Back compat hooks. |
15 |
if ( 'category' === $taxonomy ) { |
|
5 | 16 |
/** |
9 | 17 |
* Fires before the Edit Category form. |
5 | 18 |
* |
19 |
* @since 2.1.0 |
|
16 | 20 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_pre_edit_form'} instead. |
5 | 21 |
* |
9 | 22 |
* @param WP_Term $tag Current category term object. |
5 | 23 |
*/ |
16 | 24 |
do_action_deprecated( 'edit_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' ); |
25 |
} elseif ( 'link_category' === $taxonomy ) { |
|
5 | 26 |
/** |
27 |
* Fires before the Edit Link Category form. |
|
28 |
* |
|
29 |
* @since 2.3.0 |
|
16 | 30 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_pre_edit_form'} instead. |
5 | 31 |
* |
9 | 32 |
* @param WP_Term $tag Current link category term object. |
5 | 33 |
*/ |
16 | 34 |
do_action_deprecated( 'edit_link_category_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' ); |
5 | 35 |
} else { |
36 |
/** |
|
37 |
* Fires before the Edit Tag form. |
|
38 |
* |
|
39 |
* @since 2.5.0 |
|
16 | 40 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_pre_edit_form'} instead. |
5 | 41 |
* |
9 | 42 |
* @param WP_Term $tag Current tag term object. |
5 | 43 |
*/ |
16 | 44 |
do_action_deprecated( 'edit_tag_form_pre', array( $tag ), '3.0.0', '{$taxonomy}_pre_edit_form' ); |
5 | 45 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
/** |
16 | 48 |
* Use with caution, see https://developer.wordpress.org/reference/functions/wp_reset_vars/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
wp_reset_vars( array( 'wp_http_referer' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
$wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
|
18 | 54 |
// Also used by Edit Tags. |
16 | 55 |
require_once ABSPATH . 'wp-admin/includes/edit-tag-messages.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
|
5 | 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 |
* |
|
18 | 63 |
* Possible hook names include: |
64 |
* |
|
65 |
* - `category_pre_edit_form` |
|
66 |
* - `post_tag_pre_edit_form` |
|
67 |
* |
|
5 | 68 |
* @since 3.0.0 |
69 |
* |
|
9 | 70 |
* @param WP_Term $tag Current taxonomy term object. |
71 |
* @param string $taxonomy Current $taxonomy slug. |
|
5 | 72 |
*/ |
73 |
do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?> |
|
0 | 74 |
|
75 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
<h1><?php echo $tax->labels->edit_item; ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
|
9 | 78 |
<?php |
79 |
$class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success'; |
|
80 |
||
81 |
if ( $message ) { |
|
82 |
?> |
|
83 |
<div id="message" class="notice notice-<?php echo $class; ?>"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
<p><strong><?php echo $message; ?></strong></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
<?php if ( $wp_http_referer ) { ?> |
9 | 86 |
<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>"> |
87 |
<?php echo esc_html( $tax->labels->back_to_items ); ?> |
|
88 |
</a></p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
</div> |
9 | 91 |
<?php |
92 |
} |
|
93 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
|
0 | 95 |
<div id="ajax-response"></div> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
|
9 | 97 |
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate" |
98 |
<?php |
|
5 | 99 |
/** |
100 |
* Fires inside the Edit Term form tag. |
|
101 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. |
5 | 103 |
* |
18 | 104 |
* Possible hook names include: |
105 |
* |
|
106 |
* - `category_term_edit_form_tag` |
|
107 |
* - `post_tag_term_edit_form_tag` |
|
108 |
* |
|
5 | 109 |
* @since 3.7.0 |
110 |
*/ |
|
111 |
do_action( "{$taxonomy}_term_edit_form_tag" ); |
|
9 | 112 |
?> |
113 |
> |
|
18 | 114 |
<input type="hidden" name="action" value="editedtag" /> |
115 |
<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ); ?>" /> |
|
116 |
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
wp_original_referer_field( true, 'previous' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
wp_nonce_field( 'update-tag_' . $tag_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
* Fires at the beginning of the Edit Term form. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
* At this point, the required hidden fields and nonces have already been output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
* |
18 | 128 |
* Possible hook names include: |
129 |
* |
|
130 |
* - `category_term_edit_form_top` |
|
131 |
* - `post_tag_term_edit_form_top` |
|
132 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
* @since 4.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* |
9 | 135 |
* @param WP_Term $tag Current taxonomy term object. |
136 |
* @param string $taxonomy Current $taxonomy slug. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
do_action( "{$taxonomy}_term_edit_form_top", $tag, $taxonomy ); |
9 | 139 |
|
140 |
$tag_name_value = ''; |
|
141 |
if ( isset( $tag->name ) ) { |
|
142 |
$tag_name_value = esc_attr( $tag->name ); |
|
143 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
?> |
9 | 145 |
<table class="form-table" role="presentation"> |
5 | 146 |
<tr class="form-field form-required term-name-wrap"> |
147 |
<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th> |
|
9 | 148 |
<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" /> |
149 |
<p class="description"><?php _e( 'The name is how it appears on your site.' ); ?></p></td> |
|
0 | 150 |
</tr> |
9 | 151 |
<?php if ( ! global_terms_enabled() ) { ?> |
5 | 152 |
<tr class="form-field term-slug-wrap"> |
153 |
<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th> |
|
154 |
<?php |
|
155 |
/** |
|
18 | 156 |
* Filters the editable slug for a post or term. |
5 | 157 |
* |
158 |
* Note: This is a multi-use hook in that it is leveraged both for editable |
|
159 |
* post URIs and term slugs. |
|
160 |
* |
|
161 |
* @since 2.6.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
* @since 4.4.0 The `$tag` parameter was added. |
5 | 163 |
* |
9 | 164 |
* @param string $slug The editable slug. Will be either a term slug or post URI depending |
165 |
* upon the context in which it is evaluated. |
|
18 | 166 |
* @param WP_Term|WP_Post $tag Term or post object. |
5 | 167 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : ''; |
5 | 169 |
?> |
170 |
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" /> |
|
9 | 171 |
<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> |
0 | 172 |
</tr> |
173 |
<?php } ?> |
|
9 | 174 |
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?> |
5 | 175 |
<tr class="form-field term-parent-wrap"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th> |
0 | 177 |
<td> |
5 | 178 |
<?php |
179 |
$dropdown_args = array( |
|
180 |
'hide_empty' => 0, |
|
181 |
'hide_if_empty' => false, |
|
182 |
'taxonomy' => $taxonomy, |
|
183 |
'name' => 'parent', |
|
184 |
'orderby' => 'name', |
|
185 |
'selected' => $tag->parent, |
|
186 |
'exclude_tree' => $tag->term_id, |
|
187 |
'hierarchical' => true, |
|
188 |
'show_option_none' => __( 'None' ), |
|
189 |
); |
|
190 |
||
191 |
/** This filter is documented in wp-admin/edit-tags.php */ |
|
192 |
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' ); |
|
9 | 193 |
wp_dropdown_categories( $dropdown_args ); |
194 |
?> |
|
16 | 195 |
<?php if ( 'category' === $taxonomy ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
<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> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
<?php else : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
<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> |
0 | 199 |
<?php endif; ?> |
200 |
</td> |
|
201 |
</tr> |
|
202 |
<?php endif; // is_taxonomy_hierarchical() ?> |
|
5 | 203 |
<tr class="form-field term-description-wrap"> |
204 |
<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th> |
|
205 |
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea> |
|
9 | 206 |
<p class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p></td> |
0 | 207 |
</tr> |
208 |
<?php |
|
16 | 209 |
// Back compat hooks. |
210 |
if ( 'category' === $taxonomy ) { |
|
5 | 211 |
/** |
212 |
* Fires after the Edit Category form fields are displayed. |
|
213 |
* |
|
214 |
* @since 2.9.0 |
|
16 | 215 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_edit_form_fields'} instead. |
5 | 216 |
* |
9 | 217 |
* @param WP_Term $tag Current category term object. |
5 | 218 |
*/ |
16 | 219 |
do_action_deprecated( 'edit_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' ); |
220 |
} elseif ( 'link_category' === $taxonomy ) { |
|
5 | 221 |
/** |
222 |
* Fires after the Edit Link Category form fields are displayed. |
|
223 |
* |
|
224 |
* @since 2.9.0 |
|
16 | 225 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_edit_form_fields'} instead. |
5 | 226 |
* |
9 | 227 |
* @param WP_Term $tag Current link category term object. |
5 | 228 |
*/ |
16 | 229 |
do_action_deprecated( 'edit_link_category_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' ); |
5 | 230 |
} else { |
231 |
/** |
|
232 |
* Fires after the Edit Tag form fields are displayed. |
|
233 |
* |
|
234 |
* @since 2.9.0 |
|
16 | 235 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_edit_form_fields'} instead. |
5 | 236 |
* |
9 | 237 |
* @param WP_Term $tag Current tag term object. |
5 | 238 |
*/ |
16 | 239 |
do_action_deprecated( 'edit_tag_form_fields', array( $tag ), '3.0.0', '{$taxonomy}_edit_form_fields' ); |
5 | 240 |
} |
241 |
/** |
|
242 |
* Fires after the Edit Term form fields are displayed. |
|
243 |
* |
|
244 |
* The dynamic portion of the hook name, `$taxonomy`, refers to |
|
245 |
* the taxonomy slug. |
|
246 |
* |
|
18 | 247 |
* Possible hook names include: |
248 |
* |
|
249 |
* - `category_edit_form_fields` |
|
250 |
* - `post_tag_edit_form_fields` |
|
251 |
* |
|
5 | 252 |
* @since 3.0.0 |
253 |
* |
|
9 | 254 |
* @param WP_Term $tag Current taxonomy term object. |
255 |
* @param string $taxonomy Current taxonomy slug. |
|
5 | 256 |
*/ |
257 |
do_action( "{$taxonomy}_edit_form_fields", $tag, $taxonomy ); |
|
0 | 258 |
?> |
259 |
</table> |
|
260 |
<?php |
|
16 | 261 |
// Back compat hooks. |
262 |
if ( 'category' === $taxonomy ) { |
|
5 | 263 |
/** This action is documented in wp-admin/edit-tags.php */ |
16 | 264 |
do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' ); |
265 |
} elseif ( 'link_category' === $taxonomy ) { |
|
5 | 266 |
/** This action is documented in wp-admin/edit-tags.php */ |
16 | 267 |
do_action_deprecated( 'edit_link_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' ); |
5 | 268 |
} else { |
269 |
/** |
|
270 |
* Fires at the end of the Edit Term form. |
|
271 |
* |
|
272 |
* @since 2.5.0 |
|
16 | 273 |
* @deprecated 3.0.0 Use {@see '{$taxonomy}_edit_form'} instead. |
5 | 274 |
* |
9 | 275 |
* @param WP_Term $tag Current taxonomy term object. |
5 | 276 |
*/ |
16 | 277 |
do_action_deprecated( 'edit_tag_form', array( $tag ), '3.0.0', '{$taxonomy}_edit_form' ); |
5 | 278 |
} |
279 |
/** |
|
280 |
* Fires at the end of the Edit Term form for all taxonomies. |
|
281 |
* |
|
282 |
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. |
|
283 |
* |
|
18 | 284 |
* Possible hook names include: |
285 |
* |
|
286 |
* - `category_edit_form` |
|
287 |
* - `post_tag_edit_form` |
|
288 |
* |
|
5 | 289 |
* @since 3.0.0 |
290 |
* |
|
9 | 291 |
* @param WP_Term $tag Current taxonomy term object. |
292 |
* @param string $taxonomy Current taxonomy slug. |
|
5 | 293 |
*/ |
294 |
do_action( "{$taxonomy}_edit_form", $tag, $taxonomy ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
?> |
0 | 296 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
<div class="edit-tag-actions"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
<?php submit_button( __( 'Update' ), 'primary', null, false ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
<?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
<span id="delete-link"> |
18 | 303 |
<a class="delete" href="<?php echo esc_url( 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> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
<?php endif; ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
|
0 | 309 |
</form> |
310 |
</div> |
|
5 | 311 |
|
312 |
<?php if ( ! wp_is_mobile() ) : ?> |
|
0 | 313 |
<script type="text/javascript"> |
314 |
try{document.forms.edittag.name.focus();}catch(e){} |
|
315 |
</script> |
|
9 | 316 |
<?php |
317 |
endif; |