Editor: Use a consistent way to retrieve post ID on Edit Post screens.

Props mukesh27, ravipatel, davidbaumwald.
Fixes #52995.
Built from https://develop.svn.wordpress.org/trunk@50693


git-svn-id: http://core.svn.wordpress.org/trunk@50302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-04-09 11:31:09 +00:00
parent 57da3e7813
commit bdacea193a
3 changed files with 9 additions and 9 deletions

View File

@ -78,7 +78,7 @@ $post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
$action = isset( $action ) ? $action : '';
if ( (int) get_option( 'page_for_posts' ) === $post_ID && 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' );
}
@ -94,7 +94,7 @@ if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_typ
if ( $thumbnail_support ) {
add_thickbox();
wp_enqueue_media( array( 'post' => $post_ID ) );
wp_enqueue_media( array( 'post' => $post->ID ) );
}
// Add the local autosave notice HTML.
@ -103,7 +103,7 @@ add_action( 'admin_footer', '_local_storage_notice' );
/*
* @todo Document the $messages array(s).
*/
$permalink = get_permalink( $post_ID );
$permalink = get_permalink( $post->ID );
if ( ! $permalink ) {
$permalink = '';
}
@ -237,12 +237,12 @@ if ( 'auto-draft' === $post->post_status ) {
$autosave = false;
$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
} else {
$autosave = wp_get_post_autosave( $post_ID );
$autosave = wp_get_post_autosave( $post->ID );
}
$form_action = 'editpost';
$nonce_action = 'update-post_' . $post_ID;
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
$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.
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
@ -621,7 +621,7 @@ if ( post_type_supports( $post_type, 'editor' ) ) {
<?php
if ( 'auto-draft' !== $post->post_status ) {
echo '<span id="last-edit">';
$last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
$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 ) );

View File

@ -346,7 +346,7 @@ $editor_settings = array(
'enableCustomSpacing' => $custom_spacing,
);
$autosave = wp_get_post_autosave( $post_ID );
$autosave = wp_get_post_autosave( $post->ID );
if ( $autosave ) {
if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
$editor_settings['autosave'] = array(

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-50692';
$wp_version = '5.8-alpha-50693';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.