[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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        Global post type.
  16   * @global WP_Post_Type $post_type_object Global 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  if ( post_type_supports( $post_type, 'editor' )
  48      && ! wp_is_mobile()
  49      && ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) )
  50  ) {
  51      /**
  52       * Filters whether to enable the 'expand' functionality in the post editor.
  53       *
  54       * @since 4.0.0
  55       * @since 4.1.0 Added the `$post_type` parameter.
  56       *
  57       * @param bool   $expand    Whether to enable the 'expand' functionality. Default true.
  58       * @param string $post_type Post type.
  59       */
  60      if ( apply_filters( 'wp_editor_expand', true, $post_type ) ) {
  61          wp_enqueue_script( 'editor-expand' );
  62          $_content_editor_dfw = true;
  63          $_wp_editor_expand   = ( 'on' === get_user_setting( 'editor_expand', 'on' ) );
  64      }
  65  }
  66  
  67  if ( wp_is_mobile() ) {
  68      wp_enqueue_script( 'jquery-touch-punch' );
  69  }
  70  
  71  /**
  72   * Post ID global
  73   *
  74   * @name $post_ID
  75   * @var int
  76   */
  77  $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
  78  $user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
  79  $action  = isset( $action ) ? $action : '';
  80  
  81  if ( (int) get_option( 'page_for_posts' ) === $post->ID && empty( $post->post_content ) ) {
  82      add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
  83      remove_post_type_support( $post_type, 'editor' );
  84  }
  85  
  86  $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
  87  if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
  88      if ( wp_attachment_is( 'audio', $post ) ) {
  89          $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
  90      } elseif ( wp_attachment_is( 'video', $post ) ) {
  91          $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
  92      }
  93  }
  94  
  95  if ( $thumbnail_support ) {
  96      add_thickbox();
  97      wp_enqueue_media( array( 'post' => $post->ID ) );
  98  }
  99  
 100  // Add the local autosave notice HTML.
 101  add_action( 'admin_footer', '_local_storage_notice' );
 102  
 103  /*
 104   * @todo Document the $messages array(s).
 105   */
 106  $permalink = get_permalink( $post->ID );
 107  if ( ! $permalink ) {
 108      $permalink = '';
 109  }
 110  
 111  $messages = array();
 112  
 113  $preview_post_link_html   = '';
 114  $scheduled_post_link_html = '';
 115  $view_post_link_html      = '';
 116  
 117  $preview_page_link_html   = '';
 118  $scheduled_page_link_html = '';
 119  $view_page_link_html      = '';
 120  
 121  $preview_url = get_preview_post_link( $post );
 122  
 123  $viewable = is_post_type_viewable( $post_type_object );
 124  
 125  if ( $viewable ) {
 126  
 127      // Preview post link.
 128      $preview_post_link_html = sprintf(
 129          ' <a target="_blank" href="%1$s">%2$s</a>',
 130          esc_url( $preview_url ),
 131          __( 'Preview post' )
 132      );
 133  
 134      // Scheduled post preview link.
 135      $scheduled_post_link_html = sprintf(
 136          ' <a target="_blank" href="%1$s">%2$s</a>',
 137          esc_url( $permalink ),
 138          __( 'Preview post' )
 139      );
 140  
 141      // View post link.
 142      $view_post_link_html = sprintf(
 143          ' <a href="%1$s">%2$s</a>',
 144          esc_url( $permalink ),
 145          __( 'View post' )
 146      );
 147  
 148      // Preview page link.
 149      $preview_page_link_html = sprintf(
 150          ' <a target="_blank" href="%1$s">%2$s</a>',
 151          esc_url( $preview_url ),
 152          __( 'Preview page' )
 153      );
 154  
 155      // Scheduled page preview link.
 156      $scheduled_page_link_html = sprintf(
 157          ' <a target="_blank" href="%1$s">%2$s</a>',
 158          esc_url( $permalink ),
 159          __( 'Preview page' )
 160      );
 161  
 162      // View page link.
 163      $view_page_link_html = sprintf(
 164          ' <a href="%1$s">%2$s</a>',
 165          esc_url( $permalink ),
 166          __( 'View page' )
 167      );
 168  
 169  }
 170  
 171  $scheduled_date = sprintf(
 172      /* translators: Publish box date string. 1: Date, 2: Time. */
 173      __( '%1$s at %2$s' ),
 174      /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */
 175      date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
 176      /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */
 177      date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
 178  );
 179  
 180  $messages['post']       = array(
 181      0  => '', // Unused. Messages start at index 1.
 182      1  => __( 'Post updated.' ) . $view_post_link_html,
 183      2  => __( 'Custom field updated.' ),
 184      3  => __( 'Custom field deleted.' ),
 185      4  => __( 'Post updated.' ),
 186      /* translators: %s: Date and time of the revision. */
 187      5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
 188      6  => __( 'Post published.' ) . $view_post_link_html,
 189      7  => __( 'Post saved.' ),
 190      8  => __( 'Post submitted.' ) . $preview_post_link_html,
 191      /* translators: %s: Scheduled date for the post. */
 192      9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
 193      10 => __( 'Post draft updated.' ) . $preview_post_link_html,
 194  );
 195  $messages['page']       = array(
 196      0  => '', // Unused. Messages start at index 1.
 197      1  => __( 'Page updated.' ) . $view_page_link_html,
 198      2  => __( 'Custom field updated.' ),
 199      3  => __( 'Custom field deleted.' ),
 200      4  => __( 'Page updated.' ),
 201      /* translators: %s: Date and time of the revision. */
 202      5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
 203      6  => __( 'Page published.' ) . $view_page_link_html,
 204      7  => __( 'Page saved.' ),
 205      8  => __( 'Page submitted.' ) . $preview_page_link_html,
 206      /* translators: %s: Scheduled date for the page. */
 207      9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
 208      10 => __( 'Page draft updated.' ) . $preview_page_link_html,
 209  );
 210  $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
 211  
 212  /**
 213   * Filters the post updated messages.
 214   *
 215   * @since 3.0.0
 216   *
 217   * @param array[] $messages Post updated messages. For defaults see `$messages` declarations above.
 218   */
 219  $messages = apply_filters( 'post_updated_messages', $messages );
 220  
 221  $message = false;
 222  if ( isset( $_GET['message'] ) ) {
 223      $_GET['message'] = absint( $_GET['message'] );
 224      if ( isset( $messages[ $post_type ][ $_GET['message'] ] ) ) {
 225          $message = $messages[ $post_type ][ $_GET['message'] ];
 226      } elseif ( ! isset( $messages[ $post_type ] ) && isset( $messages['post'][ $_GET['message'] ] ) ) {
 227          $message = $messages['post'][ $_GET['message'] ];
 228      }
 229  }
 230  
 231  $notice     = false;
 232  $form_extra = '';
 233  if ( 'auto-draft' === $post->post_status ) {
 234      if ( 'edit' === $action ) {
 235          $post->post_title = '';
 236      }
 237      $autosave    = false;
 238      $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
 239  } else {
 240      $autosave = wp_get_post_autosave( $post->ID );
 241  }
 242  
 243  $form_action  = 'editpost';
 244  $nonce_action = 'update-post_' . $post->ID;
 245  $form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />";
 246  
 247  // Detect if there exists an autosave newer than the post and if that autosave is different than the post.
 248  if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
 249      foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
 250          if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
 251              $notice = sprintf(
 252                  /* translators: %s: URL to view the autosave. */
 253                  __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),
 254                  get_edit_post_link( $autosave->ID )
 255              );
 256              break;
 257          }
 258      }
 259      // If this autosave isn't different from the current post, begone.
 260      if ( ! $notice ) {
 261          wp_delete_post_revision( $autosave->ID );
 262      }
 263      unset( $autosave_field, $_autosave_field );
 264  }
 265  
 266  $post_type_object = get_post_type_object( $post_type );
 267  
 268  // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
 269  require_once  ABSPATH . 'wp-admin/includes/meta-boxes.php';
 270  
 271  register_and_do_post_meta_boxes( $post );
 272  
 273  add_screen_option(
 274      'layout_columns',
 275      array(
 276          'max'     => 2,
 277          'default' => 2,
 278      )
 279  );
 280  
 281  if ( 'post' === $post_type ) {
 282      $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>';
 283  
 284      get_current_screen()->add_help_tab(
 285          array(
 286              'id'      => 'customize-display',
 287              'title'   => __( 'Customizing This Display' ),
 288              'content' => $customize_display,
 289          )
 290      );
 291  
 292      $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>';
 293      $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>';
 294      $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>';
 295      $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>';
 296      $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>';
 297      $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>';
 298      $title_and_editor .= '<p>' . sprintf(
 299          /* translators: %s: Alt + F10 */
 300          __( 'Keyboard users: When you are working in the visual editor, you can use %s to access the toolbar.' ),
 301          '<kbd>Alt + F10</kbd>'
 302      ) . '</p>';
 303  
 304      get_current_screen()->add_help_tab(
 305          array(
 306              'id'      => 'title-post-editor',
 307              'title'   => __( 'Title and Post Editor' ),
 308              'content' => $title_and_editor,
 309          )
 310      );
 311  
 312      get_current_screen()->set_help_sidebar(
 313          '<p>' . sprintf(
 314              /* translators: %s: URL to Press This bookmarklet. */
 315              __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ),
 316              'tools.php'
 317          ) . '</p>' .
 318              '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 319              '<p>' . __( '<a href="https://wordpress.org/documentation/article/write-posts-classic-editor/">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
 320              '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 321      );
 322  } elseif ( 'page' === $post_type ) {
 323      $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>' .
 324          '<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>';
 325  
 326      get_current_screen()->add_help_tab(
 327          array(
 328              'id'      => 'about-pages',
 329              'title'   => __( 'About Pages' ),
 330              'content' => $about_pages,
 331          )
 332      );
 333  
 334      get_current_screen()->set_help_sidebar(
 335          '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 336              '<p>' . __( '<a href="https://wordpress.org/documentation/article/pages-add-new-screen/">Documentation on Adding New Pages</a>' ) . '</p>' .
 337              '<p>' . __( '<a href="https://wordpress.org/documentation/article/pages-screen/">Documentation on Editing Pages</a>' ) . '</p>' .
 338              '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 339      );
 340  } elseif ( 'attachment' === $post_type ) {
 341      get_current_screen()->add_help_tab(
 342          array(
 343              'id'      => 'overview',
 344              'title'   => __( 'Overview' ),
 345              'content' =>
 346                  '<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
 347                  '<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>' .
 348                  '<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>' .
 349                  '<p>' . __( 'Remember to click Update to save metadata entered or changed.' ) . '</p>',
 350          )
 351      );
 352  
 353      get_current_screen()->set_help_sidebar(
 354          '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 355          '<p>' . __( '<a href="https://wordpress.org/documentation/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
 356          '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 357      );
 358  }
 359  
 360  if ( 'post' === $post_type || 'page' === $post_type ) {
 361      $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>';
 362      $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/documentation/article/embeds/">Learn more about embeds</a>.' ) . '</p>';
 363  
 364      get_current_screen()->add_help_tab(
 365          array(
 366              'id'      => 'inserting-media',
 367              'title'   => __( 'Inserting Media' ),
 368              'content' => $inserting_media,
 369          )
 370      );
 371  }
 372  
 373  if ( 'post' === $post_type ) {
 374      $publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
 375      $publish_box .= '<ul><li>' .
 376          __( '<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.' ) .
 377      '</li>';
 378  
 379      if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
 380          $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://developer.wordpress.org/advanced-administration/wordpress/post-formats/#supported-formats">Learn more about each post format</a>.' ) . '</li>';
 381      }
 382  
 383      if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
 384          $publish_box .= '<li>' . sprintf(
 385              /* translators: %s: Featured image. */
 386              __( '<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.' ),
 387              esc_html( $post_type_object->labels->featured_image )
 388          ) . '</li>';
 389      }
 390  
 391      $publish_box .= '</ul>';
 392  
 393      get_current_screen()->add_help_tab(
 394          array(
 395              'id'      => 'publish-box',
 396              'title'   => __( 'Publish Settings' ),
 397              'content' => $publish_box,
 398          )
 399      );
 400  
 401      $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>';
 402      $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>';
 403  
 404      get_current_screen()->add_help_tab(
 405          array(
 406              'id'      => 'discussion-settings',
 407              'title'   => __( 'Discussion Settings' ),
 408              'content' => $discussion_settings,
 409          )
 410      );
 411  } elseif ( 'page' === $post_type ) {
 412      $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>' .
 413          '<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>' .
 414          '<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>';
 415  
 416      get_current_screen()->add_help_tab(
 417          array(
 418              'id'      => 'page-attributes',
 419              'title'   => __( 'Page Attributes' ),
 420              'content' => $page_attributes,
 421          )
 422      );
 423  }
 424  
 425  require_once  ABSPATH . 'wp-admin/admin-header.php';
 426  ?>
 427  
 428  <div class="wrap">
 429  <h1 class="wp-heading-inline">
 430  <?php
 431  echo esc_html( $title );
 432  ?>
 433  </h1>
 434  
 435  <?php
 436  if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) {
 437      echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new_item ) . '</a>';
 438  }
 439  ?>
 440  
 441  <hr class="wp-header-end">
 442  
 443  <?php
 444  if ( $notice ) :
 445      wp_admin_notice(
 446          '<p id="has-newer-autosave">' . $notice . '</p>',
 447          array(
 448              'type'           => 'warning',
 449              'id'             => 'notice',
 450              'paragraph_wrap' => false,
 451          )
 452      );
 453  endif;
 454  if ( $message ) :
 455      wp_admin_notice(
 456          $message,
 457          array(
 458              'type'               => 'success',
 459              'dismissible'        => true,
 460              'id'                 => 'message',
 461              'additional_classes' => array( 'updated' ),
 462          )
 463      );
 464  endif;
 465  
 466  $connection_lost_message = sprintf(
 467      '<span class="spinner"></span> %1$s <span class="hide-if-no-sessionstorage">%2$s</span>',
 468      __( '<strong>Connection lost.</strong> Saving has been disabled until you are reconnected.' ),
 469      __( 'This post is being backed up in your browser, just in case.' )
 470  );
 471  
 472  wp_admin_notice(
 473      $connection_lost_message,
 474      array(
 475          'id'                 => 'lost-connection-notice',
 476          'additional_classes' => array( 'error', 'hidden' ),
 477      )
 478  );
 479  ?>
 480  <form name="post" action="post.php" method="post" id="post"
 481  <?php
 482  /**
 483   * Fires inside the post editor form tag.
 484   *
 485   * @since 3.0.0
 486   *
 487   * @param WP_Post $post Post object.
 488   */
 489  do_action( 'post_edit_form_tag', $post );
 490  
 491  $referer = wp_get_referer();
 492  ?>
 493  >
 494  <?php wp_nonce_field( $nonce_action ); ?>
 495  <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" />
 496  <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" />
 497  <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" />
 498  <input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
 499  <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
 500  <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
 501  <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
 502  <?php if ( ! empty( $active_post_lock ) ) { ?>
 503  <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
 504      <?php
 505  }
 506  if ( 'draft' !== get_post_status( $post ) ) {
 507      wp_original_referer_field( true, 'previous' );
 508  }
 509  
 510  echo $form_extra;
 511  
 512  wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
 513  wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
 514  ?>
 515  
 516  <?php
 517  /**
 518   * Fires at the beginning of the edit form.
 519   *
 520   * At this point, the required hidden fields and nonces have already been output.
 521   *
 522   * @since 3.7.0
 523   *
 524   * @param WP_Post $post Post object.
 525   */
 526  do_action( 'edit_form_top', $post );
 527  ?>
 528  
 529  <div id="poststuff">
 530  <div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
 531  <div id="post-body-content">
 532  
 533  <?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
 534  <div id="titlediv">
 535  <div id="titlewrap">
 536      <?php
 537      /**
 538       * Filters the title field placeholder text.
 539       *
 540       * @since 3.1.0
 541       *
 542       * @param string  $text Placeholder text. Default 'Add title'.
 543       * @param WP_Post $post Post object.
 544       */
 545      $title_placeholder = apply_filters( 'enter_title_here', __( 'Add title' ), $post );
 546      ?>
 547      <label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
 548      <input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
 549      <a href="#content" class="button-secondary screen-reader-text skiplink" onclick="if (tinymce) { tinymce.execCommand( 'mceFocus', false, 'content' ); }"><?php esc_html_e( 'Skip to Editor' ); ?></a>
 550  </div>
 551      <?php
 552      /**
 553       * Fires before the permalink field in the edit form.
 554       *
 555       * @since 4.1.0
 556       *
 557       * @param WP_Post $post Post object.
 558       */
 559      do_action( 'edit_form_before_permalink', $post );
 560      ?>
 561  <div class="inside">
 562      <?php
 563      if ( $viewable ) :
 564          $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
 565  
 566          // As of 4.4, the Get Shortlink button is hidden by default.
 567          if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
 568              $shortlink = wp_get_shortlink( $post->ID, 'post' );
 569  
 570              if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
 571                  $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
 572                      '<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
 573                      __( 'Get Shortlink' ) .
 574                      '</button>';
 575              }
 576          }
 577  
 578          if ( $post_type_object->public
 579              && ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
 580          ) {
 581              $has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
 582              ?>
 583      <div id="edit-slug-box" class="hide-if-no-js">
 584              <?php
 585              if ( $has_sample_permalink ) {
 586                  echo $sample_permalink_html;
 587              }
 588              ?>
 589      </div>
 590              <?php
 591          }
 592  endif;
 593      ?>
 594  </div>
 595      <?php
 596      wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
 597      ?>
 598  </div><!-- /titlediv -->
 599      <?php
 600  }
 601  /**
 602   * Fires after the title field.
 603   *
 604   * @since 3.5.0
 605   *
 606   * @param WP_Post $post Post object.
 607   */
 608  do_action( 'edit_form_after_title', $post );
 609  
 610  if ( post_type_supports( $post_type, 'editor' ) ) {
 611      $_wp_editor_expand_class = '';
 612      if ( $_wp_editor_expand ) {
 613          $_wp_editor_expand_class = ' wp-editor-expand';
 614      }
 615      ?>
 616  <div id="postdivrich" class="postarea<?php echo $_wp_editor_expand_class; ?>">
 617  
 618      <?php
 619      wp_editor(
 620          $post->post_content,
 621          'content',
 622          array(
 623              '_content_editor_dfw' => $_content_editor_dfw,
 624              'drag_drop_upload'    => true,
 625              'editor_height'       => 300,
 626              'tinymce'             => array(
 627                  'resize'                  => false,
 628                  'wp_autoresize_on'        => $_wp_editor_expand,
 629                  'add_unload_trigger'      => false,
 630              ),
 631          )
 632      );
 633      ?>
 634  <table id="post-status-info" role="presentation"><tbody><tr>
 635      <td id="wp-word-count" class="hide-if-no-js">
 636      <?php
 637      printf(
 638          /* translators: %s: Number of words. */
 639          __( 'Word count: %s' ),
 640          '<span class="word-count">0</span>'
 641      );
 642      ?>
 643      </td>
 644      <td class="autosave-info">
 645      <span class="autosave-message">&nbsp;</span>
 646      <?php
 647      if ( 'auto-draft' !== $post->post_status ) {
 648          echo '<span id="last-edit">';
 649          $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
 650          if ( $last_user ) {
 651              printf(
 652                  /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
 653                  __( 'Last edited by %1$s on %2$s at %3$s' ),
 654                  esc_html( $last_user->display_name ),
 655                  mysql2date( __( 'F j, Y' ), $post->post_modified ),
 656                  mysql2date( __( 'g:i a' ), $post->post_modified )
 657              );
 658          } else {
 659              printf(
 660                  /* translators: 1: Post edited date, 2: Post edited time. */
 661                  __( 'Last edited on %1$s at %2$s' ),
 662                  mysql2date( __( 'F j, Y' ), $post->post_modified ),
 663                  mysql2date( __( 'g:i a' ), $post->post_modified )
 664              );
 665          }
 666          echo '</span>';
 667      }
 668      ?>
 669      </td>
 670      <td id="content-resize-handle" class="hide-if-no-js"><br /></td>
 671  </tr></tbody></table>
 672  
 673  </div>
 674      <?php
 675  }
 676  /**
 677   * Fires after the content editor.
 678   *
 679   * @since 3.5.0
 680   *
 681   * @param WP_Post $post Post object.
 682   */
 683  do_action( 'edit_form_after_editor', $post );
 684  ?>
 685  </div><!-- /post-body-content -->
 686  
 687  <div id="postbox-container-1" class="postbox-container">
 688  <?php
 689  
 690  if ( 'page' === $post_type ) {
 691      /**
 692       * Fires before meta boxes with 'side' context are output for the 'page' post type.
 693       *
 694       * The submitpage box is a meta box with 'side' context, so this hook fires just before it is output.
 695       *
 696       * @since 2.5.0
 697       *
 698       * @param WP_Post $post Post object.
 699       */
 700      do_action( 'submitpage_box', $post );
 701  } else {
 702      /**
 703       * Fires before meta boxes with 'side' context are output for all post types other than 'page'.
 704       *
 705       * The submitpost box is a meta box with 'side' context, so this hook fires just before it is output.
 706       *
 707       * @since 2.5.0
 708       *
 709       * @param WP_Post $post Post object.
 710       */
 711      do_action( 'submitpost_box', $post );
 712  }
 713  
 714  
 715  do_meta_boxes( $post_type, 'side', $post );
 716  
 717  ?>
 718  </div>
 719  <div id="postbox-container-2" class="postbox-container">
 720  <?php
 721  
 722  do_meta_boxes( null, 'normal', $post );
 723  
 724  if ( 'page' === $post_type ) {
 725      /**
 726       * Fires after 'normal' context meta boxes have been output for the 'page' post type.
 727       *
 728       * @since 1.5.0
 729       *
 730       * @param WP_Post $post Post object.
 731       */
 732      do_action( 'edit_page_form', $post );
 733  } else {
 734      /**
 735       * Fires after 'normal' context meta boxes have been output for all post types other than 'page'.
 736       *
 737       * @since 1.5.0
 738       *
 739       * @param WP_Post $post Post object.
 740       */
 741      do_action( 'edit_form_advanced', $post );
 742  }
 743  
 744  
 745  do_meta_boxes( null, 'advanced', $post );
 746  
 747  ?>
 748  </div>
 749  <?php
 750  /**
 751   * Fires after all meta box sections have been output, before the closing #post-body div.
 752   *
 753   * @since 2.1.0
 754   *
 755   * @param WP_Post $post Post object.
 756   */
 757  do_action( 'dbx_post_sidebar', $post );
 758  
 759  ?>
 760  </div><!-- /post-body -->
 761  <br class="clear" />
 762  </div><!-- /poststuff -->
 763  </form>
 764  </div>
 765  
 766  <?php
 767  if ( post_type_supports( $post_type, 'comments' ) ) {
 768      wp_comment_reply();
 769  }
 770  ?>
 771  
 772  <?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>
 773  <script type="text/javascript">
 774  try{document.post.title.focus();}catch(e){}
 775  </script>
 776  <?php endif; ?>


Generated : Thu Oct 24 08:20:01 2024 Cross-referenced by PHPXref