diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
index a446eed1c2..9c65467080 100644
|
|
|
add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); |
| 401 | 401 | add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); |
| 402 | 402 | // Create a revision whenever a post is updated. |
| 403 | 403 | add_action( 'post_updated', 'wp_save_post_revision', 10, 1 ); |
| | 404 | // Fired in `wp_transition_post_status` for newly created posts with status 'publish'. |
| | 405 | add_action( 'new_to_publish', 'wp_save_post_revision', 10, 1 ); |
| 404 | 406 | add_action( 'publish_post', '_publish_post_hook', 5, 1 ); |
| 405 | 407 | add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); |
| 406 | 408 | add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 ); |
diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index a7bc431c37..1770e6cb52 100644
|
|
|
function wp_update_custom_css_post( $css, $args = array() ) { |
| 2017 | 2017 | } else { |
| 2018 | 2018 | $r = wp_insert_post( wp_slash( $post_data ), true ); |
| 2019 | 2019 | |
| 2020 | | if ( ! is_wp_error( $r ) ) { |
| 2021 | | if ( get_stylesheet() === $args['stylesheet'] ) { |
| 2022 | | set_theme_mod( 'custom_css_post_id', $r ); |
| 2023 | | } |
| 2024 | | |
| 2025 | | // Trigger creation of a revision. This should be removed once #30854 is resolved. |
| 2026 | | if ( 0 === count( wp_get_post_revisions( $r ) ) ) { |
| 2027 | | wp_save_post_revision( $r ); |
| 2028 | | } |
| | 2020 | if ( ! is_wp_error( $r ) && get_stylesheet() === $args['stylesheet'] ) { |
| | 2021 | set_theme_mod( 'custom_css_post_id', $r ); |
| 2029 | 2022 | } |
| 2030 | 2023 | } |
| 2031 | 2024 | |
diff --git tests/phpunit/tests/post/revisions.php tests/phpunit/tests/post/revisions.php
index 35e43f18ae..392d09a1bb 100644
|
|
|
class Tests_Post_Revisions extends WP_UnitTestCase { |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | $revisions = wp_get_post_revisions( $post['ID'] ); |
| 541 | | |
| | 541 | array_unshift( $revision_ids, reset( $revisions )->ID ); |
| 542 | 542 | $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); |
| 543 | 543 | } |
| 544 | 544 | |
| … |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
| 574 | 574 | |
| 575 | 575 | $revisions = wp_get_post_revisions( $post['ID'] ); |
| 576 | 576 | |
| | 577 | array_unshift( $revision_ids, reset( $revisions )->ID ); |
| | 578 | |
| 577 | 579 | $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); |
| 578 | 580 | } |
| 579 | 581 | |
| … |
… |
class Tests_Post_Revisions extends WP_UnitTestCase { |
| 654 | 656 | |
| 655 | 657 | $this->assertWPError( $revision ); |
| 656 | 658 | } |
| | 659 | |
| | 660 | /** |
| | 661 | * @ticket 30854 |
| | 662 | */ |
| | 663 | function test_wp_first_revision_is_not_lost() { |
| | 664 | $post = self::factory()->post->create_and_get( |
| | 665 | array( |
| | 666 | 'post_title' => 'some-post', |
| | 667 | 'post_type' => 'post', |
| | 668 | 'post_content' => 'Initial Content', |
| | 669 | ) |
| | 670 | ); |
| | 671 | |
| | 672 | wp_update_post( |
| | 673 | array( |
| | 674 | 'ID' => $post->ID, |
| | 675 | 'post_content' => 'Update #1', |
| | 676 | ) |
| | 677 | ); |
| | 678 | |
| | 679 | wp_update_post( |
| | 680 | array( |
| | 681 | 'ID' => $post->ID, |
| | 682 | 'post_content' => 'Update #2', |
| | 683 | ) |
| | 684 | ); |
| | 685 | |
| | 686 | $revisions = wp_get_post_revisions( $post->ID ); |
| | 687 | $earliest_revision = end( $revisions ); |
| | 688 | |
| | 689 | $this->assertEquals( 'Initial Content', $earliest_revision->post_content ); |
| | 690 | } |
| 657 | 691 | } |
diff --git tests/phpunit/tests/xmlrpc/wp/getRevisions.php tests/phpunit/tests/xmlrpc/wp/getRevisions.php
index b7a4667165..03814bc7bf 100644
|
|
|
class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { |
| 42 | 42 | |
| 43 | 43 | $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); |
| 44 | 44 | $this->assertIsArray( $result ); |
| 45 | | $this->assertCount( 1, $result ); |
| | 45 | $this->assertCount( 2, $result ); |
| 46 | 46 | |
| 47 | 47 | wp_insert_post( |
| 48 | 48 | array( |