[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref