[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> meta-boxes.php (source)

   1  <?php
   2  /**
   3   * WordPress Administration Meta Boxes API.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  //
  10  // Post-related Meta Boxes.
  11  //
  12  
  13  /**
  14   * Displays post submit form fields.
  15   *
  16   * @since 2.7.0
  17   *
  18   * @global string $action
  19   *
  20   * @param WP_Post $post Current post object.
  21   * @param array   $args {
  22   *     Array of arguments for building the post submit meta box.
  23   *
  24   *     @type string   $id       Meta box 'id' attribute.
  25   *     @type string   $title    Meta box title.
  26   *     @type callable $callback Meta box display callback.
  27   *     @type array    $args     Extra meta box arguments.
  28   * }
  29   */
  30  function post_submit_meta_box( $post, $args = array() ) {
  31      global $action;
  32  
  33      $post_id          = (int) $post->ID;
  34      $post_type        = $post->post_type;
  35      $post_type_object = get_post_type_object( $post_type );
  36      $can_publish      = current_user_can( $post_type_object->cap->publish_posts );
  37      ?>
  38  <div class="submitbox" id="submitpost">
  39  
  40  <div id="minor-publishing">
  41  
  42      <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
  43      <div style="display:none;">
  44          <?php submit_button( __( 'Save' ), '', 'save' ); ?>
  45      </div>
  46  
  47      <div id="minor-publishing-actions">
  48          <div id="save-action">
  49              <?php
  50              if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) {
  51                  $private_style = '';
  52                  if ( 'private' === $post->post_status ) {
  53                      $private_style = 'style="display:none"';
  54                  }
  55                  ?>
  56                  <input <?php echo $private_style; ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Draft' ); ?>" class="button" />
  57                  <span class="spinner"></span>
  58              <?php } elseif ( 'pending' === $post->post_status && $can_publish ) { ?>
  59                  <input type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save as Pending' ); ?>" class="button" />
  60                  <span class="spinner"></span>
  61              <?php } ?>
  62          </div>
  63  
  64          <?php
  65          if ( is_post_type_viewable( $post_type_object ) ) :
  66              ?>
  67              <div id="preview-action">
  68                  <?php
  69                  $preview_link = esc_url( get_preview_post_link( $post ) );
  70                  if ( 'publish' === $post->post_status ) {
  71                      $preview_button_text = __( 'Preview Changes' );
  72                  } else {
  73                      $preview_button_text = __( 'Preview' );
  74                  }
  75  
  76                  $preview_button = sprintf(
  77                      '%1$s<span class="screen-reader-text"> %2$s</span>',
  78                      $preview_button_text,
  79                      /* translators: Accessibility text. */
  80                      __( '(opens in a new tab)' )
  81                  );
  82                  ?>
  83                  <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo $post_id; ?>" id="post-preview"><?php echo $preview_button; ?></a>
  84                  <input type="hidden" name="wp-preview" id="wp-preview" value="" />
  85              </div>
  86              <?php
  87          endif;
  88  
  89          /**
  90           * Fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons
  91           * in the Publish meta box.
  92           *
  93           * @since 4.4.0
  94           *
  95           * @param WP_Post $post WP_Post object for the current post.
  96           */
  97          do_action( 'post_submitbox_minor_actions', $post );
  98          ?>
  99          <div class="clear"></div>
 100      </div>
 101  
 102      <div id="misc-publishing-actions">
 103          <div class="misc-pub-section misc-pub-post-status">
 104              <?php _e( 'Status:' ); ?>
 105              <span id="post-status-display">
 106                  <?php
 107                  switch ( $post->post_status ) {
 108                      case 'private':
 109                          _e( 'Privately Published' );
 110                          break;
 111                      case 'publish':
 112                          _e( 'Published' );
 113                          break;
 114                      case 'future':
 115                          _e( 'Scheduled' );
 116                          break;
 117                      case 'pending':
 118                          _e( 'Pending Review' );
 119                          break;
 120                      case 'draft':
 121                      case 'auto-draft':
 122                          _e( 'Draft' );
 123                          break;
 124                  }
 125                  ?>
 126              </span>
 127  
 128              <?php
 129              if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) {
 130                  $private_style = '';
 131                  if ( 'private' === $post->post_status ) {
 132                      $private_style = 'style="display:none"';
 133                  }
 134                  ?>
 135                  <a href="#post_status" <?php echo $private_style; ?> class="edit-post-status hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
 136  
 137                  <div id="post-status-select" class="hide-if-js">
 138                      <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' === $post->post_status ) ? 'draft' : $post->post_status ); ?>" />
 139                      <label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label>
 140                      <select name="post_status" id="post_status">
 141                          <?php if ( 'publish' === $post->post_status ) : ?>
 142                              <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option>
 143                          <?php elseif ( 'private' === $post->post_status ) : ?>
 144                              <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option>
 145                          <?php elseif ( 'future' === $post->post_status ) : ?>
 146                              <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e( 'Scheduled' ); ?></option>
 147                          <?php endif; ?>
 148                              <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e( 'Pending Review' ); ?></option>
 149                          <?php if ( 'auto-draft' === $post->post_status ) : ?>
 150                              <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
 151                          <?php else : ?>
 152                              <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
 153                          <?php endif; ?>
 154                      </select>
 155                      <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e( 'OK' ); ?></a>
 156                      <a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
 157                  </div>
 158                  <?php
 159              }
 160              ?>
 161          </div>
 162  
 163          <div class="misc-pub-section misc-pub-visibility" id="visibility">
 164              <?php _e( 'Visibility:' ); ?>
 165              <span id="post-visibility-display">
 166                  <?php
 167                  if ( 'private' === $post->post_status ) {
 168                      $post->post_password = '';
 169                      $visibility          = 'private';
 170                      $visibility_trans    = __( 'Private' );
 171                  } elseif ( ! empty( $post->post_password ) ) {
 172                      $visibility       = 'password';
 173                      $visibility_trans = __( 'Password protected' );
 174                  } elseif ( 'post' === $post_type && is_sticky( $post_id ) ) {
 175                      $visibility       = 'public';
 176                      $visibility_trans = __( 'Public, Sticky' );
 177                  } else {
 178                      $visibility       = 'public';
 179                      $visibility_trans = __( 'Public' );
 180                  }
 181  
 182                  echo esc_html( $visibility_trans );
 183                  ?>
 184              </span>
 185  
 186              <?php if ( $can_publish ) { ?>
 187                  <a href="#visibility" class="edit-visibility hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a>
 188  
 189                  <div id="post-visibility-select" class="hide-if-js">
 190                      <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr( $post->post_password ); ?>" />
 191                      <?php if ( 'post' === $post_type ) : ?>
 192                          <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked( is_sticky( $post_id ) ); ?> />
 193                      <?php endif; ?>
 194  
 195                      <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
 196                      <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e( 'Public' ); ?></label><br />
 197  
 198                      <?php if ( 'post' === $post_type && current_user_can( 'edit_others_posts' ) ) : ?>
 199                          <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post_id ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
 200                      <?php endif; ?>
 201  
 202                      <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e( 'Password protected' ); ?></label><br />
 203                      <span id="password-span"><label for="post_password"><?php _e( 'Password:' ); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr( $post->post_password ); ?>"  maxlength="255" /><br /></span>
 204  
 205                      <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e( 'Private' ); ?></label><br />
 206  
 207                      <p>
 208                          <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e( 'OK' ); ?></a>
 209                          <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
 210                      </p>
 211                  </div>
 212              <?php } ?>
 213          </div>
 214  
 215          <?php
 216          /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
 217          $date_string = __( '%1$s at %2$s' );
 218          /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
 219          $date_format = _x( 'M j, Y', 'publish box date format' );
 220          /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
 221          $time_format = _x( 'H:i', 'publish box time format' );
 222  
 223          if ( 0 !== $post_id ) {
 224              if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date.
 225                  /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */
 226                  $stamp = __( 'Scheduled for: %s' );
 227              } elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published.
 228                  /* translators: Post date information. %s: Date on which the post was published. */
 229                  $stamp = __( 'Published on: %s' );
 230              } elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified.
 231                  $stamp = __( 'Publish <b>immediately</b>' );
 232              } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified.
 233                  /* translators: Post date information. %s: Date on which the post is to be published. */
 234                  $stamp = __( 'Schedule for: %s' );
 235              } else { // Draft, 1 or more saves, date specified.
 236                  /* translators: Post date information. %s: Date on which the post is to be published. */
 237                  $stamp = __( 'Publish on: %s' );
 238              }
 239              $date = sprintf(
 240                  $date_string,
 241                  date_i18n( $date_format, strtotime( $post->post_date ) ),
 242                  date_i18n( $time_format, strtotime( $post->post_date ) )
 243              );
 244          } else { // Draft (no saves, and thus no date specified).
 245              $stamp = __( 'Publish <b>immediately</b>' );
 246              $date  = sprintf(
 247                  $date_string,
 248                  date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ),
 249                  date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) )
 250              );
 251          }
 252  
 253          if ( ! empty( $args['args']['revisions_count'] ) ) :
 254              ?>
 255              <div class="misc-pub-section misc-pub-revisions">
 256                  <?php
 257                  /* translators: Post revisions heading. %s: The number of available revisions. */
 258                  printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
 259                  ?>
 260                  <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a>
 261              </div>
 262              <?php
 263          endif;
 264  
 265          if ( $can_publish ) : // Contributors don't get to choose the date of publish.
 266              ?>
 267              <div class="misc-pub-section curtime misc-pub-curtime">
 268                  <span id="timestamp">
 269                      <?php printf( $stamp, '<b>' . $date . '</b>' ); ?>
 270                  </span>
 271                  <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" role="button">
 272                      <span aria-hidden="true"><?php _e( 'Edit' ); ?></span>
 273                      <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span>
 274                  </a>
 275                  <fieldset id="timestampdiv" class="hide-if-js">
 276                      <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
 277                      <?php touch_time( ( 'edit' === $action ), 1 ); ?>
 278                  </fieldset>
 279              </div>
 280              <?php
 281          endif;
 282  
 283          if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
 284              ?>
 285              <div class="notice notice-info notice-alt inline">
 286                  <p>
 287                      <?php
 288                      printf(
 289                          /* translators: %s: URL to the Customizer. */
 290                          __( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there&#8217;s no need to publish now. It will be published automatically with those changes.' ),
 291                          esc_url(
 292                              add_query_arg(
 293                                  'changeset_uuid',
 294                                  rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
 295                                  admin_url( 'customize.php' )
 296                              )
 297                          )
 298                      );
 299                      ?>
 300                  </p>
 301              </div>
 302              <?php
 303          endif;
 304  
 305          /**
 306           * Fires after the post time/date setting in the Publish meta box.
 307           *
 308           * @since 2.9.0
 309           * @since 4.4.0 Added the `$post` parameter.
 310           *
 311           * @param WP_Post $post WP_Post object for the current post.
 312           */
 313          do_action( 'post_submitbox_misc_actions', $post );
 314          ?>
 315      </div>
 316      <div class="clear"></div>
 317  </div>
 318  
 319  <div id="major-publishing-actions">
 320      <?php
 321      /**
 322       * Fires at the beginning of the publishing actions section of the Publish meta box.
 323       *
 324       * @since 2.7.0
 325       * @since 4.9.0 Added the `$post` parameter.
 326       *
 327       * @param WP_Post|null $post WP_Post object for the current post on Edit Post screen,
 328       *                           null on Edit Link screen.
 329       */
 330      do_action( 'post_submitbox_start', $post );
 331      ?>
 332      <div id="delete-action">
 333          <?php
 334          if ( current_user_can( 'delete_post', $post_id ) ) {
 335              if ( ! EMPTY_TRASH_DAYS ) {
 336                  $delete_text = __( 'Delete permanently' );
 337              } else {
 338                  $delete_text = __( 'Move to Trash' );
 339              }
 340              ?>
 341              <a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post_id ); ?>"><?php echo $delete_text; ?></a>
 342              <?php
 343          }
 344          ?>
 345      </div>
 346  
 347      <div id="publishing-action">
 348          <span class="spinner"></span>
 349          <?php
 350          if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 === $post_id ) {
 351              if ( $can_publish ) :
 352                  if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) :
 353                      ?>
 354                      <input name="original_publish" type="hidden" id="original_publish" value="<?php echo esc_attr_x( 'Schedule', 'post action/button label' ); ?>" />
 355                      <?php submit_button( _x( 'Schedule', 'post action/button label' ), 'primary large', 'publish', false ); ?>
 356                      <?php
 357                  else :
 358                      ?>
 359                      <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Publish' ); ?>" />
 360                      <?php submit_button( __( 'Publish' ), 'primary large', 'publish', false ); ?>
 361                      <?php
 362                  endif;
 363              else :
 364                  ?>
 365                  <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Submit for Review' ); ?>" />
 366                  <?php submit_button( __( 'Submit for Review' ), 'primary large', 'publish', false ); ?>
 367                  <?php
 368              endif;
 369          } else {
 370              ?>
 371              <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" />
 372              <?php submit_button( __( 'Update' ), 'primary large', 'save', false, array( 'id' => 'publish' ) ); ?>
 373              <?php
 374          }
 375          ?>
 376      </div>
 377      <div class="clear"></div>
 378  </div>
 379  
 380  </div>
 381      <?php
 382  }
 383  
 384  /**
 385   * Display attachment submit form fields.
 386   *
 387   * @since 3.5.0
 388   *
 389   * @param WP_Post $post
 390   */
 391  function attachment_submit_meta_box( $post ) {
 392      ?>
 393  <div class="submitbox" id="submitpost">
 394  
 395  <div id="minor-publishing">
 396  
 397      <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
 398  <div style="display:none;">
 399      <?php submit_button( __( 'Save' ), '', 'save' ); ?>
 400  </div>
 401  
 402  
 403  <div id="misc-publishing-actions">
 404      <div class="misc-pub-section curtime misc-pub-curtime">
 405          <span id="timestamp">
 406              <?php
 407              $uploaded_on = sprintf(
 408                  /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */
 409                  __( '%1$s at %2$s' ),
 410                  /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
 411                  date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
 412                  /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
 413                  date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
 414              );
 415              /* translators: Attachment information. %s: Date the attachment was uploaded. */
 416              printf( __( 'Uploaded on: %s' ), '<b>' . $uploaded_on . '</b>' );
 417              ?>
 418          </span>
 419      </div><!-- .misc-pub-section -->
 420  
 421      <?php
 422      /**
 423       * Fires after the 'Uploaded on' section of the Save meta box
 424       * in the attachment editing screen.
 425       *
 426       * @since 3.5.0
 427       * @since 4.9.0 Added the `$post` parameter.
 428       *
 429       * @param WP_Post $post WP_Post object for the current attachment.
 430       */
 431      do_action( 'attachment_submitbox_misc_actions', $post );
 432      ?>
 433  </div><!-- #misc-publishing-actions -->
 434  <div class="clear"></div>
 435  </div><!-- #minor-publishing -->
 436  
 437  <div id="major-publishing-actions">
 438      <div id="delete-action">
 439      <?php
 440      if ( current_user_can( 'delete_post', $post->ID ) ) {
 441          if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
 442              echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
 443          } else {
 444              $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
 445              echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete permanently' ) . '</a>';
 446          }
 447      }
 448      ?>
 449      </div>
 450  
 451      <div id="publishing-action">
 452          <span class="spinner"></span>
 453          <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" />
 454          <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ); ?>" />
 455      </div>
 456      <div class="clear"></div>
 457  </div><!-- #major-publishing-actions -->
 458  
 459  </div>
 460  
 461      <?php
 462  }
 463  
 464  /**
 465   * Display post format form elements.
 466   *
 467   * @since 3.1.0
 468   *
 469   * @param WP_Post $post Post object.
 470   * @param array   $box {
 471   *     Post formats meta box arguments.
 472   *
 473   *     @type string   $id       Meta box 'id' attribute.
 474   *     @type string   $title    Meta box title.
 475   *     @type callable $callback Meta box display callback.
 476   *     @type array    $args     Extra meta box arguments.
 477   * }
 478   */
 479  function post_format_meta_box( $post, $box ) {
 480      if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
 481          $post_formats = get_theme_support( 'post-formats' );
 482  
 483          if ( is_array( $post_formats[0] ) ) :
 484              $post_format = get_post_format( $post->ID );
 485              if ( ! $post_format ) {
 486                  $post_format = '0';
 487              }
 488              // Add in the current one if it isn't there yet, in case the current theme doesn't support it.
 489              if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) {
 490                  $post_formats[0][] = $post_format;
 491              }
 492              ?>
 493          <div id="post-formats-select">
 494          <fieldset>
 495              <legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend>
 496              <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label>
 497              <?php foreach ( $post_formats[0] as $format ) : ?>
 498              <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
 499              <?php endforeach; ?>
 500          </fieldset>
 501      </div>
 502              <?php
 503      endif;
 504  endif;
 505  }
 506  
 507  /**
 508   * Display post tags form fields.
 509   *
 510   * @since 2.6.0
 511   *
 512   * @todo Create taxonomy-agnostic wrapper for this.
 513   *
 514   * @param WP_Post $post Post object.
 515   * @param array   $box {
 516   *     Tags meta box arguments.
 517   *
 518   *     @type string   $id       Meta box 'id' attribute.
 519   *     @type string   $title    Meta box title.
 520   *     @type callable $callback Meta box display callback.
 521   *     @type array    $args {
 522   *         Extra meta box arguments.
 523   *
 524   *         @type string $taxonomy Taxonomy. Default 'post_tag'.
 525   *     }
 526   * }
 527   */
 528  function post_tags_meta_box( $post, $box ) {
 529      $defaults = array( 'taxonomy' => 'post_tag' );
 530      if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
 531          $args = array();
 532      } else {
 533          $args = $box['args'];
 534      }
 535      $parsed_args           = wp_parse_args( $args, $defaults );
 536      $tax_name              = esc_attr( $parsed_args['taxonomy'] );
 537      $taxonomy              = get_taxonomy( $parsed_args['taxonomy'] );
 538      $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
 539      $comma                 = _x( ',', 'tag delimiter' );
 540      $terms_to_edit         = get_terms_to_edit( $post->ID, $tax_name );
 541      if ( ! is_string( $terms_to_edit ) ) {
 542          $terms_to_edit = '';
 543      }
 544      ?>
 545  <div class="tagsdiv" id="<?php echo $tax_name; ?>">
 546      <div class="jaxtag">
 547      <div class="nojs-tags hide-if-js">
 548          <label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label>
 549          <p><textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p>
 550      </div>
 551      <?php if ( $user_can_assign_terms ) : ?>
 552      <div class="ajaxtag hide-if-no-js">
 553          <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
 554          <input data-wp-taxonomy="<?php echo $tax_name; ?>" type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" />
 555          <input type="button" class="button tagadd" value="<?php esc_attr_e( 'Add' ); ?>" />
 556      </div>
 557      <p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p>
 558      <?php elseif ( empty( $terms_to_edit ) ) : ?>
 559          <p><?php echo $taxonomy->labels->no_terms; ?></p>
 560      <?php endif; ?>
 561      </div>
 562      <ul class="tagchecklist" role="list"></ul>
 563  </div>
 564      <?php if ( $user_can_assign_terms ) : ?>
 565  <p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-<?php echo $tax_name; ?>" aria-expanded="false"><?php echo $taxonomy->labels->choose_from_most_used; ?></button></p>
 566  <?php endif; ?>
 567      <?php
 568  }
 569  
 570  /**
 571   * Display post categories form fields.
 572   *
 573   * @since 2.6.0
 574   *
 575   * @todo Create taxonomy-agnostic wrapper for this.
 576   *
 577   * @param WP_Post $post Post object.
 578   * @param array   $box {
 579   *     Categories meta box arguments.
 580   *
 581   *     @type string   $id       Meta box 'id' attribute.
 582   *     @type string   $title    Meta box title.
 583   *     @type callable $callback Meta box display callback.
 584   *     @type array    $args {
 585   *         Extra meta box arguments.
 586   *
 587   *         @type string $taxonomy Taxonomy. Default 'category'.
 588   *     }
 589   * }
 590   */
 591  function post_categories_meta_box( $post, $box ) {
 592      $defaults = array( 'taxonomy' => 'category' );
 593      if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) {
 594          $args = array();
 595      } else {
 596          $args = $box['args'];
 597      }
 598      $parsed_args = wp_parse_args( $args, $defaults );
 599      $tax_name    = esc_attr( $parsed_args['taxonomy'] );
 600      $taxonomy    = get_taxonomy( $parsed_args['taxonomy'] );
 601      ?>
 602      <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv">
 603          <ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs">
 604              <li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li>
 605              <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php echo esc_html( $taxonomy->labels->most_used ); ?></a></li>
 606          </ul>
 607  
 608          <div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;">
 609              <ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
 610                  <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?>
 611              </ul>
 612          </div>
 613  
 614          <div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
 615              <?php
 616              $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
 617              // Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks.
 618              echo "<input type='hidden' name='{$name}[]' value='0' />";
 619              ?>
 620              <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
 621                  <?php
 622                  wp_terms_checklist(
 623                      $post->ID,
 624                      array(
 625                          'taxonomy'     => $tax_name,
 626                          'popular_cats' => $popular_ids,
 627                      )
 628                  );
 629                  ?>
 630              </ul>
 631          </div>
 632      <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>
 633              <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children">
 634                  <a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new">
 635                      <?php
 636                          /* translators: %s: Add New taxonomy label. */
 637                          printf( __( '+ %s' ), $taxonomy->labels->add_new_item );
 638                      ?>
 639                  </a>
 640                  <p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child">
 641                      <label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label>
 642                      <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true" />
 643                      <label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent">
 644                          <?php echo $taxonomy->labels->parent_item_colon; ?>
 645                      </label>
 646                      <?php
 647                      $parent_dropdown_args = array(
 648                          'taxonomy'         => $tax_name,
 649                          'hide_empty'       => 0,
 650                          'name'             => 'new' . $tax_name . '_parent',
 651                          'orderby'          => 'name',
 652                          'hierarchical'     => 1,
 653                          'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
 654                      );
 655  
 656                      /**
 657                       * Filters the arguments for the taxonomy parent dropdown on the Post Edit page.
 658                       *
 659                       * @since 4.4.0
 660                       *
 661                       * @param array $parent_dropdown_args {
 662                       *     Optional. Array of arguments to generate parent dropdown.
 663                       *
 664                       *     @type string   $taxonomy         Name of the taxonomy to retrieve.
 665                       *     @type bool     $hide_if_empty    True to skip generating markup if no
 666                       *                                      categories are found. Default 0.
 667                       *     @type string   $name             Value for the 'name' attribute
 668                       *                                      of the select element.
 669                       *                                      Default "new{$tax_name}_parent".
 670                       *     @type string   $orderby          Which column to use for ordering
 671                       *                                      terms. Default 'name'.
 672                       *     @type bool|int $hierarchical     Whether to traverse the taxonomy
 673                       *                                      hierarchy. Default 1.
 674                       *     @type string   $show_option_none Text to display for the "none" option.
 675                       *                                      Default "&mdash; {$parent} &mdash;",
 676                       *                                      where `$parent` is 'parent_item'
 677                       *                                      taxonomy label.
 678                       * }
 679                       */
 680                      $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
 681  
 682                      wp_dropdown_categories( $parent_dropdown_args );
 683                      ?>
 684                      <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" />
 685                      <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?>
 686                      <span id="<?php echo $tax_name; ?>-ajax-response"></span>
 687                  </p>
 688              </div>
 689          <?php endif; ?>
 690      </div>
 691      <?php
 692  }
 693  
 694  /**
 695   * Display post excerpt form fields.
 696   *
 697   * @since 2.6.0
 698   *
 699   * @param WP_Post $post
 700   */
 701  function post_excerpt_meta_box( $post ) {
 702      ?>
 703  <label class="screen-reader-text" for="excerpt"><?php _e( 'Excerpt' ); ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
 704  <p>
 705      <?php
 706      printf(
 707          /* translators: %s: Documentation URL. */
 708          __( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),
 709          __( 'https://wordpress.org/support/article/excerpt/' )
 710      );
 711      ?>
 712  </p>
 713      <?php
 714  }
 715  
 716  /**
 717   * Display trackback links form fields.
 718   *
 719   * @since 2.6.0
 720   *
 721   * @param WP_Post $post
 722   */
 723  function post_trackback_meta_box( $post ) {
 724      $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' .
 725          esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />';
 726  
 727      if ( '' !== $post->pinged ) {
 728          $pings          = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
 729          $already_pinged = explode( "\n", trim( $post->pinged ) );
 730          foreach ( $already_pinged as $pinged_url ) {
 731              $pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>';
 732          }
 733          $pings .= '</ul>';
 734      }
 735  
 736      ?>
 737  <p>
 738      <label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label>
 739      <?php echo $form_trackback; ?>
 740  </p>
 741  <p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p>
 742  <p>
 743      <?php
 744      printf(
 745          /* translators: %s: Documentation URL. */
 746          __( 'Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
 747          __( 'https://wordpress.org/support/article/introduction-to-blogging/#comments' )
 748      );
 749      ?>
 750  </p>
 751      <?php
 752      if ( ! empty( $pings ) ) {
 753          echo $pings;
 754      }
 755  }
 756  
 757  /**
 758   * Display custom fields form fields.
 759   *
 760   * @since 2.6.0
 761   *
 762   * @param WP_Post $post
 763   */
 764  function post_custom_meta_box( $post ) {
 765      ?>
 766  <div id="postcustomstuff">
 767  <div id="ajax-response"></div>
 768      <?php
 769      $metadata = has_meta( $post->ID );
 770      foreach ( $metadata as $key => $value ) {
 771          if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) {
 772              unset( $metadata[ $key ] );
 773          }
 774      }
 775      list_meta( $metadata );
 776      meta_form( $post );
 777      ?>
 778  </div>
 779  <p>
 780      <?php
 781      printf(
 782          /* translators: %s: Documentation URL. */
 783          __( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
 784          __( 'https://wordpress.org/support/article/custom-fields/' )
 785      );
 786      ?>
 787  </p>
 788      <?php
 789  }
 790  
 791  /**
 792   * Display comments status form fields.
 793   *
 794   * @since 2.6.0
 795   *
 796   * @param WP_Post $post
 797   */
 798  function post_comment_status_meta_box( $post ) {
 799      ?>
 800  <input name="advanced_view" type="hidden" value="1" />
 801  <p class="meta-options">
 802      <label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked( $post->comment_status, 'open' ); ?> /> <?php _e( 'Allow comments' ); ?></label><br />
 803      <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked( $post->ping_status, 'open' ); ?> />
 804          <?php
 805          printf(
 806              /* translators: %s: Documentation URL. */
 807              __( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page' ),
 808              __( 'https://wordpress.org/support/article/introduction-to-blogging/#managing-comments' )
 809          );
 810          ?>
 811      </label>
 812      <?php
 813      /**
 814       * Fires at the end of the Discussion meta box on the post editing screen.
 815       *
 816       * @since 3.1.0
 817       *
 818       * @param WP_Post $post WP_Post object of the current post.
 819       */
 820      do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
 821      ?>
 822  </p>
 823      <?php
 824  }
 825  
 826  /**
 827   * Display comments for post table header
 828   *
 829   * @since 3.0.0
 830   *
 831   * @param array $result table header rows
 832   * @return array
 833   */
 834  function post_comment_meta_box_thead( $result ) {
 835      unset( $result['cb'], $result['response'] );
 836      return $result;
 837  }
 838  
 839  /**
 840   * Display comments for post.
 841   *
 842   * @since 2.8.0
 843   *
 844   * @param WP_Post $post
 845   */
 846  function post_comment_meta_box( $post ) {
 847      wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
 848      ?>
 849      <p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);"><?php _e( 'Add Comment' ); ?></button></p>
 850      <?php
 851  
 852      $total         = get_comments(
 853          array(
 854              'post_id' => $post->ID,
 855              'number'  => 1,
 856              'count'   => true,
 857          )
 858      );
 859      $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
 860      $wp_list_table->display( true );
 861  
 862      if ( 1 > $total ) {
 863          echo '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>';
 864      } else {
 865          $hidden = get_hidden_meta_boxes( get_current_screen() );
 866          if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
 867              ?>
 868              <script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
 869              <?php
 870          }
 871  
 872          ?>
 873          <p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php echo $total; ?>);return false;"><?php _e( 'Show comments' ); ?></a> <span class="spinner"></span></p>
 874          <?php
 875      }
 876  
 877      wp_comment_trashnotice();
 878  }
 879  
 880  /**
 881   * Display slug form fields.
 882   *
 883   * @since 2.6.0
 884   *
 885   * @param WP_Post $post
 886   */
 887  function post_slug_meta_box( $post ) {
 888      /** This filter is documented in wp-admin/edit-tag-form.php */
 889      $editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
 890      ?>
 891  <label class="screen-reader-text" for="post_name"><?php _e( 'Slug' ); ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
 892      <?php
 893  }
 894  
 895  /**
 896   * Display form field with list of authors.
 897   *
 898   * @since 2.6.0
 899   *
 900   * @global int $user_ID
 901   *
 902   * @param WP_Post $post
 903   */
 904  function post_author_meta_box( $post ) {
 905      global $user_ID;
 906      ?>
 907  <label class="screen-reader-text" for="post_author_override"><?php _e( 'Author' ); ?></label>
 908      <?php
 909      wp_dropdown_users(
 910          array(
 911              'who'              => 'authors',
 912              'name'             => 'post_author_override',
 913              'selected'         => empty( $post->ID ) ? $user_ID : $post->post_author,
 914              'include_selected' => true,
 915              'show'             => 'display_name_with_login',
 916          )
 917      );
 918  }
 919  
 920  /**
 921   * Display list of revisions.
 922   *
 923   * @since 2.6.0
 924   *
 925   * @param WP_Post $post
 926   */
 927  function post_revisions_meta_box( $post ) {
 928      wp_list_post_revisions( $post );
 929  }
 930  
 931  //
 932  // Page-related Meta Boxes.
 933  //
 934  
 935  /**
 936   * Display page attributes form fields.
 937   *
 938   * @since 2.7.0
 939   *
 940   * @param WP_Post $post
 941   */
 942  function page_attributes_meta_box( $post ) {
 943      if ( is_post_type_hierarchical( $post->post_type ) ) :
 944          $dropdown_args = array(
 945              'post_type'        => $post->post_type,
 946              'exclude_tree'     => $post->ID,
 947              'selected'         => $post->post_parent,
 948              'name'             => 'parent_id',
 949              'show_option_none' => __( '(no parent)' ),
 950              'sort_column'      => 'menu_order, post_title',
 951              'echo'             => 0,
 952          );
 953  
 954          /**
 955           * Filters the arguments used to generate a Pages drop-down element.
 956           *
 957           * @since 3.3.0
 958           *
 959           * @see wp_dropdown_pages()
 960           *
 961           * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
 962           * @param WP_Post $post          The current post.
 963           */
 964          $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
 965          $pages         = wp_dropdown_pages( $dropdown_args );
 966          if ( ! empty( $pages ) ) :
 967              ?>
 968  <p class="post-attributes-label-wrapper parent-id-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
 969              <?php echo $pages; ?>
 970              <?php
 971          endif; // End empty pages check.
 972      endif;  // End hierarchical check.
 973  
 974      if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
 975          $template = ! empty( $post->page_template ) ? $post->page_template : false;
 976          ?>
 977  <p class="post-attributes-label-wrapper page-template-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label>
 978          <?php
 979          /**
 980           * Fires immediately after the label inside the 'Template' section
 981           * of the 'Page Attributes' meta box.
 982           *
 983           * @since 4.4.0
 984           *
 985           * @param string  $template The template used for the current post.
 986           * @param WP_Post $post     The current post.
 987           */
 988          do_action( 'page_attributes_meta_box_template', $template, $post );
 989          ?>
 990  </p>
 991  <select name="page_template" id="page_template">
 992          <?php
 993          /**
 994           * Filters the title of the default page template displayed in the drop-down.
 995           *
 996           * @since 4.1.0
 997           *
 998           * @param string $label   The display value for the default page template title.
 999           * @param string $context Where the option label is displayed. Possible values
1000           *                        include 'meta-box' or 'quick-edit'.
1001           */
1002          $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'meta-box' );
1003          ?>
1004  <option value="default"><?php echo esc_html( $default_title ); ?></option>
1005          <?php page_template_dropdown( $template, $post->post_type ); ?>
1006  </select>
1007  <?php endif; ?>
1008      <?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?>
1009  <p class="post-attributes-label-wrapper menu-order-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p>
1010  <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" />
1011          <?php
1012          /**
1013           * Fires before the help hint text in the 'Page Attributes' meta box.
1014           *
1015           * @since 4.9.0
1016           *
1017           * @param WP_Post $post The current post.
1018           */
1019          do_action( 'page_attributes_misc_attributes', $post );
1020          ?>
1021          <?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
1022  <p class="post-attributes-help-text"><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p>
1023              <?php
1024      endif;
1025      endif;
1026  }
1027  
1028  //
1029  // Link-related Meta Boxes.
1030  //
1031  
1032  /**
1033   * Display link create form fields.
1034   *
1035   * @since 2.7.0
1036   *
1037   * @param object $link
1038   */
1039  function link_submit_meta_box( $link ) {
1040      ?>
1041  <div class="submitbox" id="submitlink">
1042  
1043  <div id="minor-publishing">
1044  
1045      <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?>
1046  <div style="display:none;">
1047      <?php submit_button( __( 'Save' ), '', 'save', false ); ?>
1048  </div>
1049  
1050  <div id="minor-publishing-actions">
1051  <div id="preview-action">
1052      <?php if ( ! empty( $link->link_id ) ) { ?>
1053      <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e( 'Visit Link' ); ?></a>
1054  <?php } ?>
1055  </div>
1056  <div class="clear"></div>
1057  </div>
1058  
1059  <div id="misc-publishing-actions">
1060  <div class="misc-pub-section misc-pub-private">
1061      <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked( $link->link_visible, 'N' ); ?> /> <?php _e( 'Keep this link private' ); ?></label>
1062  </div>
1063  </div>
1064  
1065  </div>
1066  
1067  <div id="major-publishing-actions">
1068      <?php
1069      /** This action is documented in wp-admin/includes/meta-boxes.php */
1070      do_action( 'post_submitbox_start', null );
1071      ?>
1072  <div id="delete-action">
1073      <?php
1074      if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) {
1075          printf(
1076              '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>',
1077              wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ),
1078              /* translators: %s: Link name. */
1079              esc_js( sprintf( __( "You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ),
1080              __( 'Delete' )
1081          );
1082      }
1083      ?>
1084  </div>
1085  
1086  <div id="publishing-action">
1087      <?php if ( ! empty( $link->link_id ) ) { ?>
1088      <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ); ?>" />
1089  <?php } else { ?>
1090      <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ); ?>" />
1091  <?php } ?>
1092  </div>
1093  <div class="clear"></div>
1094  </div>
1095      <?php
1096      /**
1097       * Fires at the end of the Publish box in the Link editing screen.
1098       *
1099       * @since 2.5.0
1100       */
1101      do_action( 'submitlink_box' );
1102      ?>
1103  <div class="clear"></div>
1104  </div>
1105      <?php
1106  }
1107  
1108  /**
1109   * Display link categories form fields.
1110   *
1111   * @since 2.6.0
1112   *
1113   * @param object $link
1114   */
1115  function link_categories_meta_box( $link ) {
1116      ?>
1117  <div id="taxonomy-linkcategory" class="categorydiv">
1118      <ul id="category-tabs" class="category-tabs">
1119          <li class="tabs"><a href="#categories-all"><?php _e( 'All categories' ); ?></a></li>
1120          <li class="hide-if-no-js"><a href="#categories-pop"><?php _ex( 'Most Used', 'categories' ); ?></a></li>
1121      </ul>
1122  
1123      <div id="categories-all" class="tabs-panel">
1124          <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
1125              <?php
1126              if ( isset( $link->link_id ) ) {
1127                  wp_link_category_checklist( $link->link_id );
1128              } else {
1129                  wp_link_category_checklist();
1130              }
1131              ?>
1132          </ul>
1133      </div>
1134  
1135      <div id="categories-pop" class="tabs-panel" style="display: none;">
1136          <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
1137              <?php wp_popular_terms_checklist( 'link_category' ); ?>
1138          </ul>
1139      </div>
1140  
1141      <div id="category-adder" class="wp-hidden-children">
1142          <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e( '+ Add New Category' ); ?></a>
1143          <p id="link-category-add" class="wp-hidden-child">
1144              <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
1145              <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
1146              <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e( 'Add' ); ?>" />
1147              <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
1148              <span id="category-ajax-response"></span>
1149          </p>
1150      </div>
1151  </div>
1152      <?php
1153  }
1154  
1155  /**
1156   * Display form fields for changing link target.
1157   *
1158   * @since 2.6.0
1159   *
1160   * @param object $link
1161   */
1162  function link_target_meta_box( $link ) {
1163  
1164      ?>
1165  <fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend>
1166  <p><label for="link_target_blank" class="selectit">
1167  <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( '_blank' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
1168      <?php _e( '<code>_blank</code> &mdash; new window or tab.' ); ?></label></p>
1169  <p><label for="link_target_top" class="selectit">
1170  <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ( '_top' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
1171      <?php _e( '<code>_top</code> &mdash; current window or tab, with no frames.' ); ?></label></p>
1172  <p><label for="link_target_none" class="selectit">
1173  <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ( '' === $link->link_target ) ? 'checked="checked"' : '' ); ?> />
1174      <?php _e( '<code>_none</code> &mdash; same window or tab.' ); ?></label></p>
1175  </fieldset>
1176  <p><?php _e( 'Choose the target frame for your link.' ); ?></p>
1177      <?php
1178  }
1179  
1180  /**
1181   * Display checked checkboxes attribute for xfn microformat options.
1182   *
1183   * @since 1.0.1
1184   *
1185   * @global object $link
1186   *
1187   * @param string $class
1188   * @param string $value
1189   * @param mixed  $deprecated Never used.
1190   */
1191  function xfn_check( $class, $value = '', $deprecated = '' ) {
1192      global $link;
1193  
1194      if ( ! empty( $deprecated ) ) {
1195          _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
1196      }
1197  
1198      $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
1199      $rels     = preg_split( '/\s+/', $link_rel );
1200  
1201      if ( '' !== $value && in_array( $value, $rels, true ) ) {
1202          echo ' checked="checked"';
1203      }
1204  
1205      if ( '' === $value ) {
1206          if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
1207              echo ' checked="checked"';
1208          }
1209          if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
1210              echo ' checked="checked"';
1211          }
1212          if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
1213              echo ' checked="checked"';
1214          }
1215          if ( 'identity' === $class && in_array( 'me', $rels, true ) ) {
1216              echo ' checked="checked"';
1217          }
1218      }
1219  }
1220  
1221  /**
1222   * Display xfn form fields.
1223   *
1224   * @since 2.6.0
1225   *
1226   * @param object $link
1227   */
1228  function link_xfn_meta_box( $link ) {
1229      ?>
1230  <table class="links-table">
1231      <tr>
1232          <th scope="row"><label for="link_rel"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'rel:' ); ?></label></th>
1233          <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr( $link->link_rel ) : '' ); ?>" /></td>
1234      </tr>
1235      <tr>
1236          <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'identity' ); ?></th>
1237          <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'identity' ); ?></span></legend>
1238              <label for="me">
1239              <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check( 'identity', 'me' ); ?> />
1240              <?php _e( 'another web address of mine' ); ?></label>
1241          </fieldset></td>
1242      </tr>
1243      <tr>
1244          <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friendship' ); ?></th>
1245          <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friendship' ); ?></span></legend>
1246              <label for="contact">
1247              <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check( 'friendship', 'contact' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'contact' ); ?>
1248              </label>
1249              <label for="acquaintance">
1250              <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check( 'friendship', 'acquaintance' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'acquaintance' ); ?>
1251              </label>
1252              <label for="friend">
1253              <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check( 'friendship', 'friend' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friend' ); ?>
1254              </label>
1255              <label for="friendship">
1256              <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check( 'friendship' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?>
1257              </label>
1258          </fieldset></td>
1259      </tr>
1260      <tr>
1261          <th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'physical' ); ?> </th>
1262          <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'physical' ); ?></span></legend>
1263              <label for="met">
1264              <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check( 'physical', 'met' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'met' ); ?>
1265              </label>
1266          </fieldset></td>
1267      </tr>
1268      <tr>
1269          <th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'professional' ); ?> </th>
1270          <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'professional' ); ?></span></legend>
1271              <label for="co-worker">
1272              <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check( 'professional', 'co-worker' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-worker' ); ?>
1273              </label>
1274              <label for="colleague">
1275              <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check( 'professional', 'colleague' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'colleague' ); ?>
1276              </label>
1277          </fieldset></td>
1278      </tr>
1279      <tr>
1280          <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'geographical' ); ?></th>
1281          <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'geographical' ); ?> </span></legend>
1282              <label for="co-resident">
1283              <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check( 'geographical', 'co-resident' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-resident' ); ?>
1284              </label>
1285              <label for="neighbor">
1286              <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check( 'geographical', 'neighbor' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'neighbor' ); ?>
1287              </label>
1288              <label for="geographical">
1289              <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check( 'geographical' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?>
1290              </label>
1291          </fieldset></td>
1292      </tr>
1293      <tr>
1294          <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'family' ); ?></th>
1295          <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'family' ); ?> </span></legend>
1296              <label for="child">
1297              <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check( 'family', 'child' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'child' ); ?>
1298              </label>
1299              <label for="kin">
1300              <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check( 'family', 'kin' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'kin' ); ?>
1301              </label>
1302              <label for="parent">
1303              <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check( 'family', 'parent' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'parent' ); ?>
1304              </label>
1305              <label for="sibling">
1306              <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check( 'family', 'sibling' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'sibling' ); ?>
1307              </label>
1308              <label for="spouse">
1309              <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check( 'family', 'spouse' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'spouse' ); ?>
1310              </label>
1311              <label for="family">
1312              <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check( 'family' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?>
1313              </label>
1314          </fieldset></td>
1315      </tr>
1316      <tr>
1317          <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'romantic' ); ?></th>
1318          <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'romantic' ); ?> </span></legend>
1319              <label for="muse">
1320              <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check( 'romantic', 'muse' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'muse' ); ?>
1321              </label>
1322              <label for="crush">
1323              <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check( 'romantic', 'crush' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'crush' ); ?>
1324              </label>
1325              <label for="date">
1326              <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check( 'romantic', 'date' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'date' ); ?>
1327              </label>
1328              <label for="romantic">
1329              <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check( 'romantic', 'sweetheart' ); ?> />&nbsp;<?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'sweetheart' ); ?>
1330              </label>
1331          </fieldset></td>
1332      </tr>
1333  
1334  </table>
1335  <p><?php _e( 'If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="https://gmpg.org/xfn/">XFN</a>.' ); ?></p>
1336      <?php
1337  }
1338  
1339  /**
1340   * Display advanced link options form fields.
1341   *
1342   * @since 2.6.0
1343   *
1344   * @param object $link
1345   */
1346  function link_advanced_meta_box( $link ) {
1347      ?>
1348  <table class="links-table" cellpadding="0">
1349      <tr>
1350          <th scope="row"><label for="link_image"><?php _e( 'Image Address' ); ?></label></th>
1351          <td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr( $link->link_image ) : '' ); ?>" /></td>
1352      </tr>
1353      <tr>
1354          <th scope="row"><label for="rss_uri"><?php _e( 'RSS Address' ); ?></label></th>
1355          <td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr( $link->link_rss ) : '' ); ?>" /></td>
1356      </tr>
1357      <tr>
1358          <th scope="row"><label for="link_notes"><?php _e( 'Notes' ); ?></label></th>
1359          <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : '' ); // textarea_escaped ?></textarea></td>
1360      </tr>
1361      <tr>
1362          <th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th>
1363          <td><select name="link_rating" id="link_rating" size="1">
1364          <?php
1365          for ( $parsed_args = 0; $parsed_args <= 10; $parsed_args++ ) {
1366              echo '<option value="' . $parsed_args . '"';
1367              if ( isset( $link->link_rating ) && $link->link_rating == $parsed_args ) {
1368                  echo ' selected="selected"';
1369              }
1370              echo( '>' . $parsed_args . '</option>' );
1371          }
1372          ?>
1373          </select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?>
1374          </td>
1375      </tr>
1376  </table>
1377      <?php
1378  }
1379  
1380  /**
1381   * Display post thumbnail meta box.
1382   *
1383   * @since 2.9.0
1384   *
1385   * @param WP_Post $post A post object.
1386   */
1387  function post_thumbnail_meta_box( $post ) {
1388      $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
1389      echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
1390  }
1391  
1392  /**
1393   * Display fields for ID3 data
1394   *
1395   * @since 3.9.0
1396   *
1397   * @param WP_Post $post A post object.
1398   */
1399  function attachment_id3_data_meta_box( $post ) {
1400      $meta = array();
1401      if ( ! empty( $post->ID ) ) {
1402          $meta = wp_get_attachment_metadata( $post->ID );
1403      }
1404  
1405      foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) :
1406          $value = '';
1407          if ( ! empty( $meta[ $key ] ) ) {
1408              $value = $meta[ $key ];
1409          }
1410          ?>
1411      <p>
1412          <label for="title"><?php echo $label; ?></label><br />
1413          <input type="text" name="id3_<?php echo esc_attr( $key ); ?>" id="id3_<?php echo esc_attr( $key ); ?>" class="large-text" value="<?php echo esc_attr( $value ); ?>" />
1414      </p>
1415          <?php
1416      endforeach;
1417  }
1418  
1419  /**
1420   * Registers the default post meta boxes, and runs the `do_meta_boxes` actions.
1421   *
1422   * @since 5.0.0
1423   *
1424   * @param WP_Post $post The post object that these meta boxes are being generated for.
1425   */
1426  function register_and_do_post_meta_boxes( $post ) {
1427      $post_type        = $post->post_type;
1428      $post_type_object = get_post_type_object( $post_type );
1429  
1430      $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
1431      if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
1432          if ( wp_attachment_is( 'audio', $post ) ) {
1433              $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
1434          } elseif ( wp_attachment_is( 'video', $post ) ) {
1435              $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
1436          }
1437      }
1438  
1439      $publish_callback_args = array( '__back_compat_meta_box' => true );
1440  
1441      if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) {
1442          $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
1443  
1444          // We should aim to show the revisions meta box only when there are revisions.
1445          if ( count( $revisions ) > 1 ) {
1446              $publish_callback_args = array(
1447                  'revisions_count'        => count( $revisions ),
1448                  'revision_id'            => reset( $revisions ),
1449                  '__back_compat_meta_box' => true,
1450              );
1451  
1452              add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1453          }
1454      }
1455  
1456      if ( 'attachment' === $post_type ) {
1457          wp_enqueue_script( 'image-edit' );
1458          wp_enqueue_style( 'imgareaselect' );
1459          add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1460          add_action( 'edit_form_after_title', 'edit_form_image_editor' );
1461  
1462          if ( wp_attachment_is( 'audio', $post ) ) {
1463              add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1464          }
1465      } else {
1466          add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
1467      }
1468  
1469      if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
1470          add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1471      }
1472  
1473      // All taxonomies.
1474      foreach ( get_object_taxonomies( $post ) as $tax_name ) {
1475          $taxonomy = get_taxonomy( $tax_name );
1476          if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
1477              continue;
1478          }
1479  
1480          $label = $taxonomy->labels->name;
1481  
1482          if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
1483              $tax_meta_box_id = 'tagsdiv-' . $tax_name;
1484          } else {
1485              $tax_meta_box_id = $tax_name . 'div';
1486          }
1487  
1488          add_meta_box(
1489              $tax_meta_box_id,
1490              $label,
1491              $taxonomy->meta_box_cb,
1492              null,
1493              'side',
1494              'core',
1495              array(
1496                  'taxonomy'               => $tax_name,
1497                  '__back_compat_meta_box' => true,
1498              )
1499          );
1500      }
1501  
1502      if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
1503          add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) );
1504      }
1505  
1506      if ( $thumbnail_support && current_user_can( 'upload_files' ) ) {
1507          add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low', array( '__back_compat_meta_box' => true ) );
1508      }
1509  
1510      if ( post_type_supports( $post_type, 'excerpt' ) ) {
1511          add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1512      }
1513  
1514      if ( post_type_supports( $post_type, 'trackbacks' ) ) {
1515          add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1516      }
1517  
1518      if ( post_type_supports( $post_type, 'custom-fields' ) ) {
1519          add_meta_box(
1520              'postcustom',
1521              __( 'Custom Fields' ),
1522              'post_custom_meta_box',
1523              null,
1524              'normal',
1525              'core',
1526              array(
1527                  '__back_compat_meta_box'             => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
1528                  '__block_editor_compatible_meta_box' => true,
1529              )
1530          );
1531      }
1532  
1533      /**
1534       * Fires in the middle of built-in meta box registration.
1535       *
1536       * @since 2.1.0
1537       * @deprecated 3.7.0 Use {@see 'add_meta_boxes'} instead.
1538       *
1539       * @param WP_Post $post Post object.
1540       */
1541      do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
1542  
1543      // Allow the Discussion meta box to show up if the post type supports comments,
1544      // or if comments or pings are open.
1545      if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
1546          add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1547      }
1548  
1549      $stati = get_post_stati( array( 'public' => true ) );
1550      if ( empty( $stati ) ) {
1551          $stati = array( 'publish' );
1552      }
1553      $stati[] = 'private';
1554  
1555      if ( in_array( get_post_status( $post ), $stati, true ) ) {
1556          // If the post type support comments, or the post has comments,
1557          // allow the Comments meta box.
1558          if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
1559              add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1560          }
1561      }
1562  
1563      if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
1564          add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1565      }
1566  
1567      if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
1568          add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
1569      }
1570  
1571      /**
1572       * Fires after all built-in meta boxes have been added.
1573       *
1574       * @since 3.0.0
1575       *
1576       * @param string  $post_type Post type.
1577       * @param WP_Post $post      Post object.
1578       */
1579      do_action( 'add_meta_boxes', $post_type, $post );
1580  
1581      /**
1582       * Fires after all built-in meta boxes have been added, contextually for the given post type.
1583       *
1584       * The dynamic portion of the hook name, `$post_type`, refers to the post type of the post.
1585       *
1586       * Possible hook names include:
1587       *
1588       *  - `add_meta_boxes_post`
1589       *  - `add_meta_boxes_page`
1590       *  - `add_meta_boxes_attachment`
1591       *
1592       * @since 3.0.0
1593       *
1594       * @param WP_Post $post Post object.
1595       */
1596      do_action( "add_meta_boxes_{$post_type}", $post );
1597  
1598      /**
1599       * Fires after meta boxes have been added.
1600       *
1601       * Fires once for each of the default meta box contexts: normal, advanced, and side.
1602       *
1603       * @since 3.0.0
1604       *
1605       * @param string                $post_type Post type of the post on Edit Post screen, 'link' on Edit Link screen,
1606       *                                         'dashboard' on Dashboard screen.
1607       * @param string                $context   Meta box context. Possible values include 'normal', 'advanced', 'side'.
1608       * @param WP_Post|object|string $post      Post object on Edit Post screen, link object on Edit Link screen,
1609       *                                         an empty string on Dashboard screen.
1610       */
1611      do_action( 'do_meta_boxes', $post_type, 'normal', $post );
1612      /** This action is documented in wp-admin/includes/meta-boxes.php */
1613      do_action( 'do_meta_boxes', $post_type, 'advanced', $post );
1614      /** This action is documented in wp-admin/includes/meta-boxes.php */
1615      do_action( 'do_meta_boxes', $post_type, 'side', $post );
1616  }


Generated: Thu Sep 23 01:00:04 2021 Cross-referenced by PHPXref 0.7.1