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