Media: Don't backdate media uploaded to pages.

When media is uploaded to a post, the upload directory is set according to the date of the post, so that the media URLs in the post match when the post was published.

A page is a slightly different beast, pages often live for years, and are regularly updated to stay relevant. This change causes media uploaded to pages to use the upload date to determine the upload directory.

Fixes #10752.


Built from https://develop.svn.wordpress.org/trunk@41964


git-svn-id: http://core.svn.wordpress.org/trunk@41798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2017-10-21 13:27:48 +00:00
parent 26f9c6b909
commit 0847fab645
2 changed files with 3 additions and 2 deletions

View File

@ -274,7 +274,8 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
$time = current_time('mysql');
if ( $post = get_post($post_id) ) {
if ( substr( $post->post_date, 0, 4 ) > 0 )
// The post date doesn't usually matter for pages, so don't backdate this upload.
if ( 'page' !== $post->post_type && substr( $post->post_date, 0, 4 ) > 0 )
$time = $post->post_date;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta3-41963';
$wp_version = '4.9-beta3-41964';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.