wp/wp-admin/edit-form-advanced.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     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 
    13 
    14 /**
    14 /**
    15  * @global string       $post_type
    15  * @global string       $post_type
    16  * @global WP_Post_Type $post_type_object
    16  * @global WP_Post_Type $post_type_object
    17  * @global WP_Post      $post
    17  * @global WP_Post      $post             Global post object.
    18  */
    18  */
    19 global $post_type, $post_type_object, $post;
    19 global $post_type, $post_type_object, $post;
    20 
    20 
    21 // Flag that we're not loading the block editor.
    21 // Flag that we're not loading the block editor.
    22 $current_screen = get_current_screen();
    22 $current_screen = get_current_screen();
    38 
    38 
    39 	unset( $check_users );
    39 	unset( $check_users );
    40 }
    40 }
    41 
    41 
    42 wp_enqueue_script( 'post' );
    42 wp_enqueue_script( 'post' );
    43 $_wp_editor_expand = $_content_editor_dfw = false;
    43 
       
    44 $_wp_editor_expand   = false;
       
    45 $_content_editor_dfw = false;
    44 
    46 
    45 /**
    47 /**
    46  * Filters whether to enable the 'expand' functionality in the post editor.
    48  * Filters whether to enable the 'expand' functionality in the post editor.
    47  *
    49  *
    48  * @since 4.0.0
    50  * @since 4.0.0
    55 	! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) &&
    57 	! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) &&
    56 	apply_filters( 'wp_editor_expand', true, $post_type ) ) {
    58 	apply_filters( 'wp_editor_expand', true, $post_type ) ) {
    57 
    59 
    58 	wp_enqueue_script( 'editor-expand' );
    60 	wp_enqueue_script( 'editor-expand' );
    59 	$_content_editor_dfw = true;
    61 	$_content_editor_dfw = true;
    60 	$_wp_editor_expand   = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
    62 	$_wp_editor_expand   = ( 'on' === get_user_setting( 'editor_expand', 'on' ) );
    61 }
    63 }
    62 
    64 
    63 if ( wp_is_mobile() ) {
    65 if ( wp_is_mobile() ) {
    64 	wp_enqueue_script( 'jquery-touch-punch' );
    66 	wp_enqueue_script( 'jquery-touch-punch' );
    65 }
    67 }
    72  */
    74  */
    73 $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
    75 $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
    74 $user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
    76 $user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
    75 $action  = isset( $action ) ? $action : '';
    77 $action  = isset( $action ) ? $action : '';
    76 
    78 
    77 if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
    79 if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
    78 	add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
    80 	add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
    79 	remove_post_type_support( $post_type, 'editor' );
    81 	remove_post_type_support( $post_type, 'editor' );
    80 }
    82 }
    81 
    83 
    82 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
    84 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
    91 if ( $thumbnail_support ) {
    93 if ( $thumbnail_support ) {
    92 	add_thickbox();
    94 	add_thickbox();
    93 	wp_enqueue_media( array( 'post' => $post_ID ) );
    95 	wp_enqueue_media( array( 'post' => $post_ID ) );
    94 }
    96 }
    95 
    97 
    96 // Add the local autosave notice HTML
    98 // Add the local autosave notice HTML.
    97 add_action( 'admin_footer', '_local_storage_notice' );
    99 add_action( 'admin_footer', '_local_storage_notice' );
    98 
   100 
    99 /*
   101 /*
   100  * @todo Document the $messages array(s).
   102  * @todo Document the $messages array(s).
   101  */
   103  */
   104 	$permalink = '';
   106 	$permalink = '';
   105 }
   107 }
   106 
   108 
   107 $messages = array();
   109 $messages = array();
   108 
   110 
   109 $preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = '';
   111 $preview_post_link_html   = '';
   110 $preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = '';
   112 $scheduled_post_link_html = '';
       
   113 $view_post_link_html      = '';
       
   114 
       
   115 $preview_page_link_html   = '';
       
   116 $scheduled_page_link_html = '';
       
   117 $view_page_link_html      = '';
   111 
   118 
   112 $preview_url = get_preview_post_link( $post );
   119 $preview_url = get_preview_post_link( $post );
   113 
   120 
   114 $viewable = is_post_type_viewable( $post_type_object );
   121 $viewable = is_post_type_viewable( $post_type_object );
   115 
   122 
   157 		__( 'View page' )
   164 		__( 'View page' )
   158 	);
   165 	);
   159 
   166 
   160 }
   167 }
   161 
   168 
   162 /* translators: Publish box date format, see https://secure.php.net/date */
   169 $scheduled_date = sprintf(
   163 $scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) );
   170 	/* translators: Publish box date string. 1: Date, 2: Time. */
       
   171 	__( '%1$s at %2$s' ),
       
   172 	/* translators: Publish box date format, see https://www.php.net/date */
       
   173 	date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
       
   174 	/* translators: Publish box time format, see https://www.php.net/date */
       
   175 	date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
       
   176 );
   164 
   177 
   165 $messages['post']       = array(
   178 $messages['post']       = array(
   166 	0  => '', // Unused. Messages start at index 1.
   179 	0  => '', // Unused. Messages start at index 1.
   167 	1  => __( 'Post updated.' ) . $view_post_link_html,
   180 	1  => __( 'Post updated.' ) . $view_post_link_html,
   168 	2  => __( 'Custom field updated.' ),
   181 	2  => __( 'Custom field updated.' ),
   169 	3  => __( 'Custom field deleted.' ),
   182 	3  => __( 'Custom field deleted.' ),
   170 	4  => __( 'Post updated.' ),
   183 	4  => __( 'Post updated.' ),
   171 	/* translators: %s: date and time of the revision */
   184 	/* translators: %s: Date and time of the revision. */
   172 	5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   185 	5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   173 	6  => __( 'Post published.' ) . $view_post_link_html,
   186 	6  => __( 'Post published.' ) . $view_post_link_html,
   174 	7  => __( 'Post saved.' ),
   187 	7  => __( 'Post saved.' ),
   175 	8  => __( 'Post submitted.' ) . $preview_post_link_html,
   188 	8  => __( 'Post submitted.' ) . $preview_post_link_html,
       
   189 	/* translators: %s: Scheduled date for the post. */
   176 	9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
   190 	9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
   177 	10 => __( 'Post draft updated.' ) . $preview_post_link_html,
   191 	10 => __( 'Post draft updated.' ) . $preview_post_link_html,
   178 );
   192 );
   179 $messages['page']       = array(
   193 $messages['page']       = array(
   180 	0  => '', // Unused. Messages start at index 1.
   194 	0  => '', // Unused. Messages start at index 1.
   181 	1  => __( 'Page updated.' ) . $view_page_link_html,
   195 	1  => __( 'Page updated.' ) . $view_page_link_html,
   182 	2  => __( 'Custom field updated.' ),
   196 	2  => __( 'Custom field updated.' ),
   183 	3  => __( 'Custom field deleted.' ),
   197 	3  => __( 'Custom field deleted.' ),
   184 	4  => __( 'Page updated.' ),
   198 	4  => __( 'Page updated.' ),
   185 	/* translators: %s: date and time of the revision */
   199 	/* translators: %s: Date and time of the revision. */
   186 	5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   200 	5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   187 	6  => __( 'Page published.' ) . $view_page_link_html,
   201 	6  => __( 'Page published.' ) . $view_page_link_html,
   188 	7  => __( 'Page saved.' ),
   202 	7  => __( 'Page saved.' ),
   189 	8  => __( 'Page submitted.' ) . $preview_page_link_html,
   203 	8  => __( 'Page submitted.' ) . $preview_page_link_html,
       
   204 	/* translators: %s: Scheduled date for the page. */
   190 	9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
   205 	9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
   191 	10 => __( 'Page draft updated.' ) . $preview_page_link_html,
   206 	10 => __( 'Page draft updated.' ) . $preview_page_link_html,
   192 );
   207 );
   193 $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
   208 $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
   194 
   209 
   211 	}
   226 	}
   212 }
   227 }
   213 
   228 
   214 $notice     = false;
   229 $notice     = false;
   215 $form_extra = '';
   230 $form_extra = '';
   216 if ( 'auto-draft' == $post->post_status ) {
   231 if ( 'auto-draft' === $post->post_status ) {
   217 	if ( 'edit' == $action ) {
   232 	if ( 'edit' === $action ) {
   218 		$post->post_title = '';
   233 		$post->post_title = '';
   219 	}
   234 	}
   220 	$autosave    = false;
   235 	$autosave    = false;
   221 	$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
   236 	$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
   222 } else {
   237 } else {
   225 
   240 
   226 $form_action  = 'editpost';
   241 $form_action  = 'editpost';
   227 $nonce_action = 'update-post_' . $post_ID;
   242 $nonce_action = 'update-post_' . $post_ID;
   228 $form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
   243 $form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
   229 
   244 
   230 // Detect if there exists an autosave newer than the post and if that autosave is different than the post
   245 // Detect if there exists an autosave newer than the post and if that autosave is different than the post.
   231 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
   246 if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
   232 	foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
   247 	foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
   233 		if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
   248 		if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
   234 			$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 ) );
   249 			$notice = sprintf(
       
   250 				/* translators: %s: URL to view the autosave. */
       
   251 				__( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),
       
   252 				get_edit_post_link( $autosave->ID )
       
   253 			);
   235 			break;
   254 			break;
   236 		}
   255 		}
   237 	}
   256 	}
   238 	// If this autosave isn't different from the current post, begone.
   257 	// If this autosave isn't different from the current post, begone.
   239 	if ( ! $notice ) {
   258 	if ( ! $notice ) {
   243 }
   262 }
   244 
   263 
   245 $post_type_object = get_post_type_object( $post_type );
   264 $post_type_object = get_post_type_object( $post_type );
   246 
   265 
   247 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
   266 // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
   248 require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
   267 require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
   249 
   268 
   250 register_and_do_post_meta_boxes( $post );
   269 register_and_do_post_meta_boxes( $post );
   251 
   270 
   252 add_screen_option(
   271 add_screen_option(
   253 	'layout_columns',
   272 	'layout_columns',
   255 		'max'     => 2,
   274 		'max'     => 2,
   256 		'default' => 2,
   275 		'default' => 2,
   257 	)
   276 	)
   258 );
   277 );
   259 
   278 
   260 if ( 'post' == $post_type ) {
   279 if ( 'post' === $post_type ) {
   261 	$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>';
   280 	$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>';
   262 
   281 
   263 	get_current_screen()->add_help_tab(
   282 	get_current_screen()->add_help_tab(
   264 		array(
   283 		array(
   265 			'id'      => 'customize-display',
   284 			'id'      => 'customize-display',
   272 	$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>';
   291 	$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>';
   273 	$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>';
   292 	$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>';
   274 	$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>';
   293 	$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>';
   275 	$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>';
   294 	$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>';
   276 	$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>';
   295 	$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>';
   277 	$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>';
   296 	$title_and_editor .= '<p>' . sprintf(
       
   297 		/* translators: %s: Alt + F10 */
       
   298 		__( 'Keyboard users: When you&#8217;re working in the visual editor, you can use %s to access the toolbar.' ),
       
   299 		'<kbd>Alt + F10</kbd>'
       
   300 	) . '</p>';
   278 
   301 
   279 	get_current_screen()->add_help_tab(
   302 	get_current_screen()->add_help_tab(
   280 		array(
   303 		array(
   281 			'id'      => 'title-post-editor',
   304 			'id'      => 'title-post-editor',
   282 			'title'   => __( 'Title and Post Editor' ),
   305 			'title'   => __( 'Title and Post Editor' ),
   283 			'content' => $title_and_editor,
   306 			'content' => $title_and_editor,
   284 		)
   307 		)
   285 	);
   308 	);
   286 
   309 
   287 	get_current_screen()->set_help_sidebar(
   310 	get_current_screen()->set_help_sidebar(
   288 		'<p>' . sprintf( __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
   311 		'<p>' . sprintf(
       
   312 			/* translators: %s: URL to Press This bookmarklet. */
       
   313 			__( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ),
       
   314 			'tools.php'
       
   315 		) . '</p>' .
   289 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   316 			'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   290 			'<p>' . __( '<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
   317 			'<p>' . __( '<a href="https://wordpress.org/support/article/wordpress-editor/">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
   291 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   318 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   292 	);
   319 	);
   293 } elseif ( 'page' == $post_type ) {
   320 } elseif ( 'page' === $post_type ) {
   294 	$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>' .
   321 	$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>' .
   295 		'<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>';
   322 		'<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>';
   296 
   323 
   297 	get_current_screen()->add_help_tab(
   324 	get_current_screen()->add_help_tab(
   298 		array(
   325 		array(
   302 		)
   329 		)
   303 	);
   330 	);
   304 
   331 
   305 	get_current_screen()->set_help_sidebar(
   332 	get_current_screen()->set_help_sidebar(
   306 		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   333 		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   307 			'<p>' . __( '<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>' ) . '</p>' .
   334 			'<p>' . __( '<a href="https://wordpress.org/support/article/pages-add-new-screen/">Documentation on Adding New Pages</a>' ) . '</p>' .
   308 			'<p>' . __( '<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>' ) . '</p>' .
   335 			'<p>' . __( '<a href="https://wordpress.org/support/article/pages-screen/">Documentation on Editing Pages</a>' ) . '</p>' .
   309 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   336 			'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   310 	);
   337 	);
   311 } elseif ( 'attachment' == $post_type ) {
   338 } elseif ( 'attachment' === $post_type ) {
   312 	get_current_screen()->add_help_tab(
   339 	get_current_screen()->add_help_tab(
   313 		array(
   340 		array(
   314 			'id'      => 'overview',
   341 			'id'      => 'overview',
   315 			'title'   => __( 'Overview' ),
   342 			'title'   => __( 'Overview' ),
   316 			'content' =>
   343 			'content' =>
   317 				'<p>' . __( 'This screen allows you to edit four fields for metadata in a file within the media library.' ) . '</p>' .
   344 				'<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
   318 				'<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>' .
   345 				'<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>' .
   319 				'<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>' .
   346 				'<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>' .
   320 				'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
   347 				'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
   321 		)
   348 		)
   322 	);
   349 	);
   323 
   350 
   324 	get_current_screen()->set_help_sidebar(
   351 	get_current_screen()->set_help_sidebar(
   325 		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   352 		'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   326 		'<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>' ) . '</p>' .
   353 		'<p>' . __( '<a href="https://wordpress.org/support/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
   327 		'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   354 		'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   328 	);
   355 	);
   329 }
   356 }
   330 
   357 
   331 if ( 'post' == $post_type || 'page' == $post_type ) {
   358 if ( 'post' === $post_type || 'page' === $post_type ) {
   332 	$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>';
   359 	$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>';
   333 	$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. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.' ) . '</p>';
   360 	$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>';
   334 
   361 
   335 	get_current_screen()->add_help_tab(
   362 	get_current_screen()->add_help_tab(
   336 		array(
   363 		array(
   337 			'id'      => 'inserting-media',
   364 			'id'      => 'inserting-media',
   338 			'title'   => __( 'Inserting Media' ),
   365 			'title'   => __( 'Inserting Media' ),
   339 			'content' => $inserting_media,
   366 			'content' => $inserting_media,
   340 		)
   367 		)
   341 	);
   368 	);
   342 }
   369 }
   343 
   370 
   344 if ( 'post' == $post_type ) {
   371 if ( 'post' === $post_type ) {
   345 	$publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
   372 	$publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
   346 	$publish_box .= '<ul><li>' .
   373 	$publish_box .= '<ul><li>' .
   347 		__( '<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.' ) .
   374 		__( '<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.' ) .
   348 	'</li>';
   375 	'</li>';
   349 
   376 
   350 	if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
   377 	if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
   351 		$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>';
   378 		$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>';
   352 	}
   379 	}
   353 
   380 
   354 	if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
   381 	if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
   355 		/* translators: %s: Featured Image */
   382 		$publish_box .= '<li>' . sprintf(
   356 		$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>';
   383 			/* translators: %s: Featured image. */
       
   384 			__( '<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.' ),
       
   385 			esc_html( $post_type_object->labels->featured_image )
       
   386 		) . '</li>';
   357 	}
   387 	}
   358 
   388 
   359 	$publish_box .= '</ul>';
   389 	$publish_box .= '</ul>';
   360 
   390 
   361 	get_current_screen()->add_help_tab(
   391 	get_current_screen()->add_help_tab(
   374 			'id'      => 'discussion-settings',
   404 			'id'      => 'discussion-settings',
   375 			'title'   => __( 'Discussion Settings' ),
   405 			'title'   => __( 'Discussion Settings' ),
   376 			'content' => $discussion_settings,
   406 			'content' => $discussion_settings,
   377 		)
   407 		)
   378 	);
   408 	);
   379 } elseif ( 'page' == $post_type ) {
   409 } elseif ( 'page' === $post_type ) {
   380 	$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>' .
   410 	$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>' .
   381 		'<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>' .
   411 		'<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>' .
   382 		'<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>';
   412 		'<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>';
   383 
   413 
   384 	get_current_screen()->add_help_tab(
   414 	get_current_screen()->add_help_tab(
   388 			'content' => $page_attributes,
   418 			'content' => $page_attributes,
   389 		)
   419 		)
   390 	);
   420 	);
   391 }
   421 }
   392 
   422 
   393 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   423 require_once ABSPATH . 'wp-admin/admin-header.php';
   394 ?>
   424 ?>
   395 
   425 
   396 <div class="wrap">
   426 <div class="wrap">
   397 <h1 class="wp-heading-inline">
   427 <h1 class="wp-heading-inline">
   398 <?php
   428 <?php
   443 <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
   473 <input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
   444 <?php if ( ! empty( $active_post_lock ) ) { ?>
   474 <?php if ( ! empty( $active_post_lock ) ) { ?>
   445 <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
   475 <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
   446 	<?php
   476 	<?php
   447 }
   477 }
   448 if ( 'draft' != get_post_status( $post ) ) {
   478 if ( 'draft' !== get_post_status( $post ) ) {
   449 	wp_original_referer_field( true, 'previous' );
   479 	wp_original_referer_field( true, 'previous' );
   450 }
   480 }
   451 
   481 
   452 echo $form_extra;
   482 echo $form_extra;
   453 
   483 
   467  */
   497  */
   468 do_action( 'edit_form_top', $post );
   498 do_action( 'edit_form_top', $post );
   469 ?>
   499 ?>
   470 
   500 
   471 <div id="poststuff">
   501 <div id="poststuff">
   472 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
   502 <div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
   473 <div id="post-body-content">
   503 <div id="post-body-content">
   474 
   504 
   475 <?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
   505 <?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
   476 <div id="titlediv">
   506 <div id="titlediv">
   477 <div id="titlewrap">
   507 <div id="titlewrap">
   506 
   536 
   507 		// As of 4.4, the Get Shortlink button is hidden by default.
   537 		// As of 4.4, the Get Shortlink button is hidden by default.
   508 		if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
   538 		if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
   509 			$shortlink = wp_get_shortlink( $post->ID, 'post' );
   539 			$shortlink = wp_get_shortlink( $post->ID, 'post' );
   510 
   540 
   511 			if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
   541 			if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
   512 				$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>';
   542 				$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
       
   543 					'<button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' .
       
   544 					__( 'Get Shortlink' ) .
       
   545 					'</button>';
   513 			}
   546 			}
   514 		}
   547 		}
   515 
   548 
   516 		if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
   549 		if ( $post_type_object->public
   517 			$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
   550 			&& ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
       
   551 		) {
       
   552 			$has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
   518 			?>
   553 			?>
   519 	<div id="edit-slug-box" class="hide-if-no-js">
   554 	<div id="edit-slug-box" class="hide-if-no-js">
   520 			<?php
   555 			<?php
   521 			if ( $has_sample_permalink ) {
   556 			if ( $has_sample_permalink ) {
   522 				echo $sample_permalink_html;
   557 				echo $sample_permalink_html;
   568 			),
   603 			),
   569 		)
   604 		)
   570 	);
   605 	);
   571 	?>
   606 	?>
   572 <table id="post-status-info"><tbody><tr>
   607 <table id="post-status-info"><tbody><tr>
   573 	<td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
   608 	<td id="wp-word-count" class="hide-if-no-js">
       
   609 	<?php
       
   610 	printf(
       
   611 		/* translators: %s: Number of words. */
       
   612 		__( 'Word count: %s' ),
       
   613 		'<span class="word-count">0</span>'
       
   614 	);
       
   615 	?>
       
   616 	</td>
   574 	<td class="autosave-info">
   617 	<td class="autosave-info">
   575 	<span class="autosave-message">&nbsp;</span>
   618 	<span class="autosave-message">&nbsp;</span>
   576 	<?php
   619 	<?php
   577 	if ( 'auto-draft' != $post->post_status ) {
   620 	if ( 'auto-draft' !== $post->post_status ) {
   578 		echo '<span id="last-edit">';
   621 		echo '<span id="last-edit">';
   579 		if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
   622 		$last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
   580 			/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
   623 		if ( $last_user ) {
       
   624 			/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
   581 			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 ) );
   625 			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 ) );
   582 		} else {
   626 		} else {
   583 			/* translators: 1: Post edited date, 2: Post edited time */
   627 			/* translators: 1: Post edited date, 2: Post edited time. */
   584 			printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
   628 			printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
   585 		}
   629 		}
   586 		echo '</span>';
   630 		echo '</span>';
   587 	}
   631 	}
   588 	?>
   632 	?>
   605 </div><!-- /post-body-content -->
   649 </div><!-- /post-body-content -->
   606 
   650 
   607 <div id="postbox-container-1" class="postbox-container">
   651 <div id="postbox-container-1" class="postbox-container">
   608 <?php
   652 <?php
   609 
   653 
   610 if ( 'page' == $post_type ) {
   654 if ( 'page' === $post_type ) {
   611 	/**
   655 	/**
   612 	 * Fires before meta boxes with 'side' context are output for the 'page' post type.
   656 	 * Fires before meta boxes with 'side' context are output for the 'page' post type.
   613 	 *
   657 	 *
   614 	 * The submitpage box is a meta box with 'side' context, so this hook fires just before it is output.
   658 	 * The submitpage box is a meta box with 'side' context, so this hook fires just before it is output.
   615 	 *
   659 	 *
   639 <div id="postbox-container-2" class="postbox-container">
   683 <div id="postbox-container-2" class="postbox-container">
   640 <?php
   684 <?php
   641 
   685 
   642 do_meta_boxes( null, 'normal', $post );
   686 do_meta_boxes( null, 'normal', $post );
   643 
   687 
   644 if ( 'page' == $post_type ) {
   688 if ( 'page' === $post_type ) {
   645 	/**
   689 	/**
   646 	 * Fires after 'normal' context meta boxes have been output for the 'page' post type.
   690 	 * Fires after 'normal' context meta boxes have been output for the 'page' post type.
   647 	 *
   691 	 *
   648 	 * @since 1.5.0
   692 	 * @since 1.5.0
   649 	 *
   693 	 *