wp/wp-admin/edit-form-advanced.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8 
     8 
     9 // don't load directly
     9 // don't load directly
    10 if ( !defined('ABSPATH') )
    10 if ( !defined('ABSPATH') )
    11 	die('-1');
    11 	die('-1');
    12 
    12 
       
    13 /**
       
    14  * @global string       $post_type
       
    15  * @global WP_Post_Type $post_type_object
       
    16  * @global WP_Post      $post
       
    17  */
    13 global $post_type, $post_type_object, $post;
    18 global $post_type, $post_type_object, $post;
       
    19 
       
    20 if ( is_multisite() ) {
       
    21 	add_action( 'admin_footer', '_admin_notice_post_locked' );
       
    22 } else {
       
    23 	$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
       
    24 
       
    25 	if ( count( $check_users ) > 1 )
       
    26 		add_action( 'admin_footer', '_admin_notice_post_locked' );
       
    27 
       
    28 	unset( $check_users );
       
    29 }
    14 
    30 
    15 wp_enqueue_script('post');
    31 wp_enqueue_script('post');
    16 $_wp_editor_expand = $_content_editor_dfw = false;
    32 $_wp_editor_expand = $_content_editor_dfw = false;
    17 
    33 
    18 /**
    34 /**
    19  * Filter whether to enable the 'expand' functionality in the post editor.
    35  * Filters whether to enable the 'expand' functionality in the post editor.
    20  *
    36  *
    21  * @since 4.0.0
    37  * @since 4.0.0
    22  * @since 4.1.0 Added the `$post_type` parameter.
    38  * @since 4.1.0 Added the `$post_type` parameter.
    23  *
    39  *
    24  * @param bool   $expand    Whether to enable the 'expand' functionality. Default true.
    40  * @param bool   $expand    Whether to enable the 'expand' functionality. Default true.
    74 if ( ! $permalink ) {
    90 if ( ! $permalink ) {
    75 	$permalink = '';
    91 	$permalink = '';
    76 }
    92 }
    77 
    93 
    78 $messages = array();
    94 $messages = array();
       
    95 
       
    96 $preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = '';
       
    97 $preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = '';
       
    98 
       
    99 $preview_url = get_preview_post_link( $post );
       
   100 
       
   101 $viewable = is_post_type_viewable( $post_type_object );
       
   102 
       
   103 if ( $viewable ) {
       
   104 
       
   105 	// Preview post link.
       
   106 	$preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
       
   107 		esc_url( $preview_url ),
       
   108 		__( 'Preview post' )
       
   109 	);
       
   110 
       
   111 	// Scheduled post preview link.
       
   112 	$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
       
   113 		esc_url( $permalink ),
       
   114 		__( 'Preview post' )
       
   115 	);
       
   116 
       
   117 	// View post link.
       
   118 	$view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
       
   119 		esc_url( $permalink ),
       
   120 		__( 'View post' )
       
   121 	);
       
   122 
       
   123 	// Preview page link.
       
   124 	$preview_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
       
   125 		esc_url( $preview_url ),
       
   126 		__( 'Preview page' )
       
   127 	);
       
   128 
       
   129 	// Scheduled page preview link.
       
   130 	$scheduled_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
       
   131 		esc_url( $permalink ),
       
   132 		__( 'Preview page' )
       
   133 	);
       
   134 
       
   135 	// View page link.
       
   136 	$view_page_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
       
   137 		esc_url( $permalink ),
       
   138 		__( 'View page' )
       
   139 	);
       
   140 
       
   141 }
       
   142 
       
   143 /* translators: Publish box date format, see https://secure.php.net/date */
       
   144 $scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) );
       
   145 
    79 $messages['post'] = array(
   146 $messages['post'] = array(
    80 	 0 => '', // Unused. Messages start at index 1.
   147 	 0 => '', // Unused. Messages start at index 1.
    81 	 1 => sprintf( __('Post updated. <a href="%s">View post</a>'), esc_url( $permalink ) ),
   148 	 1 => __( 'Post updated.' ) . $view_post_link_html,
    82 	 2 => __('Custom field updated.'),
   149 	 2 => __( 'Custom field updated.' ),
    83 	 3 => __('Custom field deleted.'),
   150 	 3 => __( 'Custom field deleted.' ),
    84 	 4 => __('Post updated.'),
   151 	 4 => __( 'Post updated.' ),
    85 	/* translators: %s: date and time of the revision */
   152 	/* translators: %s: date and time of the revision */
    86 	 5 => isset($_GET['revision']) ? sprintf( __('Post restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   153 	 5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    87 	 6 => sprintf( __('Post published. <a href="%s">View post</a>'), esc_url( $permalink ) ),
   154 	 6 => __( 'Post published.' ) . $view_post_link_html,
    88 	 7 => __('Post saved.'),
   155 	 7 => __( 'Post saved.' ),
    89 	 8 => sprintf( __('Post submitted. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
   156 	 8 => __( 'Post submitted.' ) . $preview_post_link_html,
    90 	 9 => sprintf( __('Post scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview post</a>'),
   157 	 9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
    91 		/* translators: Publish box date format, see http://php.net/date */
   158 	10 => __( 'Post draft updated.' ) . $preview_post_link_html,
    92 		date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
       
    93 	10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
       
    94 );
   159 );
    95 $messages['page'] = array(
   160 $messages['page'] = array(
    96 	 0 => '', // Unused. Messages start at index 1.
   161 	 0 => '', // Unused. Messages start at index 1.
    97 	 1 => sprintf( __('Page updated. <a href="%s">View page</a>'), esc_url( $permalink ) ),
   162 	 1 => __( 'Page updated.' ) . $view_page_link_html,
    98 	 2 => __('Custom field updated.'),
   163 	 2 => __( 'Custom field updated.' ),
    99 	 3 => __('Custom field deleted.'),
   164 	 3 => __( 'Custom field deleted.' ),
   100 	 4 => __('Page updated.'),
   165 	 4 => __( 'Page updated.' ),
   101 	 5 => isset($_GET['revision']) ? sprintf( __('Page restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   166 	/* translators: %s: date and time of the revision */
   102 	 6 => sprintf( __('Page published. <a href="%s">View page</a>'), esc_url( $permalink ) ),
   167 	 5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   103 	 7 => __('Page saved.'),
   168 	 6 => __( 'Page published.' ) . $view_page_link_html,
   104 	 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
   169 	 7 => __( 'Page saved.' ),
   105 	 9 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) ), esc_url( $permalink ) ),
   170 	 8 => __( 'Page submitted.' ) . $preview_page_link_html,
   106 	10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),
   171 	 9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
       
   172 	10 => __( 'Page draft updated.' ) . $preview_page_link_html,
   107 );
   173 );
   108 $messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated.' ) ); // Hack, for now.
   174 $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
   109 
   175 
   110 /**
   176 /**
   111  * Filter the post updated messages.
   177  * Filters the post updated messages.
   112  *
   178  *
   113  * @since 3.0.0
   179  * @since 3.0.0
   114  *
   180  *
   115  * @param array $messages Post updated messages. For defaults @see $messages declarations above.
   181  * @param array $messages Post updated messages. For defaults @see $messages declarations above.
   116  */
   182  */
   140 $nonce_action = 'update-post_' . $post_ID;
   206 $nonce_action = 'update-post_' . $post_ID;
   141 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
   207 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
   142 
   208 
   143 // Detect if there exists an autosave newer than the post and if that autosave is different than the post
   209 // Detect if there exists an autosave newer than the post and if that autosave is different than the post
   144 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
   210 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
   145 	foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
   211 	foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
   146 		if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
   212 		if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
   147 			$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
   213 			$notice = sprintf( __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ), get_edit_post_link( $autosave->ID ) );
   148 			break;
   214 			break;
   149 		}
   215 		}
   150 	}
   216 	}
   162 
   228 
   163 $publish_callback_args = null;
   229 $publish_callback_args = null;
   164 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
   230 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
   165 	$revisions = wp_get_post_revisions( $post_ID );
   231 	$revisions = wp_get_post_revisions( $post_ID );
   166 
   232 
   167 	// We should aim to show the revisions metabox only when there are revisions.
   233 	// We should aim to show the revisions meta box only when there are revisions.
   168 	if ( count( $revisions ) > 1 ) {
   234 	if ( count( $revisions ) > 1 ) {
   169 		reset( $revisions ); // Reset pointer for key()
   235 		reset( $revisions ); // Reset pointer for key()
   170 		$publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
   236 		$publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
   171 		add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
   237 		add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
   172 	}
   238 	}
   202 		$tax_meta_box_id = $tax_name . 'div';
   268 		$tax_meta_box_id = $tax_name . 'div';
   203 
   269 
   204 	add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
   270 	add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
   205 }
   271 }
   206 
   272 
   207 if ( post_type_supports($post_type, 'page-attributes') )
   273 if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) {
   208 	add_meta_box('pageparentdiv', 'page' == $post_type ? __('Page Attributes') : __('Attributes'), 'page_attributes_meta_box', null, 'side', 'core');
   274 	add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' );
       
   275 }
   209 
   276 
   210 if ( $thumbnail_support && current_user_can( 'upload_files' ) )
   277 if ( $thumbnail_support && current_user_can( 'upload_files' ) )
   211 	add_meta_box('postimagediv', __('Featured Image'), 'post_thumbnail_meta_box', null, 'side', 'low');
   278 	add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low');
   212 
   279 
   213 if ( post_type_supports($post_type, 'excerpt') )
   280 if ( post_type_supports($post_type, 'excerpt') )
   214 	add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
   281 	add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
   215 
   282 
   216 if ( post_type_supports($post_type, 'trackbacks') )
   283 if ( post_type_supports($post_type, 'trackbacks') )
   227  *
   294  *
   228  * @param WP_Post $post Post object.
   295  * @param WP_Post $post Post object.
   229  */
   296  */
   230 do_action( 'dbx_post_advanced', $post );
   297 do_action( 'dbx_post_advanced', $post );
   231 
   298 
   232 if ( post_type_supports($post_type, 'comments') )
   299 // Allow the Discussion meta box to show up if the post type supports comments,
   233 	add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core');
   300 // or if comments or pings are open.
   234 
   301 if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
   235 if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
   302 	add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core' );
   236 	add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
   303 }
       
   304 
       
   305 $stati = get_post_stati( array( 'public' => true ) );
       
   306 if ( empty( $stati ) ) {
       
   307 	$stati = array( 'publish' );
       
   308 }
       
   309 $stati[] = 'private';
       
   310 
       
   311 if ( in_array( get_post_status( $post ), $stati ) ) {
       
   312 	// If the post type support comments, or the post has comments, allow the
       
   313 	// Comments meta box.
       
   314 	if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
       
   315 		add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core' );
       
   316 	}
       
   317 }
   237 
   318 
   238 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
   319 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
   239 	add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
   320 	add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
   240 
   321 
   241 if ( post_type_supports($post_type, 'author') ) {
   322 if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
   242 	if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) )
   323 	add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core' );
   243 		add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
       
   244 }
   324 }
   245 
   325 
   246 /**
   326 /**
   247  * Fires after all built-in meta boxes have been added.
   327  * Fires after all built-in meta boxes have been added.
   248  *
   328  *
   260  *
   340  *
   261  * @since 3.0.0
   341  * @since 3.0.0
   262  *
   342  *
   263  * @param WP_Post $post Post object.
   343  * @param WP_Post $post Post object.
   264  */
   344  */
   265 do_action( 'add_meta_boxes_' . $post_type, $post );
   345 do_action( "add_meta_boxes_{$post_type}", $post );
   266 
   346 
   267 /**
   347 /**
   268  * Fires after meta boxes have been added.
   348  * Fires after meta boxes have been added.
   269  *
   349  *
   270  * Fires once for each of the default meta box contexts: normal, advanced, and side.
   350  * Fires once for each of the default meta box contexts: normal, advanced, and side.
   290 		'id'      => 'customize-display',
   370 		'id'      => 'customize-display',
   291 		'title'   => __('Customizing This Display'),
   371 		'title'   => __('Customizing This Display'),
   292 		'content' => $customize_display,
   372 		'content' => $customize_display,
   293 	) );
   373 	) );
   294 
   374 
   295 	$title_and_editor  = '<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
   375 	$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>';
   296 	$title_and_editor .= '<p>' . __( '<strong>Post editor</strong> - 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>';
   376 	$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>';
   297 	$title_and_editor .= '<p>' . __( 'Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. ') . '</p>';
   377 	$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>';
   298 	$title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Line breaks will be converted to paragraphs automatically.' ) . '</p>';
   378 	$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>';
   299 	$title_and_editor .= '<p>' . __( 'You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>';
   379 	$title_and_editor .= '<p>' . __( 'You can insert media files by clicking the icons above the post editor and following the directions. You can align or edit images using the inline formatting toolbar available in Visual mode.' ) . '</p>';
   300 	$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>';
   380 	$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>';
   301 	$title_and_editor .= '<p>' . __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
   381 	$title_and_editor .= '<p>' . __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
   302 
   382 
   303 	get_current_screen()->add_help_tab( array(
   383 	get_current_screen()->add_help_tab( array(
   305 		'title'   => __('Title and Post Editor'),
   385 		'title'   => __('Title and Post Editor'),
   306 		'content' => $title_and_editor,
   386 		'content' => $title_and_editor,
   307 	) );
   387 	) );
   308 
   388 
   309 	get_current_screen()->set_help_sidebar(
   389 	get_current_screen()->set_help_sidebar(
   310 			'<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'options-writing.php') . '</p>' .
   390 			'<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'tools.php') . '</p>' .
   311 			'<p><strong>' . __('For more information:') . '</strong></p>' .
   391 			'<p><strong>' . __('For more information:') . '</strong></p>' .
   312 			'<p>' . __('<a href="https://codex.wordpress.org/Posts_Add_New_Screen" target="_blank">Documentation on Writing and Editing Posts</a>') . '</p>' .
   392 			'<p>' . __('<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>') . '</p>' .
   313 			'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   393 			'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
   314 	);
   394 	);
   315 } elseif ( 'page' == $post_type ) {
   395 } elseif ( 'page' == $post_type ) {
   316 	$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>' .
   396 	$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>' .
   317 		'<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>';
   397 		'<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>';
   318 
   398 
   319 	get_current_screen()->add_help_tab( array(
   399 	get_current_screen()->add_help_tab( array(
   320 		'id'      => 'about-pages',
   400 		'id'      => 'about-pages',
   321 		'title'   => __('About Pages'),
   401 		'title'   => __('About Pages'),
   322 		'content' => $about_pages,
   402 		'content' => $about_pages,
   323 	) );
   403 	) );
   324 
   404 
   325 	get_current_screen()->set_help_sidebar(
   405 	get_current_screen()->set_help_sidebar(
   326 			'<p><strong>' . __('For more information:') . '</strong></p>' .
   406 			'<p><strong>' . __('For more information:') . '</strong></p>' .
   327 			'<p>' . __('<a href="https://codex.wordpress.org/Pages_Add_New_Screen" target="_blank">Documentation on Adding New Pages</a>') . '</p>' .
   407 			'<p>' . __('<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>') . '</p>' .
   328 			'<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages" target="_blank">Documentation on Editing Pages</a>') . '</p>' .
   408 			'<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>') . '</p>' .
   329 			'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   409 			'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
   330 	);
   410 	);
   331 } elseif ( 'attachment' == $post_type ) {
   411 } elseif ( 'attachment' == $post_type ) {
   332 	get_current_screen()->add_help_tab( array(
   412 	get_current_screen()->add_help_tab( array(
   333 		'id'      => 'overview',
   413 		'id'      => 'overview',
   334 		'title'   => __('Overview'),
   414 		'title'   => __('Overview'),
   339 			'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
   419 			'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
   340 	) );
   420 	) );
   341 
   421 
   342 	get_current_screen()->set_help_sidebar(
   422 	get_current_screen()->set_help_sidebar(
   343 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   423 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   344 	'<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media" target="_blank">Documentation on Edit Media</a>') . '</p>' .
   424 	'<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>') . '</p>' .
   345 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   425 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
   346 	);
   426 	);
   347 }
   427 }
   348 
   428 
   349 if ( 'post' == $post_type || 'page' == $post_type ) {
   429 if ( 'post' == $post_type || 'page' == $post_type ) {
   350 	$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>';
   430 	$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>';
   357 	) );
   437 	) );
   358 }
   438 }
   359 
   439 
   360 if ( 'post' == $post_type ) {
   440 if ( 'post' == $post_type ) {
   361 	$publish_box = '<p>' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '</p>';
   441 	$publish_box = '<p>' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '</p>';
   362 	$publish_box .= '<ul><li>' . __('<strong>Publish</strong> - 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). 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.') . '</li>';
   442 	$publish_box .= '<ul><li>' .
       
   443 		__( '<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.' ) .
       
   444 	'</li>';
   363 
   445 
   364 	if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
   446 	if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
   365 		$publish_box .= '<li>' . __( '<strong>Format</strong> - 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. Please refer to the Codex for <a href="https://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</li>';
   447 		$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. Please refer to the Codex for <a href="https://codex.wordpress.org/Post_Formats#Supported_Formats">descriptions of each post format</a>. Your theme could enable all or some of 10 possible formats.' ) . '</li>';
   366 	}
   448 	}
   367 
   449 
   368 	if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
   450 	if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
   369 		$publish_box .= '<li>' . __('<strong>Featured Image</strong> - 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 featured image as a post thumbnail on the home page, a custom header, etc.') . '</li>';
   451 		/* translators: %s: Featured Image */
       
   452 		$publish_box .= '<li>' . sprintf( __( '<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.' ), esc_html( $post_type_object->labels->featured_image ) ) . '</li>';
   370 	}
   453 	}
   371 
   454 
   372 	$publish_box .= '</ul>';
   455 	$publish_box .= '</ul>';
   373 
   456 
   374 	get_current_screen()->add_help_tab( array(
   457 	get_current_screen()->add_help_tab( array(
   375 		'id'      => 'publish-box',
   458 		'id'      => 'publish-box',
   376 		'title'   => __('Publish Settings'),
   459 		'title'   => __('Publish Settings'),
   377 		'content' => $publish_box,
   460 		'content' => $publish_box,
   378 	) );
   461 	) );
   379 
   462 
   380 	$discussion_settings  = '<p>' . __('<strong>Send Trackbacks</strong> - 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>';
   463 	$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>';
   381 	$discussion_settings .= '<p>' . __('<strong>Discussion</strong> - 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>';
   464 	$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>';
   382 
   465 
   383 	get_current_screen()->add_help_tab( array(
   466 	get_current_screen()->add_help_tab( array(
   384 		'id'      => 'discussion-settings',
   467 		'id'      => 'discussion-settings',
   385 		'title'   => __('Discussion Settings'),
   468 		'title'   => __('Discussion Settings'),
   386 		'content' => $discussion_settings,
   469 		'content' => $discussion_settings,
   387 	) );
   470 	) );
   388 } elseif ( 'page' == $post_type ) {
   471 } elseif ( 'page' == $post_type ) {
   389 	$page_attributes = '<p>' . __('<strong>Parent</strong> - 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>' .
   472 	$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>' .
   390 		'<p>' . __('<strong>Template</strong> - 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>' .
   473 		'<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>' .
   391 		'<p>' . __('<strong>Order</strong> - Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>';
   474 		'<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>';
   392 
   475 
   393 	get_current_screen()->add_help_tab( array(
   476 	get_current_screen()->add_help_tab( array(
   394 		'id' => 'page-attributes',
   477 		'id' => 'page-attributes',
   395 		'title' => __('Page Attributes'),
   478 		'title' => __('Page Attributes'),
   396 		'content' => $page_attributes,
   479 		'content' => $page_attributes,
   399 
   482 
   400 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   483 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   401 ?>
   484 ?>
   402 
   485 
   403 <div class="wrap">
   486 <div class="wrap">
   404 <h2><?php
   487 <h1 class="wp-heading-inline"><?php
   405 echo esc_html( $title );
   488 echo esc_html( $title );
   406 if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) )
   489 ?></h1>
   407 	echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="add-new-h2">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
   490 
   408 ?></h2>
   491 <?php
       
   492 if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) {
       
   493 	echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
       
   494 }
       
   495 ?>
       
   496 
       
   497 <hr class="wp-header-end">
       
   498 
   409 <?php if ( $notice ) : ?>
   499 <?php if ( $notice ) : ?>
   410 <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div>
   500 <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div>
   411 <?php endif; ?>
   501 <?php endif; ?>
   412 <?php if ( $message ) : ?>
   502 <?php if ( $message ) : ?>
   413 <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
   503 <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
   469 <?php if ( post_type_supports($post_type, 'title') ) { ?>
   559 <?php if ( post_type_supports($post_type, 'title') ) { ?>
   470 <div id="titlediv">
   560 <div id="titlediv">
   471 <div id="titlewrap">
   561 <div id="titlewrap">
   472 	<?php
   562 	<?php
   473 	/**
   563 	/**
   474 	 * Filter the title field placeholder text.
   564 	 * Filters the title field placeholder text.
   475 	 *
   565 	 *
   476 	 * @since 3.1.0
   566 	 * @since 3.1.0
   477 	 *
   567 	 *
   478 	 * @param string  $text Placeholder text. Default 'Enter title here'.
   568 	 * @param string  $text Placeholder text. Default 'Enter title here'.
   479 	 * @param WP_Post $post Post object.
   569 	 * @param WP_Post $post Post object.
   480 	 */
   570 	 */
   481 	$title_placeholder = apply_filters( 'enter_title_here', __( 'Enter title here' ), $post );
   571 	$title_placeholder = apply_filters( 'enter_title_here', __( 'Enter title here' ), $post );
   482 	?>
   572 	?>
   483 	<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
   573 	<label class="screen-reader-text" id="title-prompt-text" for="title"><?php echo $title_placeholder; ?></label>
   484 	<input type="text" name="post_title" size="30" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" spellcheck="true" autocomplete="off" />
   574 	<input type="text" name="post_title" size="30" value="<?php echo esc_attr( $post->post_title ); ?>" id="title" spellcheck="true" autocomplete="off" />
   485 </div>
   575 </div>
   486 <?php
   576 <?php
   487 /**
   577 /**
   488  * Fires before the permalink field in the edit form.
   578  * Fires before the permalink field in the edit form.
   489  *
   579  *
   493  */
   583  */
   494 do_action( 'edit_form_before_permalink', $post );
   584 do_action( 'edit_form_before_permalink', $post );
   495 ?>
   585 ?>
   496 <div class="inside">
   586 <div class="inside">
   497 <?php
   587 <?php
       
   588 if ( $viewable ) :
   498 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
   589 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
   499 $shortlink = wp_get_shortlink($post->ID, 'post');
   590 
   500 
   591 // As of 4.4, the Get Shortlink button is hidden by default.
   501 if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) )
   592 if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
   502     $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
   593 	$shortlink = wp_get_shortlink($post->ID, 'post');
       
   594 
       
   595 	if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) {
       
   596 		$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
       
   597 	}
       
   598 }
   503 
   599 
   504 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
   600 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
   505 	$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
   601 	$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
   506 ?>
   602 ?>
   507 	<div id="edit-slug-box" class="hide-if-no-js">
   603 	<div id="edit-slug-box" class="hide-if-no-js">
   510 			echo $sample_permalink_html;
   606 			echo $sample_permalink_html;
   511 	?>
   607 	?>
   512 	</div>
   608 	</div>
   513 <?php
   609 <?php
   514 }
   610 }
       
   611 endif;
   515 ?>
   612 ?>
   516 </div>
   613 </div>
   517 <?php
   614 <?php
   518 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
   615 wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
   519 ?>
   616 ?>
   540 	'editor_height' => 300,
   637 	'editor_height' => 300,
   541 	'tinymce' => array(
   638 	'tinymce' => array(
   542 		'resize' => false,
   639 		'resize' => false,
   543 		'wp_autoresize_on' => $_wp_editor_expand,
   640 		'wp_autoresize_on' => $_wp_editor_expand,
   544 		'add_unload_trigger' => false,
   641 		'add_unload_trigger' => false,
       
   642 		'wp_keep_scroll_position' => ! $is_IE,
   545 	),
   643 	),
   546 ) ); ?>
   644 ) ); ?>
   547 <table id="post-status-info"><tbody><tr>
   645 <table id="post-status-info"><tbody><tr>
   548 	<td id="wp-word-count"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
   646 	<td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
   549 	<td class="autosave-info">
   647 	<td class="autosave-info">
   550 	<span class="autosave-message">&nbsp;</span>
   648 	<span class="autosave-message">&nbsp;</span>
   551 <?php
   649 <?php
   552 	if ( 'auto-draft' != $post->post_status ) {
   650 	if ( 'auto-draft' != $post->post_status ) {
   553 		echo '<span id="last-edit">';
   651 		echo '<span id="last-edit">';
   554 		if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
   652 		if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
   555 			printf(__('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
   653 			/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
       
   654 			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 ) );
   556 		} else {
   655 		} else {
   557 			printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
   656 			/* translators: 1: Post edited date, 2: Post edited time */
       
   657 			printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
   558 		}
   658 		}
   559 		echo '</span>';
   659 		echo '</span>';
   560 	} ?>
   660 	} ?>
   561 	</td>
   661 	</td>
   562 	<td id="content-resize-handle" class="hide-if-no-js"><br /></td>
   662 	<td id="content-resize-handle" class="hide-if-no-js"><br /></td>