Ticket #39032: 39032.5.diff
| File 39032.5.diff, 2.0 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/theme.php
diff --git src/wp-includes/theme.php src/wp-includes/theme.php index cf1bb0f..8aac86c 100644
function wp_update_custom_css_post( $css, $args = array() ) { 1786 1786 $r = wp_update_post( wp_slash( $post_data ), true ); 1787 1787 } else { 1788 1788 $r = wp_insert_post( wp_slash( $post_data ), true ); 1789 1790 // Trigger creation of a revision. This should be removed once #30854 is resolved. 1791 if ( ! is_wp_error( $r ) && 0 === count( wp_get_post_revisions( $r ) ) ) { 1792 wp_save_post_revision( $r ); 1793 } 1789 1794 } 1790 1795 1791 if ( $r instanceof WP_Error) {1796 if ( is_wp_error( $r ) ) { 1792 1797 return $r; 1793 1798 } 1794 1799 return get_post( $r ); -
tests/phpunit/tests/customize/custom-css-setting.php
diff --git tests/phpunit/tests/customize/custom-css-setting.php tests/phpunit/tests/customize/custom-css-setting.php index e787094..102d303 100644
class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { 193 193 } 194 194 195 195 /** 196 * Test revision saving on initial save of Custom CSS. 197 * 198 * @ticket 39032 199 */ 200 function test_custom_css_revision_saved() { 201 $inserted_css = 'body { background: black; }'; 202 $updated_css = 'body { background: red; }'; 203 204 $post = wp_update_custom_css_post( $inserted_css, array( 205 'stylesheet' => 'testtheme', 206 ) ); 207 208 $this->assertSame( $inserted_css, $post->post_content ); 209 $revisions = array_values( wp_get_post_revisions( $post ) ); 210 $this->assertCount( 1, $revisions ); 211 $this->assertSame( $inserted_css, $revisions[0]->post_content ); 212 213 wp_update_custom_css_post( $updated_css, array( 214 'stylesheet' => 'testtheme', 215 ) ); 216 217 $revisions = array_values( wp_get_post_revisions( $post ) ); 218 $this->assertCount( 2, $revisions ); 219 $this->assertSame( $updated_css, $revisions[0]->post_content ); 220 $this->assertSame( $inserted_css, $revisions[1]->post_content ); 221 } 222 223 /** 196 224 * Test crud methods on WP_Customize_Custom_CSS_Setting. 197 225 * 198 226 * @covers WP_Customize_Custom_CSS_Setting::value()