diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index e69a03faf..4fa716783 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -500,26 +500,20 @@ class Item extends Entity { public function _toHtml() { - $return = ''; $id = $this->get_id(); if ( $id ) { - $link = get_permalink( (int) $id ); if (is_string($link)) { - $return = ""; $return.= $this->get_title(); $return .= ""; - } - } return $return; - } /** diff --git a/src/classes/entities/class-tainacan-term.php b/src/classes/entities/class-tainacan-term.php index 0241c4fb2..7d4b55f2e 100644 --- a/src/classes/entities/class-tainacan-term.php +++ b/src/classes/entities/class-tainacan-term.php @@ -245,25 +245,19 @@ class Term extends Entity { } public function _toHtml() { - $return = ''; $id = $this->get_id(); if ( $id ) { - $link = get_term_link( (int) $id ); if (is_string($link)) { - $return = ""; $return.= $this->get_name(); $return .= ""; - } - } - return apply_filters('tainacan-term-to-html', $return, $this); - + return apply_filters('tainacan-term-to-html', $return, $this); } } diff --git a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php index 27ad6fd1c..031ca13c2 100644 --- a/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php +++ b/src/views/admin/components/metadata-types/taxonomy/class-tainacan-taxonomy.php @@ -332,9 +332,7 @@ class Taxonomy extends Metadata_Type { * @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page */ public function get_value_as_html(Item_Metadata_Entity $item_metadata) { - $value = $item_metadata->get_value(); - $return = ''; if ( $item_metadata->is_multiple() ) { @@ -345,7 +343,7 @@ class Taxonomy extends Metadata_Type { $separator = $item_metadata->get_multivalue_separator(); foreach ( $value as $term ) { - $count ++; + $count++; if ( is_integer($term) ) { $term = \Tainacan\Repositories\Terms::get_instance()->fetch($term, $this->get_option('taxonomy_id')); @@ -361,7 +359,6 @@ class Taxonomy extends Metadata_Type { } } } - } else { if ( $value instanceof \Tainacan\Entities\Term ) { $return .= $this->get_term_hierarchy_html($value); @@ -372,9 +369,7 @@ class Taxonomy extends Metadata_Type { } private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) { - $terms = []; - $terms[] = $this->term_to_html($term); while ($term->get_parent() > 0) { @@ -383,11 +378,9 @@ class Taxonomy extends Metadata_Type { } $terms = \array_reverse($terms); - $glue = apply_filters('tainacan-terms-hierarchy-html-separator', ' > '); return \implode($glue, $terms); - } private function term_to_html($term) { diff --git a/tests/test-item-metadata.php b/tests/test-item-metadata.php index b2ffacc21..75c1a1356 100644 --- a/tests/test-item-metadata.php +++ b/tests/test-item-metadata.php @@ -659,4 +659,30 @@ class Item_Metadata extends TAINACAN_UnitTestCase { return "${title}"; } + + function test_taxonomy_metadata_html() { + $taxonomy = $this->tainacan_entity_factory->create_entity( + 'taxonomy', + array( + 'name' => 'My Taxonomy test', + 'collections' => [$this->collection], + 'status' => 'publish' + ), + true + ); + + $meta = $this->tainacan_entity_factory->create_entity( + 'metadatum', + array( + 'name' => 'My tax meta', + 'status' => 'publish', + 'collection' => $this->collection, + 'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy', + 'metadata_type_options' => [ + 'taxonomy_id' => $taxonomy->get_id(), + ] + ), + true + ); + } } \ No newline at end of file