From 21d5f9ed58033ff960df1bfeb31abb21fc0a567a Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Thu, 24 Oct 2019 16:00:11 -0300 Subject: [PATCH 1/5] fix name of class on catch --- .../relationship/class-tainacan-relationship.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/classes/metadata-types/relationship/class-tainacan-relationship.php b/src/classes/metadata-types/relationship/class-tainacan-relationship.php index 83b87b1b9..698d5d88a 100644 --- a/src/classes/metadata-types/relationship/class-tainacan-relationship.php +++ b/src/classes/metadata-types/relationship/class-tainacan-relationship.php @@ -148,8 +148,8 @@ class Relationship extends Metadata_Type { } - } catch (Exception $e) { - // item not found + } catch (\Exception $e) { + // item not found } } @@ -164,7 +164,7 @@ class Relationship extends Metadata_Type { $return .= $this->get_item_html($item); } - } catch (Exception $e) { + } catch (\Exception $e) { // item not found } From f494a0dc11c4372bb57b24a12ebfa0ce4f56a55d Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 23 Oct 2019 16:48:51 -0300 Subject: [PATCH 2/5] add test for object post type of the taxonomies --- tests/test-taxonomies.php | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 6d13b6070..164e6b186 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -416,4 +416,171 @@ class Taxonomies extends TAINACAN_UnitTestCase { } + function test_metadata_taxonomy_term_count() { + $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); + $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); + + $collection_1 = $this->tainacan_entity_factory->create_entity( + 'collection', + array( 'name' => 'test-1' ), + true + ); + + $collection_2 = $this->tainacan_entity_factory->create_entity( + 'collection', + array( 'name' => 'test-2' ), + true + ); + + $tax = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => 'tax_test', + 'status' => 'publish', + 'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] + ), + true + ); + + $tax_repository = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => 'tax_test_repository', + 'status' => 'publish' + ), + true + ); + + $t1 = $this->tainacan_entity_factory->create_entity( + 'term', + array( + 'taxonomy' => $tax->get_db_identifier(), + 'name' => 'term', + 'user' => get_current_user_id(), + ), + true + ); + + $t2 = $this->tainacan_entity_factory->create_entity( + 'term', + array( + 'taxonomy' => $tax_repository->get_db_identifier(), + 'name' => 'term_repository' + ), + true + ); + + $metadatum_1 = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-1', + 'description' => 'description-1', + 'collection' => $collection_1, + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $metadatum_2 = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-2', + 'description' => 'description-2', + 'collection' => $collection_2, + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $metadatum_repository = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'meta-1', + 'description' => 'description-1', + 'collection_id' => $Tainacan_Metadata->get_default_metadata_attribute(), + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'status' => 'publish', + 'metadata_type_options' => [ + 'taxonomy_id' => $tax_repository->get_id(), + 'allow_new_terms' => 'no' + ] + ), + true + ); + + $i1 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item teste', + 'description' => 'adasdasdsa', + 'collection' => $collection_1 + ), + true + ); + $itemMeta1 = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_1); + $itemMeta1->set_value('term'); + $itemMeta1->validate(); + $Tainacan_Item_Metadata->insert($itemMeta1); + + $itemMeta1_repo = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_repository); + $itemMeta1_repo->set_value('term_repository'); + $itemMeta1_repo->validate(); + $Tainacan_Item_Metadata->insert($itemMeta1_repo); + + + $i2 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item teste', + 'description' => 'adasdasdsa', + 'collection' => $collection_2 + ), + true + ); + $itemMeta2 = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum_2); + $itemMeta2->set_value('term'); + $itemMeta2->validate(); + $Tainacan_Item_Metadata->insert($itemMeta2); + + $itemMeta2_repo = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum_repository); + $itemMeta2_repo->set_value('term_repository'); + $itemMeta2_repo->validate(); + $Tainacan_Item_Metadata->insert($itemMeta2_repo); + + $terms = get_terms([ + 'taxonomy' => $tax->get_db_identifier(), + //'hide_empty' => false, + ]); + $this->assertEquals(1, count($terms)); + + wp_update_term_count($t1->get_term_id(), $tax->get_db_identifier()); + wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); + + $term = get_term($t1->get_term_id()); + $term_repo = get_term($t2->get_term_id()); + $tax_used = get_object_taxonomies( [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()]); + + $tax = get_taxonomy($tax->get_db_identifier()); + $tax_repository = get_taxonomy($tax_repository->get_db_identifier()); + + $this->assertContains($collection_1->get_db_identifier(), $tax->object_type); + $this->assertContains($collection_2->get_db_identifier(), $tax->object_type); + + $this->assertContains($collection_1->get_db_identifier(), $tax_repository->object_type); + $this->assertContains($collection_2->get_db_identifier(), $tax_repository->object_type); + + $this->assertEquals(2, $term->count); + $this->assertEquals(2, $term_repo->count); + } + } \ No newline at end of file From 678f69f26a09a0d4dc68cbd421eeaf0b161417a9 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Wed, 23 Oct 2019 16:55:27 -0300 Subject: [PATCH 3/5] remove `enabled_post_types` on declared taxonomy. --- tests/test-taxonomies.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 164e6b186..8c2db54d2 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -437,7 +437,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'name' => 'tax_test', 'status' => 'publish', - 'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] + //'enabled_post_types' => [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()] ), true ); From 56b9e76aa16dece7fc5e215ea100b26933cac4e7 Mon Sep 17 00:00:00 2001 From: leogermani Date: Wed, 23 Oct 2019 20:08:00 -0300 Subject: [PATCH 4/5] Make WP update terms count for all items #318 --- .../entities/class-tainacan-taxonomy.php | 53 +++--- tests/test-taxonomies.php | 176 +++++++++--------- 2 files changed, 116 insertions(+), 113 deletions(-) diff --git a/src/classes/entities/class-tainacan-taxonomy.php b/src/classes/entities/class-tainacan-taxonomy.php index af5c94265..dd11af5d2 100644 --- a/src/classes/entities/class-tainacan-taxonomy.php +++ b/src/classes/entities/class-tainacan-taxonomy.php @@ -22,28 +22,28 @@ class Taxonomy extends Entity { * @var string */ static $post_type = 'tainacan-taxonomy'; - + /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::capability_type * @var string */ protected static $capability_type = ['tainacan-taxonomy', 'tainacan-taxonomies']; - + /** * {@inheritDoc} * @see \Tainacan\Entities\Entity::repository * @var string */ protected $repository = 'Taxonomies'; - + /** * Prefix used to create the db_identifier * * @var string */ static $db_identifier_prefix = 'tnc_tax_'; - + public function __toString(){ return apply_filters("tainacan-taxonomy-to-string", $this->get_name(), $this); } @@ -67,7 +67,7 @@ class Taxonomy extends Entity { 'new_item_name' => __( 'New Genre term', 'tainacan' ), 'menu_name' => $this->get_name(), ); - + $enabled_post_types = $this->get_enabled_post_types(); $enabled_post_types = sizeof($enabled_post_types) ? $enabled_post_types : null; $show_ui = is_array($enabled_post_types) ? true : false; @@ -80,21 +80,22 @@ class Taxonomy extends Entity { 'show_admin_column' => false, 'rewrite' => [ 'slug' => $this->get_slug() - ], + ], + 'update_count_callback' => '_update_generic_term_count' ); - + if (taxonomy_exists($this->get_db_identifier())){ unregister_taxonomy($this->get_db_identifier()); } - - - - register_taxonomy( - $this->get_db_identifier(), - $enabled_post_types, - $args + + + + register_taxonomy( + $this->get_db_identifier(), + $enabled_post_types, + $args ); - + return true; } @@ -135,7 +136,7 @@ class Taxonomy extends Entity { function get_slug() { return $this->get_mapped_property('slug'); } - + /** * Return the enabled post types * @@ -144,7 +145,7 @@ class Taxonomy extends Entity { function get_enabled_post_types() { return $this->get_mapped_property('enabled_post_types'); } - + // special Getters /** @@ -194,7 +195,7 @@ class Taxonomy extends Entity { function set_allow_insert($value) { $this->set_mapped_property('allow_insert', $value); } - + /** * Sets enabled post types * @@ -221,19 +222,19 @@ class Taxonomy extends Entity { return parent::validate(); } - + /** - * Check if a term already exists + * Check if a term already exists * - * @param string $term_name The term name - * @param int|null $parent The ID of the parent term to look for children or null to look for terms in any hierarchical position. Default is null - * @param bool $return_term wether to return the term object if it exists. default is to false - * - * @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object + * @param string $term_name The term name + * @param int|null $parent The ID of the parent term to look for children or null to look for terms in any hierarchical position. Default is null + * @param bool $return_term wether to return the term object if it exists. default is to false + * + * @return bool|WP_Term return boolean indicating if term exists. If $return_term is true and term exists, return WP_Term object */ function term_exists($term_name, $parent = null, $return_term = false) { $repo = $this->get_repository(); return $repo->term_exists($this, $term_name, $parent, $return_term); } -} \ No newline at end of file +} diff --git a/tests/test-taxonomies.php b/tests/test-taxonomies.php index 8c2db54d2..e30d6a5d7 100644 --- a/tests/test-taxonomies.php +++ b/tests/test-taxonomies.php @@ -69,9 +69,9 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals( $test->get_name(), 'Rock' ); $this->assertEquals( $test->get_user(), 56 ); } - + function test_terms_of_draft_taxonomy() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -82,14 +82,14 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy->get_id()); - + $this->assertEquals(0, sizeof($terms), 'new auto draft taxonomy should return 0 terms'); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -98,17 +98,17 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - - - + + + $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy->get_id()); - + $this->assertEquals(1, sizeof($terms), 'you should be able to create a term even if the taxonomy is still auto-draft'); - + } - + function test_term_exists() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -119,10 +119,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -131,7 +131,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $parent = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -140,7 +140,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $child = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -150,14 +150,14 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $this->assertFalse( $Tainacan_Terms->term_exists('Reggae', $taxonomy->get_db_identifier()) ); $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_db_identifier()) ); - + //var_dump( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_db_identifier(), 0, true) ); - - // test extreme case - + + // test extreme case + $term_2 = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -167,49 +167,49 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $this->assertFalse( $Tainacan_Terms->term_exists('test 123', $taxonomy->get_db_identifier(), 0) ); // parent 0 $this->assertTrue( $Tainacan_Terms->term_exists('test 123', $taxonomy->get_db_identifier(), $term->get_id()) ); // spaces in between - - // testing passing taxonomy object + + // testing passing taxonomy object $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy) ); - + // testing passing taxonomy ID $this->assertTrue( $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id()) ); - + // testing via Taxonomy object $this->assertTrue( $taxonomy->term_exists('Rock') ); - - // testing retrieving the term + + // testing retrieving the term $this->assertTrue( $taxonomy->term_exists('Rock', 0, true) instanceof \WP_Term ); $this->assertEquals( $term->get_id(), $taxonomy->term_exists('Rock', 0, true)->term_taxonomy_id ); - - // test parent + + // test parent $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier()) ); // parent null $this->assertFalse( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), 0) ); // parent 0 - $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), $parent->get_id()) ); // parent - - // test with ID + $this->assertTrue( $Tainacan_Terms->term_exists('Child', $taxonomy->get_db_identifier(), $parent->get_id()) ); // parent + + // test with ID $this->assertTrue( $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id()) ); - - // test get term + + // test get term $test_term = $Tainacan_Terms->term_exists($term->get_id(), $taxonomy->get_id(), null, true); $this->assertEquals($term->get_id(), $test_term->term_id); - + $test_term = $Tainacan_Terms->term_exists('Rock', $taxonomy->get_id(), null, true); $this->assertEquals($term->get_id(), $test_term->term_id); - + $test_term = $Tainacan_Terms->term_exists('Parent', $taxonomy->get_id(), null, true); $this->assertEquals($parent->get_id(), $test_term->term_id); - + // test brackets $test_term = $Tainacan_Terms->term_exists('[Rock]', $taxonomy->get_id(), null, true); $this->assertFalse($test_term); - + } - + function test_term_validation() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -220,10 +220,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -232,7 +232,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $parent = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -241,7 +241,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $child = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -251,27 +251,27 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $newTerm = new \Tainacan\Entities\Term(); $newTerm->set_name('Child'); $newTerm->set_taxonomy($taxonomy->get_db_identifier()); - + $this->assertTrue( $newTerm->validate() ); - + $newTerm->set_parent($parent->get_id()); - + $this->assertFalse( $newTerm->validate(), 'term should not validate because it has a duplicate in the same level' ); - + $child->set_description('changed'); - + $this->assertTrue( $child->validate(), 'child should validate'); - - - + + + } - + /** - * @group enabled + * @group enabled */ function test_enabled_post_types(){ $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); @@ -287,15 +287,15 @@ class Taxonomies extends TAINACAN_UnitTestCase { ); $taxonomy = $Tainacan_Taxonomies->insert($taxonomy); - + $pto = get_object_taxonomies('post'); $pages = get_object_taxonomies('page'); $this->assertContains($taxonomy->get_db_identifier(), $pto); $this->assertNotContains($taxonomy->get_db_identifier(), $pages); } - + function test_brackets() { - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -306,10 +306,10 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance(); $Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance(); - + $term = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -318,7 +318,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $term2 = $this->tainacan_entity_factory->create_entity( 'term', array( @@ -327,16 +327,16 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $terms = $Tainacan_Terms->fetch(['hide_empty' => false], $taxonomy); $this->assertEquals(2, sizeof($terms)); - + } - + function test_brackets_2() { - + $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); - + $collection = $this->tainacan_entity_factory->create_entity( 'collection', array( @@ -345,7 +345,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $taxonomy = $this->tainacan_entity_factory->create_entity( 'taxonomy', array( @@ -381,7 +381,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $i2 = $this->tainacan_entity_factory->create_entity( 'item', array( @@ -391,44 +391,44 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $itemMeta1 = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum); $itemMeta1->set_value('Rock'); $itemMeta1->validate(); $Tainacan_Item_Metadata->insert($itemMeta1); - + //$this->assertNotFalse(term_exists( 'Rock', $taxonomy->get_db_identifier() )); // term_exists() is not to be trusted //$this->assertFalse(term_exists( '[Rock]', $taxonomy->get_db_identifier() )); - + $itemMeta2 = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum); $itemMeta2->set_value('[Rock]'); $itemMeta2->validate(); $Tainacan_Item_Metadata->insert($itemMeta2); - + $itemMeta1_check = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum); $this->assertEquals('Rock', $itemMeta1_check->get_value()->get_name()); - + $itemMeta2_check = new \Tainacan\Entities\Item_Metadata_Entity($i2, $metadatum); $this->assertEquals('[Rock]', $itemMeta2_check->get_value()->get_name()); - - - + + + } - + function test_metadata_taxonomy_term_count() { $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); $collection_1 = $this->tainacan_entity_factory->create_entity( 'collection', - array( 'name' => 'test-1' ), + array( 'name' => 'test-1', 'status' => 'publish', ), true ); $collection_2 = $this->tainacan_entity_factory->create_entity( 'collection', - array( 'name' => 'test-2' ), + array( 'name' => 'test-2', 'status' => 'publish', ), true ); @@ -469,7 +469,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { ), true ); - + $metadatum_1 = $this->tainacan_entity_factory->create_entity( 'metadatum', array( @@ -523,7 +523,8 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'title' => 'item teste', 'description' => 'adasdasdsa', - 'collection' => $collection_1 + 'collection' => $collection_1, + 'status' => 'publish' ), true ); @@ -531,7 +532,7 @@ class Taxonomies extends TAINACAN_UnitTestCase { $itemMeta1->set_value('term'); $itemMeta1->validate(); $Tainacan_Item_Metadata->insert($itemMeta1); - + $itemMeta1_repo = new \Tainacan\Entities\Item_Metadata_Entity($i1, $metadatum_repository); $itemMeta1_repo->set_value('term_repository'); $itemMeta1_repo->validate(); @@ -543,7 +544,8 @@ class Taxonomies extends TAINACAN_UnitTestCase { array( 'title' => 'item teste', 'description' => 'adasdasdsa', - 'collection' => $collection_2 + 'collection' => $collection_2, + 'status' => 'private' ), true ); @@ -564,12 +566,12 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals(1, count($terms)); wp_update_term_count($t1->get_term_id(), $tax->get_db_identifier()); - wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); + wp_update_term_count($t2->get_term_id(), $tax_repository->get_db_identifier()); $term = get_term($t1->get_term_id()); $term_repo = get_term($t2->get_term_id()); $tax_used = get_object_taxonomies( [$collection_1->get_db_identifier(), $collection_2->get_db_identifier()]); - + $tax = get_taxonomy($tax->get_db_identifier()); $tax_repository = get_taxonomy($tax_repository->get_db_identifier()); @@ -583,4 +585,4 @@ class Taxonomies extends TAINACAN_UnitTestCase { $this->assertEquals(2, $term_repo->count); } -} \ No newline at end of file +} From 5fb6451e553373f4584a2d3203bf7df2cc6f40a9 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Thu, 24 Oct 2019 17:19:59 -0300 Subject: [PATCH 5/5] save importer instance on get source info importer #313 --- src/api/endpoints/class-tainacan-rest-importers-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/endpoints/class-tainacan-rest-importers-controller.php b/src/api/endpoints/class-tainacan-rest-importers-controller.php index 2897bf72d..51dddbd92 100644 --- a/src/api/endpoints/class-tainacan-rest-importers-controller.php +++ b/src/api/endpoints/class-tainacan-rest-importers-controller.php @@ -267,7 +267,7 @@ class REST_Importers_Controller extends REST_Controller { if ( method_exists($importer, 'get_source_special_fields') ) { $response['source_special_fields'] = $importer->get_source_special_fields(); } - + $Tainacan_Importer_Handler->save_importer_instance($importer); return new \WP_REST_Response( $response, 200 ); }