WordPress.org

Make WordPress Core

Ticket #22435: export.3.diff

File export.3.diff, 1.4 KB (added by rodrigosprimo, 5 years ago)

Fixes categories tags when exporting posts from a single category

  • src/wp-includes/export/class-wp-export-query.php

    diff --git a/src/wp-includes/export/class-wp-export-query.php b/src/wp-includes/export/class-wp-export-query.php
    index d0948da..30de3fe 100644
    a b class WP_Export_Query { 
    7272
    7373        public function categories() {
    7474                if ( $this->category ) {
    75                         return $this->category;
     75                        return array( $this->category );
    7676                }
    7777                if ( $this->filters['post_type'] ) {
    7878                        return array();
  • tests/phpunit/tests/export/class-wp-export-query.php

    diff --git a/tests/phpunit/tests/export/class-wp-export-query.php b/tests/phpunit/tests/export/class-wp-export-query.php
    index 0fd90d6..5be2567 100644
    a b class Test_WP_Export_Query extends WP_UnitTestCase { 
    174174                $category_id = $this->factory->category->create( array( 'name' => 'baba' ) );
    175175                $other_category_id = $this->factory->category->create( array( 'name' => 'dyado' ) );
    176176                $export = new WP_Export_Query( array( 'post_type' => 'post', 'category' => $category_id ) );
    177                 $this->assertEquals( 1, count( $export->categories() ) );
     177                $categories = $export->categories();
     178                $this->assertTrue( is_array( $categories ) );
     179                $this->assertEquals( 1, count( $categories ) );
    178180        }
    179181
    180182        function test_categories_should_return_no_categories_if_we_are_requesting_only_one_post_type() {