[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Post advanced form for inclusion in the administration panels.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  // Don't load directly.
  10  if ( ! defined( 'ABSPATH' ) ) {
  11      die( '-1' );
  12  }
  13  
  14  /**
  15   * @global string       $post_type
  16   * @global WP_Post_Type $post_type_object
  17   * @global WP_Post      $post             Global post object.
  18   */
  19  global $post_type, $post_type_object, $post;
  20  
  21  // Flag that we're not loading the block editor.
  22  $current_screen = get_current_screen();
  23  $current_screen->is_block_editor( false );
  24  
  25  if ( is_multisite() ) {
  26      add_action( 'admin_footer', '_admin_notice_post_locked' );
  27  } else {
  28      $check_users = get_users(
  29          array(
  30              'fields' => 'ID',
  31              'number' => 2,
  32          )
  33      );
  34  
  35      if ( count( $check_users ) > 1 ) {
  36          add_action( 'admin_footer', '_admin_notice_post_locked' );
  37      }
  38  
  39      unset( $check_users );
  40  }
  41  
  42  wp_enqueue_script( 'post' );
  43  
  44  $_wp_editor_expand   = false;
  45  $_content_editor_dfw = false;
  46  
  47  /**
  48   * Filters whether to enable the 'expand' functionality in the post editor.
  49   *
  50   * @since 4.0.0
  51   * @since 4.1.0 Added the `$post_type` parameter.
  52   *
  53   * @param bool   $expand    Whether to enable the 'expand' functionality. Default true.
  54   * @param string $post_type Post type.
  55   */
  56  $_wp_editor_expand_enabled = apply_filters( 'wp_editor_expand', true, $post_type );
  57  
  58  if ( post_type_supports( $post_type, 'editor' )
  59      && ! wp_is_mobile()
  60      && ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) )
  61      && $_wp_editor_expand_enabled
  62  ) {
  63  
  64      wp_enqueue_script( 'editor-expand' );
  65      $_content_editor_dfw = true;
  66      $_wp_editor_expand   = ( 'on' === get_user_setting( 'editor_expand', 'on' ) );
  67  }
  68  
  69  if ( wp_is_mobile() ) {
  70      wp_enqueue_script( 'jquery-touch-punch' );
  71  }
  72  
  73  /**
  74   * Post ID global
  75   *
  76   * @name $post_ID
  77   * @var int
  78   */
  79  $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
  80  $user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
  81  $action  = isset( $action ) ? $action : '';
  82  
  83  if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
  84      add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
  85      remove_post_type_support( $post_type, 'editor' );
  86  }
  87  
  88  $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
  89  if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
  90      if ( wp_attachment_is( 'audio', $post ) ) {
  91          $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
  92      } elseif ( wp_attachment_is( 'video', $post ) ) {
  93          $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
  94      }
  95  }
  96  
  97  if ( $thumbnail_support ) {
  98      add_thickbox();
  99      wp_enqueue_media( array( 'post' => $post_ID ) );
 100  }
 101  
 102  // Add the local autosave notice HTML.
 103  add_action( 'admin_footer', '_local_storage_notice' );
 104  
 105  /*
 106   * @todo Document the $messages array(s).
 107   */
 108  $permalink = get_permalink( $post_ID );
 109  if ( ! $permalink ) {
 110      $permalink = '';
 111  }
 112  
 113  $messages = array();
 114  
 115  $preview_post_link_html   = '';
 116  $scheduled_post_link_html = '';
 117  $view_post_link_html      = '';
 118  
 119  $preview_page_link_html   = '';
 120  $scheduled_page_link_html = '';
 121  $view_page_link_html      = '';
 122  
 123  $preview_url = get_preview_post_link( $post );
 124  
 125  $viewable = is_post_type_viewable( $post_type_object );
 126  
 127  if ( $viewable ) {
 128  
 129      // Preview post link.
 130      $preview_post_link_html = sprintf(
 131          ' <a target="_blank" href="%1$s">%2$s</a>',
 132          esc_url( $preview_url ),
 133          __( 'Preview post' )
 134      );
 135  
 136      // Scheduled post preview link.
 137      $scheduled_post_link_html = sprintf(
 138          ' <a target="_blank" href="%1$s">%2$s</a>',
 139          esc_url( $permalink ),
 140          __( 'Preview post' )
 141      );
 142  
 143      // View post link.
 144      $view_post_link_html = sprintf(
 145          ' <a href="%1$s">%2$s</a>',
 146          esc_url( $permalink ),
 147          __( 'View post' )
 148      );
 149  
 150      // Preview page link.
 151      $preview_page_link_html = sprintf(
 152          ' <a target="_blank" href="%1$s">%2$s</a>',
 153          esc_url( $preview_url ),
 154          __( 'Preview page' )
 155      );
 156  
 157      // Scheduled page preview link.
 158      $scheduled_page_link_html = sprintf(
 159          ' <a target="_blank" href="%1$s">%2$s</a>',
 160          esc_url( $permalink ),
 161          __( 'Preview page' )
 162      );
 163  
 164      // View page link.
 165      $view_page_link_html = sprintf(
 166          ' <a href="%1$s">%2$s</a>',
 167          esc_url( $permalink ),
 168          __( 'View page' )
 169      );
 170  
 171  }
 172  
 173  $scheduled_date = sprintf(
 174      /* translators: Publish box date string. 1: Date, 2: Time. */
 175      __( '%1$s at %2$s' ),
 176      /* translators: Publish box date format, see https://www.php.net/date */
 177      date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
 178      /* translators: Publish box time format, see https://www.php.net/date */
 179      date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
 180  );
 181  
 182  $messages['post']       = array(
 183      0  => '', // Unused. Messages start at index 1.
 184      1  => __( 'Post updated.' ) . $view_post_link_html,
 185      2  => __( 'Custom field updated.' ),
 186      3  => __( 'Custom field deleted.' ),
 187      4  => __( 'Post updated.' ),
 188      /* translators: %s: Date and time of the revision. */
 189      5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
 190      6  => __( 'Post published.' ) . $view_post_link_html,
 191      7  => __( 'Post saved.' ),
 192      8  => __( 'Post submitted.' ) . $preview_post_link_html,
 193      /* translators: %s: Scheduled date for the post. */
 194      9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
 195      10 => __( 'Post draft updated.' ) . $preview_post_link_html,
 196  );
 197  $messages['page']       = array(
 198      0  => '', // Unused. Messages start at index 1.
 199      1  => __( 'Page updated.' ) . $view_page_link_html,
 200      2  => __( 'Custom field updated.' ),
 201      3  => __( 'Custom field deleted.' ),
 202      4  => __( 'Page updated.' ),
 203      /* translators: %s: Date and time of the revision. */
 204      5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
 205      6  => __( 'Page published.' ) . $view_page_link_html,
 206      7  => __( 'Page saved.' ),
 207      8  => __( 'Page submitted.' ) . $preview_page_link_html,
 208      /* translators: %s: Scheduled date for the page. */
 209      9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
 210      10 => __( 'Page draft updated.' ) . $preview_page_link_html,
 211  );
 212  $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
 213  
 214  /**
 215   * Filters the post updated messages.
 216   *
 217   * @since 3.0.0
 218   *
 219   * @param array[] $messages Post updated messages. For defaults see `$messages` declarations above.
 220   */
 221  $messages = apply_filters( 'post_updated_messages', $messages );
 222  
 223  $message = false;
 224  if ( isset( $_GET['message'] ) ) {
 225      $_GET['message'] = absint( $_GET['message'] );
 226      if ( isset( $messages[ $post_type ][ $_GET['message'] ] ) ) {
 227          $message = $messages[ $post_type ][ $_GET['message'] ];
 228      } elseif ( ! isset( $messages[ $post_type ] ) && isset( $messages['post'][ $_GET['message'] ] ) ) {
 229          $message = $messages['post'][ $_GET['message'] ];
 230      }
 231  }
 232  
 233  $notice     = false;
 234  $form_extra = '';
 235  if ( 'auto-draft' === $post->post_status ) {
 236      if ( 'edit' === $action ) {
 237          $post->post_title = '';
 238      }
 239      $autosave    = false;
 240      $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
 241  } else {
 242      $autosave = wp_get_post_autosave( $post_ID );
 243  }
 244  
 245  $form_action  = 'editpost';
 246  $nonce_action = 'update-post_' . $post_ID;
 247  $form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
 248  
 249  // Detect if there exists an autosave newer than the post and if that autosave is different than the post.
 250  if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
 251      foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
 252          if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
 253              $notice = sprintf(
 254                  /* translators: %s: URL to view the autosave. */
 255                  __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),
 256                  get_edit_post_link( $autosave->ID )
 257              );
 258              break;
 259          }
 260      }
 261      // If this autosave isn't different from the current post, begone.
 262      if ( ! $notice ) {
 263          wp_delete_post_revision( $autosave->ID );
 264      }
 265      unset( $autosave_field, $_autosave_field );
 266  }
 267  
 268  $post_type_object = get_post_type_object( $post_type );
 269  
 270  // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
 271  require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
 272  
 273  register_and_do_post_meta_boxes( $post );
 274  
 275  add_screen_option(
 276      'layout_columns',
 277      array(
 278          'max'     => 2,
 279          'default' => 2,
 280      )
 281  );
 282  
 283  if ( 'post' === $post_type ) {
 284      $customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
 285  
 286      get_current_screen()->add_help_tab(
 287          array(
 288              'id'      => 'customize-display',
 289              'title'   => __( 'Customizing This Display' ),
 290              'content' => $customize_display,
 291          )
 292      );
 293  
 294      $title_and_editor  = '<p>' . __( '<strong>Title</strong> &mdash; Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.' ) . '</p>';
 295      $title_and_editor .= '<p>' . __( '<strong>Post editor</strong> &mdash; Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>';
 296      $title_and_editor .= '<p>' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '</p>';
 297      $title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Note that &lt;p&gt; and &lt;br&gt; tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing &lt;br&gt;, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>';
 298      $title_and_editor .= '<p>' . __( 'You can insert media files by clicking the button above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>';
 299      $title_and_editor .= '<p>' . __( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '</p>';
 300      $title_and_editor .= '<p>' . sprintf(
 301          /* translators: %s: Alt + F10 */
 302          __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use %s to access the toolbar.' ),
 303          '<kbd>Alt + F10</kbd>'
 304      ) . '</p>';
 305  
 306      get_current_screen()->add_help_tab(
 307          array(
 308              'id'      => 'title-post-editor',
 309              'title'   => __( 'Title and Post Editor' ),
 310              'content' => $title_and_editor,
 311          )
 312      );
 313  
 314      get_current_screen()->set_help_sidebar(
 315          '<p>' . sprintf(
 316              /* translators: %s: URL to Press This bookmarklet. */
 317              __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ),
 318              'tools.php'
 319          ) . '</p>' .
 320              '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 321              '<p>' . __( '<a href="https://wordpress.org/support/article/wordpress-editor/">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
 322              '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 323      );
 324  } elseif ( 'page' === $post_type ) {
 325      $about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
 326          '<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
 327  
 328      get_current_screen()->add_help_tab(
 329          array(
 330              'id'      => 'about-pages',
 331              'title'   => __( 'About Pages' ),
 332              'content' => $about_pages,
 333          )
 334      );
 335  
 336      get_current_screen()->set_help_sidebar(
 337          '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 338              '<p>' . __( '<a href="https://wordpress.org/support/article/pages-add-new-screen/">Documentation on Adding New Pages</a>' ) . '</p>' .
 339              '<p>' . __( '<a href="https://wordpress.org/support/article/pages-screen/">Documentation on Editing Pages</a>' ) . '</p>' .
 340              '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 341      );
 342  } elseif ( 'attachment' === $post_type ) {
 343      get_current_screen()->add_help_tab(
 344          array(
 345              'id'      => 'overview',
 346              'title'   => __( 'Overview' ),
 347              'content' =>
 348                  '<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
 349                  '<p>' . __( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
 350                  '<p>' . __( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
 351                  '<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
 352          )
 353      );
 354  
 355      get_current_screen()->set_help_sidebar(
 356          '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 357          '<p>' . __( '<a href="https://wordpress.org/support/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
 358          '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 359      );
 360  }
 361  
 362  if ( 'post' === $post_type || 'page' === $post_type ) {
 363      $inserting_media  = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
 364      $inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. <a href="https://wordpress.org/support/article/embeds/">Learn more about embeds</a>.' ) . '</p>';
 365  
 366      get_current_screen()->add_help_tab(
 367          array(
 368              'id'      => 'inserting-media',
 369              'title'   => __( 'Inserting Media' ),
 370              'content' => $inserting_media,
 371          )
 372      );
 373  }
 374  
 375  if ( 'post' === $post_type ) {
 376      $publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
 377      $publish_box .= '<ul><li>' .
 378          __( '<strong>Publish</strong> &mdash; You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) .
 379      '</li>';
 380  
 381      if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
 382          $publish_box .= '<li>' . __( '<strong>Format</strong> &mdash; Post Formats designate how your theme will display a specific post. For example, you could have a <em>standard</em> blog post with a title and paragraphs, or a short <em>aside</em> that omits the title and contains a short text blurb. Your theme could enable all or some of 10 possible formats. <a href="https://wordpress.org/support/article/post-formats/#supported-formats">Learn more about each post format</a>.' ) . '</li>';
 383      }
 384  
 385      if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
 386          $publish_box .= '<li>' . sprintf(
 387              /* translators: %s: Featured image. */
 388              __( '<strong>%s</strong> &mdash; This allows you to associate an image with your post without inserting it. This is usually useful only if your theme makes use of the image as a post thumbnail on the home page, a custom header, etc.' ),
 389              esc_html( $post_type_object->labels->featured_image )
 390          ) . '</li>';
 391      }
 392  
 393      $publish_box .= '</ul>';
 394  
 395      get_current_screen()->add_help_tab(
 396          array(
 397              'id'      => 'publish-box',
 398              'title'   => __( 'Publish Settings' ),
 399              'content' => $publish_box,
 400          )
 401      );
 402  
 403      $discussion_settings  = '<p>' . __( '<strong>Send Trackbacks</strong> &mdash; Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.' ) . '</p>';
 404      $discussion_settings .= '<p>' . __( '<strong>Discussion</strong> &mdash; You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.' ) . '</p>';
 405  
 406      get_current_screen()->add_help_tab(
 407          array(
 408              'id'      => 'discussion-settings',
 409              'title'   => __( 'Discussion Settings' ),
 410              'content' => $discussion_settings,
 411          )
 412      );
 413  } elseif ( 'page' === $post_type ) {
 414      $page_attributes = '<p>' . __( '<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
 415          '<p>' . __( '<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.' ) . '</p>' .
 416          '<p>' . __( '<strong>Order</strong> &mdash; Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.' ) . '</p>';
 417  
 418      get_current_screen()->add_help_tab(
 419          array(
 420              'id'      => 'page-attributes',
 421              'title'   => __( 'Page Attributes' ),
 422              'content' => $page_attributes,
 423          )
 424      );
 425  }
 426  
 427  require_once ABSPATH . 'wp-admin/admin-header.php';
 428  ?>
 429  
 430  <div class="wrap">
 431  <h1 class="wp-heading-inline">
 432  <?php
 433  echo esc_html( $title );
 434  ?>
 435  </h1>
 436  
 437  <?php
 438  if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) {
 439      echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
 440  }
 441  ?>
 442  
 443  <hr class="wp-header-end">
 444  
 445  <?php if ( $notice ) : ?>
 446  <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice; ?></p></div>
 447  <?php endif; ?>
 448  <?php if ( $message ) : ?>
 449  <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
 450  <?php endif; ?>
 451  <div id="lost-connection-notice" class="error hidden">
 452      <p><span class="spinner"></span> <?php _e( '<strong>Connection lost.</strong> Saving has been disabled until you&#8217;re reconnected.' ); ?>
 453      <span class="hide-if-no-sessionstorage"><?php _e( 'We&#8217;re backing up this post in your browser, just in case.' ); ?></span>
 454      </p>
 455  </div>
 456  <form name="post" action="post.php" method="post" id="post"
 457  <?php
 458  /**
 459   * Fires inside the post editor form tag.
 460   *
 461   * @since 3.0.0
 462   *
 463   * @param WP_Post $post Post object.
 464   */
 465  do_action( 'post_edit_form_tag', $post );
 466  
 467  $referer = wp_get_referer();
 468  ?>
 469  >
 470  <?php wp_nonce_field( $nonce_action ); ?>
 471  <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" />
 472  <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" />
 473  <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" />
 474  <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
 475  <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
 476  <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
 477  <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
 478  <?php if ( ! empty( $active_post_lock ) ) { ?>
 479  <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
 480      <?php
 481  }
 482  if ( 'draft' !== get_post_status( $post ) ) {
 483      wp_original_referer_field( true, 'previous' );
 484  }
 485  
 486  echo $form_extra;
 487  
 488  wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 489  wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 490  ?>
 491  
 492  <?php
 493  /**
 494   * Fires at the beginning of the edit form.
 495   *
 496   * At this point, the required hidden fields and nonces have already been output.
 497   *
 498   * @since 3.7.0
 499   *
 500   * @param WP_Post $post Post object.
 501   */
 502  do_action( 'edit_form_top', $post );
 503  ?>
 504  
 505  <div id="poststuff">
 506  <div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
 507  <div id="post-body-content">
 508  
 509  <?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
 510  <div id="titlediv">
 511  <div id="titlewrap">
 512      <?php
 513      /**
 514       * Filters the title field placeholder text.
 515       *
 516       * @since 3.1.0
 517       *
 518       * @param string  $text Placeholder text. Default 'Add title'.
 519       * @param WP_Post $post Post object.
 520       */
 521      $title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
 522      ?>
 523      <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
 524      <input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
 525  </div>
 526      <?php
 527      /**
 528       * Fires before the permalink field in the edit form.
 529       *
 530       * @since 4.1.0
 531       *
 532       * @param WP_Post $post Post object.
 533       */
 534      do_action( 'edit_form_before_permalink', $post );
 535      ?>
 536  <div class="inside">
 537      <?php
 538      if ( $viewable ) :
 539          $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
 540  
 541          // As of 4.4, the Get Shortlink button is hidden by default.
 542          if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
 543              $shortlink = wp_get_shortlink( $post->ID, 'post' );
 544  
 545              if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
 546                  $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
 547                      '<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
 548                      __( 'Get Shortlink' ) .
 549                      '</button>';
 550              }
 551          }
 552  
 553          if ( $post_type_object->public
 554              && ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
 555          ) {
 556              $has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
 557              ?>
 558      <div id="edit-slug-box" class="hide-if-no-js">
 559              <?php
 560              if ( $has_sample_permalink ) {
 561                  echo $sample_permalink_html;
 562              }
 563              ?>
 564      </div>
 565              <?php
 566          }
 567  endif;
 568      ?>
 569  </div>
 570      <?php
 571      wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
 572      ?>
 573  </div><!-- /titlediv -->
 574      <?php
 575  }
 576  /**
 577   * Fires after the title field.
 578   *
 579   * @since 3.5.0
 580   *
 581   * @param WP_Post $post Post object.
 582   */
 583  do_action( 'edit_form_after_title', $post );
 584  
 585  if ( post_type_supports( $post_type, 'editor' ) ) {
 586      $_wp_editor_expand_class = '';
 587      if ( $_wp_editor_expand ) {
 588          $_wp_editor_expand_class = ' wp-editor-expand';
 589      }
 590      ?>
 591  <div id="postdivrich" class="postarea<?php echo $_wp_editor_expand_class; ?>">
 592  
 593      <?php
 594      wp_editor(
 595          $post->post_content,
 596          'content',
 597          array(
 598              '_content_editor_dfw' => $_content_editor_dfw,
 599              'drag_drop_upload'    => true,
 600              'tabfocus_elements'   => 'content-html,save-post',
 601              'editor_height'       => 300,
 602              'tinymce'             => array(
 603                  'resize'                  => false,
 604                  'wp_autoresize_on'        => $_wp_editor_expand,
 605                  'add_unload_trigger'      => false,
 606                  'wp_keep_scroll_position' => ! $is_IE,
 607              ),
 608          )
 609      );
 610      ?>
 611  <table id="post-status-info"><tbody><tr>
 612      <td id="wp-word-count" class="hide-if-no-js">
 613      <?php
 614      printf(
 615          /* translators: %s: Number of words. */
 616          __( 'Word count: %s' ),
 617          '<span class="word-count">0</span>'
 618      );
 619      ?>
 620      </td>
 621      <td class="autosave-info">
 622      <span class="autosave-message">&nbsp;</span>
 623      <?php
 624      if ( 'auto-draft' !== $post->post_status ) {
 625          echo '<span id="last-edit">';
 626          $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
 627          if ( $last_user ) {
 628              /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
 629              printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
 630          } else {
 631              /* translators: 1: Post edited date, 2: Post edited time. */
 632              printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
 633          }
 634          echo '</span>';
 635      }
 636      ?>
 637      </td>
 638      <td id="content-resize-handle" class="hide-if-no-js"><br /></td>
 639  </tr></tbody></table>
 640  
 641  </div>
 642      <?php
 643  }
 644  /**
 645   * Fires after the content editor.
 646   *
 647   * @since 3.5.0
 648   *
 649   * @param WP_Post $post Post object.
 650   */
 651  do_action( 'edit_form_after_editor', $post );
 652  ?>
 653  </div><!-- /post-body-content -->
 654  
 655  <div id="postbox-container-1" class="postbox-container">
 656  <?php
 657  
 658  if ( 'page' === $post_type ) {
 659      /**
 660       * Fires before meta boxes with 'side' context are output for the 'page' post type.
 661       *
 662       * The submitpage box is a meta box with 'side' context, so this hook fires just before it is output.
 663       *
 664       * @since 2.5.0
 665       *
 666       * @param WP_Post $post Post object.
 667       */
 668      do_action( 'submitpage_box', $post );
 669  } else {
 670      /**
 671       * Fires before meta boxes with 'side' context are output for all post types other than 'page'.
 672       *
 673       * The submitpost box is a meta box with 'side' context, so this hook fires just before it is output.
 674       *
 675       * @since 2.5.0
 676       *
 677       * @param WP_Post $post Post object.
 678       */
 679      do_action( 'submitpost_box', $post );
 680  }
 681  
 682  
 683  do_meta_boxes( $post_type, 'side', $post );
 684  
 685  ?>
 686  </div>
 687  <div id="postbox-container-2" class="postbox-container">
 688  <?php
 689  
 690  do_meta_boxes( null, 'normal', $post );
 691  
 692  if ( 'page' === $post_type ) {
 693      /**
 694       * Fires after 'normal' context meta boxes have been output for the 'page' post type.
 695       *
 696       * @since 1.5.0
 697       *
 698       * @param WP_Post $post Post object.
 699       */
 700      do_action( 'edit_page_form', $post );
 701  } else {
 702      /**
 703       * Fires after 'normal' context meta boxes have been output for all post types other than 'page'.
 704       *
 705       * @since 1.5.0
 706       *
 707       * @param WP_Post $post Post object.
 708       */
 709      do_action( 'edit_form_advanced', $post );
 710  }
 711  
 712  
 713  do_meta_boxes( null, 'advanced', $post );
 714  
 715  ?>
 716  </div>
 717  <?php
 718  /**
 719   * Fires after all meta box sections have been output, before the closing #post-body div.
 720   *
 721   * @since 2.1.0
 722   *
 723   * @param WP_Post $post Post object.
 724   */
 725  do_action( 'dbx_post_sidebar', $post );
 726  
 727  ?>
 728  </div><!-- /post-body -->
 729  <br class="clear" />
 730  </div><!-- /poststuff -->
 731  </form>
 732  </div>
 733  
 734  <?php
 735  if ( post_type_supports( $post_type, 'comments' ) ) {
 736      wp_comment_reply();
 737  }
 738  ?>
 739  
 740  <?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>
 741  <script type="text/javascript">
 742  try{document.post.title.focus();}catch(e){}
 743  </script>
 744  <?php endif; ?>


Generated: Wed Aug 12 01:00:03 2020 Cross-referenced by PHPXref 0.7.1