[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

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

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


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7