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