Ticket #38719: 38719.0.diff
| File 38719.0.diff, 5.2 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/theme.php
diff --git src/wp-includes/theme.php src/wp-includes/theme.php index a36fe79..92d52ae 100644
function _wp_customize_include() { 2549 2549 * @param WP_Post $changeset_post Changeset post object. 2550 2550 */ 2551 2551 function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_post ) { 2552 global $wp_customize ;2552 global $wp_customize, $wpdb; 2553 2553 2554 2554 $is_publishing_changeset = ( 2555 2555 'customize_changeset' === $changeset_post->post_type … … function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_p 2600 2600 * and thus garbage collected. 2601 2601 */ 2602 2602 if ( ! wp_revisions_enabled( $changeset_post ) ) { 2603 wp_trash_post( $changeset_post->ID ); 2603 $post = $changeset_post; 2604 $post_id = $changeset_post->ID; 2605 2606 // The following re-formulates the logic from wp_trash_post() as done in wp_publish_post(). 2607 if ( ! EMPTY_TRASH_DAYS ) { 2608 wp_delete_post( $post_id, true ); 2609 } else { 2610 /** This action is documented in wp-includes/post.php */ 2611 do_action( 'wp_trash_post', $post_id ); 2612 2613 add_post_meta( $post_id,'_wp_trash_meta_status', $post->post_status ); 2614 add_post_meta( $post_id,'_wp_trash_meta_time', time() ); 2615 2616 $wpdb->update( $wpdb->posts, array( 'post_status' => 'trash' ), array( 'ID' => $post->ID ) ); 2617 clean_post_cache( $post->ID ); 2618 2619 $old_status = $post->post_status; 2620 $post->post_status = 'publish'; 2621 wp_transition_post_status( 'publish', $old_status, $post ); 2622 2623 /** This action is documented in wp-includes/post.php */ 2624 do_action( 'edit_post', $post->ID, $post ); 2625 2626 /** This action is documented in wp-includes/post.php */ 2627 do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); 2628 2629 /** This action is documented in wp-includes/post.php */ 2630 do_action( 'save_post', $post->ID, $post, true ); 2631 2632 /** This action is documented in wp-includes/post.php */ 2633 do_action( 'wp_insert_post', $post->ID, $post, true ); 2634 2635 /** This action is documented in wp-includes/post.php */ 2636 do_action( 'trashed_post', $post_id ); 2637 } 2604 2638 } 2605 2639 } 2606 2640 -
tests/phpunit/tests/customize/manager.php
diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php index a28d834..7c9d98b 100644
class Tests_WP_Customize_Manager extends WP_UnitTestCase { 416 416 * @covers WP_Customize_Manager::save_changeset_post() 417 417 */ 418 418 function test_save_changeset_post_without_theme_activation() { 419 global $wp_customize; 419 420 wp_set_current_user( self::$admin_user_id ); 420 421 421 422 $did_action = array( … … class Tests_WP_Customize_Manager extends WP_UnitTestCase { 425 426 ); 426 427 $uuid = wp_generate_uuid4(); 427 428 428 $ manager = new WP_Customize_Manager( array(429 $wp_customize = $manager = new WP_Customize_Manager( array( 429 430 'changeset_uuid' => $uuid, 430 431 ) ); 431 432 $manager->register_controls(); … … class Tests_WP_Customize_Manager extends WP_UnitTestCase { 507 508 $this->assertEquals( $previous_saved_data, json_decode( get_post( $post_id )->post_content, true ) ); 508 509 509 510 // Attempt a non-transactional/incremental update. 510 $ manager = new WP_Customize_Manager( array(511 $wp_customize = $manager = new WP_Customize_Manager( array( 511 512 'changeset_uuid' => $uuid, 512 513 ) ); 513 514 $manager->register_controls(); // That is, register settings. … … class Tests_WP_Customize_Manager extends WP_UnitTestCase { 544 545 $this->assertEquals( $customize_changeset_save_data_call_count + 1, $this->customize_changeset_save_data_call_count ); 545 546 546 547 // Publish the changeset. 547 $ manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );548 $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); 548 549 $manager->register_controls(); 549 $GLOBALS['wp_customize'] = $manager; 550 $manager->add_setting( 'scratchpad', array( 551 'type' => 'option', 552 'capability' => 'exist', 553 ) ); 554 $manager->get_setting( 'blogname' )->capability = 'exist'; 555 wp_set_current_user( self::$subscriber_user_id ); 550 556 $r = $manager->save_changeset_post( array( 551 557 'status' => 'publish', 552 558 'data' => array( 553 559 'blogname' => array( 554 560 'value' => 'Do it live \o/', 555 561 ), 562 'scratchpad' => array( 563 'value' => '<script>console.info( "HELLO" )</script>', 564 ), 556 565 ), 557 566 ) ); 558 567 $this->assertInternalType( 'array', $r ); 559 568 $this->assertEquals( 'Do it live \o/', get_option( 'blogname' ) ); 560 569 $this->assertEquals( 'trash', get_post_status( $post_id ) ); // Auto-trashed. 570 $this->assertContains( '<script>', get_post( $post_id )->post_content ); 571 $this->assertEquals( $manager->changeset_uuid(), get_post( $post_id )->post_name, 'Expected that the "__trashed" suffix to not be added.' ); 572 wp_set_current_user( self::$admin_user_id ); 561 573 562 574 // Test revisions. 563 575 add_post_type_support( 'customize_changeset', 'revisions' ); 564 576 $uuid = wp_generate_uuid4(); 565 $ manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );577 $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); 566 578 $manager->register_controls(); 567 $GLOBALS['wp_customize'] = $manager;568 579 569 580 $manager->set_post_value( 'blogname', 'Hello Surface' ); 570 581 $manager->save_changeset_post( array( 'status' => 'auto-draft' ) );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)