[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Sun Apr 5 01:00:03 2020 Cross-referenced by PHPXref 0.7.1