Make WordPress Core


Ignore:
Timestamp:
07/30/2017 02:40:42 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Post Formats: In bulk_edit_posts(), set post format before the post is updated, for consistency with edit_post().

This makes sure that plugins hooked to save_post get the right post format.

Props Chouby, SergeyBiryukov.
Fixes #41396.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r39062 r41187  
    208208     * @ticket 27792
    209209     */
    210     function test_bulk_edit_posts_stomping() {
     210    public function test_bulk_edit_posts_stomping() {
    211211        wp_set_current_user( self::$admin_id );
    212212
     
    243243        $this->assertEquals( 'closed', $post->comment_status );
    244244        $this->assertEquals( 'closed', $post->ping_status );
     245    }
     246
     247    /**
     248     * @ticket 41396
     249     */
     250    public function test_bulk_edit_posts_should_set_post_format_before_wp_update_post_runs() {
     251        wp_set_current_user( self::$admin_id );
     252
     253        $request = array(
     254            'post_format' => 'aside',
     255            '_status'     => -1,
     256            'post'        => array( self::$post_id ),
     257        );
     258
     259        add_action( 'save_post', array( $this, 'check_post_format' ) );
     260
     261        bulk_edit_posts( $request );
     262
     263        remove_action( 'save_post', array( $this, 'check_post_format' ) );
     264    }
     265
     266    public function check_post_format( $post_id ) {
     267        if ( self::$post_id === $post_id ) {
     268            $this->assertEquals( 'aside', get_post_format( $post_id ) );
     269        }
    245270    }
    246271
Note: See TracChangeset for help on using the changeset viewer.