Skip to content

Commit c00ba50

Browse files
Editor: Use a consistent way to retrieve post ID on Edit Post screens.
Props mukesh27, ravipatel, davidbaumwald. Fixes #52995. git-svn-id: https://develop.svn.wordpress.org/trunk@50693 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4e5569d commit c00ba50

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/wp-admin/edit-form-advanced.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
7979
$action = isset( $action ) ? $action : '';
8080

81-
if ( (int) get_option( 'page_for_posts' ) === $post_ID && empty( $post->post_content ) ) {
81+
if ( (int) get_option( 'page_for_posts' ) === $post->ID && empty( $post->post_content ) ) {
8282
add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
8383
remove_post_type_support( $post_type, 'editor' );
8484
}
@@ -94,7 +94,7 @@
9494

9595
if ( $thumbnail_support ) {
9696
add_thickbox();
97-
wp_enqueue_media( array( 'post' => $post_ID ) );
97+
wp_enqueue_media( array( 'post' => $post->ID ) );
9898
}
9999

100100
// Add the local autosave notice HTML.
@@ -103,7 +103,7 @@
103103
/*
104104
* @todo Document the $messages array(s).
105105
*/
106-
$permalink = get_permalink( $post_ID );
106+
$permalink = get_permalink( $post->ID );
107107
if ( ! $permalink ) {
108108
$permalink = '';
109109
}
@@ -237,12 +237,12 @@
237237
$autosave = false;
238238
$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
239239
} else {
240-
$autosave = wp_get_post_autosave( $post_ID );
240+
$autosave = wp_get_post_autosave( $post->ID );
241241
}
242242

243243
$form_action = 'editpost';
244-
$nonce_action = 'update-post_' . $post_ID;
245-
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
244+
$nonce_action = 'update-post_' . $post->ID;
245+
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />";
246246

247247
// Detect if there exists an autosave newer than the post and if that autosave is different than the post.
248248
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
@@ -621,7 +621,7 @@
621621
<?php
622622
if ( 'auto-draft' !== $post->post_status ) {
623623
echo '<span id="last-edit">';
624-
$last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) );
624+
$last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
625625
if ( $last_user ) {
626626
/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time. */
627627
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 ) );

src/wp-admin/edit-form-blocks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
'enableCustomSpacing' => $custom_spacing,
347347
);
348348

349-
$autosave = wp_get_post_autosave( $post_ID );
349+
$autosave = wp_get_post_autosave( $post->ID );
350350
if ( $autosave ) {
351351
if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
352352
$editor_settings['autosave'] = array(

0 commit comments

Comments
 (0)