[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> edit-tag-form.php (source)

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


Generated : Wed May 8 08:20:02 2024 Cross-referenced by PHPXref