--- a/wp/wp-admin/edit-form-advanced.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/edit-form-advanced.php Tue Dec 15 13:49:49 2020 +0100
@@ -6,7 +6,7 @@
* @subpackage Administration
*/
-// don't load directly
+// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
@@ -14,7 +14,7 @@
/**
* @global string $post_type
* @global WP_Post_Type $post_type_object
- * @global WP_Post $post
+ * @global WP_Post $post Global post object.
*/
global $post_type, $post_type_object, $post;
@@ -40,7 +40,9 @@
}
wp_enqueue_script( 'post' );
-$_wp_editor_expand = $_content_editor_dfw = false;
+
+$_wp_editor_expand = false;
+$_content_editor_dfw = false;
/**
* Filters whether to enable the 'expand' functionality in the post editor.
@@ -57,7 +59,7 @@
wp_enqueue_script( 'editor-expand' );
$_content_editor_dfw = true;
- $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
+ $_wp_editor_expand = ( 'on' === get_user_setting( 'editor_expand', 'on' ) );
}
if ( wp_is_mobile() ) {
@@ -74,7 +76,7 @@
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
$action = isset( $action ) ? $action : '';
-if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
+if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
remove_post_type_support( $post_type, 'editor' );
}
@@ -93,7 +95,7 @@
wp_enqueue_media( array( 'post' => $post_ID ) );
}
-// Add the local autosave notice HTML
+// Add the local autosave notice HTML.
add_action( 'admin_footer', '_local_storage_notice' );
/*
@@ -106,8 +108,13 @@
$messages = array();
-$preview_post_link_html = $scheduled_post_link_html = $view_post_link_html = '';
-$preview_page_link_html = $scheduled_page_link_html = $view_page_link_html = '';
+$preview_post_link_html = '';
+$scheduled_post_link_html = '';
+$view_post_link_html = '';
+
+$preview_page_link_html = '';
+$scheduled_page_link_html = '';
+$view_page_link_html = '';
$preview_url = get_preview_post_link( $post );
@@ -159,8 +166,14 @@
}
-/* translators: Publish box date format, see https://secure.php.net/date */
-$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) );
+$scheduled_date = sprintf(
+ /* translators: Publish box date string. 1: Date, 2: Time. */
+ __( '%1$s at %2$s' ),
+ /* translators: Publish box date format, see https://www.php.net/date */
+ date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ),
+ /* translators: Publish box time format, see https://www.php.net/date */
+ date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) )
+);
$messages['post'] = array(
0 => '', // Unused. Messages start at index 1.
@@ -168,11 +181,12 @@
2 => __( 'Custom field updated.' ),
3 => __( 'Custom field deleted.' ),
4 => __( 'Post updated.' ),
- /* translators: %s: date and time of the revision */
+ /* translators: %s: Date and time of the revision. */
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Post published.' ) . $view_post_link_html,
7 => __( 'Post saved.' ),
8 => __( 'Post submitted.' ) . $preview_post_link_html,
+ /* translators: %s: Scheduled date for the post. */
9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
10 => __( 'Post draft updated.' ) . $preview_post_link_html,
);
@@ -182,11 +196,12 @@
2 => __( 'Custom field updated.' ),
3 => __( 'Custom field deleted.' ),
4 => __( 'Page updated.' ),
- /* translators: %s: date and time of the revision */
+ /* translators: %s: Date and time of the revision. */
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Page published.' ) . $view_page_link_html,
7 => __( 'Page saved.' ),
8 => __( 'Page submitted.' ) . $preview_page_link_html,
+ /* translators: %s: Scheduled date for the page. */
9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
10 => __( 'Page draft updated.' ) . $preview_page_link_html,
);
@@ -213,8 +228,8 @@
$notice = false;
$form_extra = '';
-if ( 'auto-draft' == $post->post_status ) {
- if ( 'edit' == $action ) {
+if ( 'auto-draft' === $post->post_status ) {
+ if ( 'edit' === $action ) {
$post->post_title = '';
}
$autosave = false;
@@ -227,11 +242,15 @@
$nonce_action = 'update-post_' . $post_ID;
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
-// Detect if there exists an autosave newer than the post and if that autosave is different than the post
+// Detect if there exists an autosave newer than the post and if that autosave is different than the post.
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
- if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
- $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 ) );
+ if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
+ $notice = sprintf(
+ /* translators: %s: URL to view the autosave. */
+ __( '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 )
+ );
break;
}
}
@@ -245,7 +264,7 @@
$post_type_object = get_post_type_object( $post_type );
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
-require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
+require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
register_and_do_post_meta_boxes( $post );
@@ -257,7 +276,7 @@
)
);
-if ( 'post' == $post_type ) {
+if ( 'post' === $post_type ) {
$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>';
get_current_screen()->add_help_tab(
@@ -274,7 +293,11 @@
$title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Note that <p> and <br> 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 <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>';
$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>';
$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>';
- $title_and_editor .= '<p>' . __( 'Keyboard users: When you’re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
+ $title_and_editor .= '<p>' . sprintf(
+ /* translators: %s: Alt + F10 */
+ __( 'Keyboard users: When you’re working in the visual editor, you can use %s to access the toolbar.' ),
+ '<kbd>Alt + F10</kbd>'
+ ) . '</p>';
get_current_screen()->add_help_tab(
array(
@@ -285,12 +308,16 @@
);
get_current_screen()->set_help_sidebar(
- '<p>' . sprintf( __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
+ '<p>' . sprintf(
+ /* translators: %s: URL to Press This bookmarklet. */
+ __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ),
+ 'tools.php'
+ ) . '</p>' .
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/wordpress-editor/">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
-} elseif ( 'page' == $post_type ) {
+} elseif ( 'page' === $post_type ) {
$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 “Parent” of the other, creating a group of pages.' ) . '</p>' .
'<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>';
@@ -304,17 +331,17 @@
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>' ) . '</p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/pages-add-new-screen/">Documentation on Adding New Pages</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/pages-screen/">Documentation on Editing Pages</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
-} elseif ( 'attachment' == $post_type ) {
+} elseif ( 'attachment' === $post_type ) {
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
- '<p>' . __( 'This screen allows you to edit four fields for metadata in a file within the media library.' ) . '</p>' .
+ '<p>' . __( 'This screen allows you to edit fields for metadata in a file within the media library.' ) . '</p>' .
'<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>' .
'<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>' .
'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
@@ -323,14 +350,14 @@
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
- '<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>' ) . '</p>' .
+ '<p>' . __( '<a href="https://wordpress.org/support/article/edit-media/">Documentation on Edit Media</a>' ) . '</p>' .
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
}
-if ( 'post' == $post_type || 'page' == $post_type ) {
+if ( 'post' === $post_type || 'page' === $post_type ) {
$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 “Create a new gallery” button.' ) . '</p>';
- $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>';
+ $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>';
get_current_screen()->add_help_tab(
array(
@@ -341,19 +368,22 @@
);
}
-if ( 'post' == $post_type ) {
+if ( 'post' === $post_type ) {
$publish_box = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
$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). 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.' ) .
'</li>';
if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) {
- $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>';
+ $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. 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>';
}
if ( current_theme_supports( 'post-thumbnails' ) && post_type_supports( 'post', 'thumbnail' ) ) {
- /* translators: %s: Featured Image */
- $publish_box .= '<li>' . sprintf( __( '<strong>%s</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 image as a post thumbnail on the home page, a custom header, etc.' ), esc_html( $post_type_object->labels->featured_image ) ) . '</li>';
+ $publish_box .= '<li>' . sprintf(
+ /* translators: %s: Featured image. */
+ __( '<strong>%s</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 image as a post thumbnail on the home page, a custom header, etc.' ),
+ esc_html( $post_type_object->labels->featured_image )
+ ) . '</li>';
}
$publish_box .= '</ul>';
@@ -376,7 +406,7 @@
'content' => $discussion_settings,
)
);
-} elseif ( 'page' == $post_type ) {
+} elseif ( 'page' === $post_type ) {
$page_attributes = '<p>' . __( '<strong>Parent</strong> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
'<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’ll see them in this dropdown menu.' ) . '</p>' .
'<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>';
@@ -390,7 +420,7 @@
);
}
-require_once( ABSPATH . 'wp-admin/admin-header.php' );
+require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<div class="wrap">
@@ -445,7 +475,7 @@
<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
<?php
}
-if ( 'draft' != get_post_status( $post ) ) {
+if ( 'draft' !== get_post_status( $post ) ) {
wp_original_referer_field( true, 'previous' );
}
@@ -469,7 +499,7 @@
?>
<div id="poststuff">
-<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
+<div id="post-body" class="metabox-holder columns-<?php echo ( 1 === get_current_screen()->get_columns() ) ? '1' : '2'; ?>">
<div id="post-body-content">
<?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
@@ -508,13 +538,18 @@
if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
$shortlink = wp_get_shortlink( $post->ID, 'post' );
- if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
- $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
+ if ( ! empty( $shortlink ) && $shortlink !== $permalink && home_url( '?page_id=' . $post->ID ) !== $permalink ) {
+ $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" />' .
+ '<button type="button" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val());">' .
+ __( 'Get Shortlink' ) .
+ '</button>';
}
}
- if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
- $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
+ if ( $post_type_object->public
+ && ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) )
+ ) {
+ $has_sample_permalink = $sample_permalink_html && 'auto-draft' !== $post->post_status;
?>
<div id="edit-slug-box" class="hide-if-no-js">
<?php
@@ -570,17 +605,26 @@
);
?>
<table id="post-status-info"><tbody><tr>
- <td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
+ <td id="wp-word-count" class="hide-if-no-js">
+ <?php
+ printf(
+ /* translators: %s: Number of words. */
+ __( 'Word count: %s' ),
+ '<span class="word-count">0</span>'
+ );
+ ?>
+ </td>
<td class="autosave-info">
<span class="autosave-message"> </span>
<?php
- if ( 'auto-draft' != $post->post_status ) {
+ if ( 'auto-draft' !== $post->post_status ) {
echo '<span id="last-edit">';
- if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
- /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
+ $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
+ if ( $last_user ) {
+ /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
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 ) );
} else {
- /* translators: 1: Post edited date, 2: Post edited time */
+ /* translators: 1: Post edited date, 2: Post edited time. */
printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
}
echo '</span>';
@@ -607,7 +651,7 @@
<div id="postbox-container-1" class="postbox-container">
<?php
-if ( 'page' == $post_type ) {
+if ( 'page' === $post_type ) {
/**
* Fires before meta boxes with 'side' context are output for the 'page' post type.
*
@@ -641,7 +685,7 @@
do_meta_boxes( null, 'normal', $post );
-if ( 'page' == $post_type ) {
+if ( 'page' === $post_type ) {
/**
* Fires after 'normal' context meta boxes have been output for the 'page' post type.
*