Make WordPress Core

Ticket #44914: 44914-2.diff

File 44914-2.diff, 2.0 KB (added by birgire, 6 years ago)
  • src/wp-admin/includes/post.php

    diff --git src/wp-admin/includes/post.php src/wp-admin/includes/post.php
    index 187c013..f7d8c91 100644
    function bulk_edit_posts( $post_data = null ) { 
    610610
    611611                if ( isset( $shared_post_data['post_format'] ) ) {
    612612                        set_post_format( $post_ID, $shared_post_data['post_format'] );
     613                }
     614
     615                if ( isset( $post_data['tax_input']['post_format'] ) ) {
    613616                        unset( $post_data['tax_input']['post_format'] );
    614617                }
    615618
  • tests/phpunit/tests/admin/includesPost.php

    diff --git tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/admin/includesPost.php
    index ee3edb8..9c57d72 100644
    class Tests_Admin_Includes_Post extends WP_UnitTestCase { 
    255255        }
    256256
    257257        /**
     258         * The bulk_edit_posts() function should preserve the post format
     259         * when it's unchanged.
     260         *
     261         * @ticket 44914
     262         */
     263        public function test_bulk_edit_posts_should_preserve_post_format_when_unchanged() {
     264                wp_set_current_user( self::$admin_id );
     265
     266                $post_ids = self::factory()->post->create_many( 3 );
     267
     268                set_post_format( $post_ids[0], 'image' );
     269                set_post_format( $post_ids[1], 'aside' );
     270
     271                $request = array(
     272                        'post_format'    => -1, // Don't change the post format.
     273                        '_status'        => -1,
     274                        'post'           => $post_ids,
     275                );
     276
     277                bulk_edit_posts( $request );
     278
     279                $terms1 = get_the_terms( $post_ids[0], 'post_format' );
     280                $terms2 = get_the_terms( $post_ids[1], 'post_format' );
     281                $terms3 = get_the_terms( $post_ids[2], 'post_format' );
     282
     283                $this->assertSame( 'post-format-image', $terms1[0]->slug );
     284                $this->assertSame( 'post-format-aside', $terms2[0]->slug );
     285                $this->assertFalse( $terms3 );
     286
     287                $this->assertSame( 'image', get_post_format( $post_ids[0] ) );
     288                $this->assertSame( 'aside', get_post_format( $post_ids[1] ) );
     289                $this->assertFalse( get_post_format( $post_ids[2] ) );
     290        }
     291
     292        /**
    258293         * @ticket 41396
    259294         */
    260295        public function test_bulk_edit_posts_should_set_post_format_before_wp_update_post_runs() {