diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
index dde54c510d..fb5a86318e 100644
|
a
|
b
|
function wp_insert_post( $postarr, $wp_error = false ) {
|
| 3726 | 3726 | } |
| 3727 | 3727 | |
| 3728 | 3728 | if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { |
| 3729 | | if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) { |
| | 3729 | if ( ! in_array( $post_status, get_post_stati( array( 'date_floating' => true ) ), true ) ) { |
| 3730 | 3730 | $post_date_gmt = get_gmt_from_date( $post_date ); |
| 3731 | 3731 | } else { |
| 3732 | 3732 | $post_date_gmt = '0000-00-00 00:00:00'; |
diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php
index 6ef0c8449f..dec4f9ece9 100644
|
a
|
b
|
class Tests_Post extends WP_UnitTestCase {
|
| 1391 | 1391 | remove_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| | 1394 | /** |
| | 1395 | * @ticket 48113 |
| | 1396 | */ |
| | 1397 | public function test_insert_post_should_respect_date_floating_post_status_arg() { |
| | 1398 | register_post_status( 'floating', array( 'date_floating' => true ) ); |
| | 1399 | |
| | 1400 | $post_id = self::factory()->post->create( |
| | 1401 | array( |
| | 1402 | 'post_status' => 'floating', |
| | 1403 | 'post_date' => null, |
| | 1404 | 'post_date_gmt' => null, |
| | 1405 | ) |
| | 1406 | ); |
| | 1407 | |
| | 1408 | $post = get_post( $post_id ); |
| | 1409 | self::assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); |
| | 1410 | } |
| | 1411 | |
| 1394 | 1412 | function filter_pre_wp_unique_post_slug( $default, $slug, $post_ID, $post_status, $post_type, $post_parent ) { |
| 1395 | 1413 | return 'override-slug-' . $post_type; |
| 1396 | 1414 | } |