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