diff --git src/wp-includes/post-functions.php src/wp-includes/post-functions.php
index a9f1ffc..5701aec 100644
|
|
function _post_type_meta_capabilities( $capabilities = null ) { |
1330 | 1330 | * @since 4.3.0 Added the `featured_image`, `set_featured_image`, `remove_featured_image`, |
1331 | 1331 | * and `use_featured_image` labels. |
1332 | 1332 | * @since 4.4.0 Added the `insert_into_item` and `uploaded_to_this_item` labels. |
1333 | | * |
| 1333 | * |
1334 | 1334 | * @access private |
1335 | 1335 | * |
1336 | 1336 | * @param object $post_type_object Post type object. |
… |
… |
function wp_insert_post( $postarr, $wp_error = false ) { |
3012 | 3012 | * is not 'draft' or 'pending', set date to now. |
3013 | 3013 | */ |
3014 | 3014 | if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) { |
3015 | | $post_date = current_time( 'mysql' ); |
| 3015 | if ( empty($postarr['post_date_gmt']) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { |
| 3016 | $post_date = current_time( 'mysql' ); |
| 3017 | } else { |
| 3018 | $post_date = get_date_from_gmt($postarr['post_date_gmt']); |
| 3019 | } |
| 3020 | |
3016 | 3021 | } else { |
3017 | 3022 | $post_date = $postarr['post_date']; |
3018 | 3023 | } |
diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
index b3d7b0a..403258e 100644
|
|
class Tests_Post extends WP_UnitTestCase { |
1218 | 1218 | |
1219 | 1219 | $this->assertEquals( $this->author_id, get_post( $post_id )->post_author ); |
1220 | 1220 | } |
| 1221 | |
| 1222 | /** |
| 1223 | * @ticket 15946 |
| 1224 | */ |
| 1225 | function test_wp_insert_post_should_respect_post_date_gmt() { |
| 1226 | $post = array( |
| 1227 | 'post_author' => $this->author_id, |
| 1228 | 'post_status' => 'publish', |
| 1229 | 'post_content' => rand_str(), |
| 1230 | 'post_title' => rand_str(), |
| 1231 | 'post_date_gmt' => '2014-01-01 12:00:00', |
| 1232 | ); |
| 1233 | |
| 1234 | // insert a post and make sure the ID is ok |
| 1235 | $id = wp_insert_post($post); |
| 1236 | |
| 1237 | $out = get_post($id); |
| 1238 | |
| 1239 | $this->assertEquals($post['post_content'], $out->post_content); |
| 1240 | $this->assertEquals($post['post_title'], $out->post_title); |
| 1241 | $this->assertEquals($post['post_author'], $out->post_author); |
| 1242 | $this->assertEquals(get_date_from_gmt($post['post_date_gmt']), $out->post_date); |
| 1243 | $this->assertEquals($post['post_date_gmt'], $out->post_date_gmt); |
| 1244 | } |
1221 | 1245 | } |