From 1507b29cf1287a126a6b4954a47cf8ccf7e0f9c3 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 18 Dec 2020 10:35:59 -0300 Subject: [PATCH] feat: add document mimetype #456 --- src/classes/entities/class-tainacan-item.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index 2886a1627..cbdc9d495 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -57,7 +57,7 @@ class Item extends Entity { $array_item['url'] = get_permalink( $this->get_id() ); $array_item['creation_date'] = $this->get_date_i18n( explode( ' ', $array_item['creation_date'] )[0] ); $array_item['modification_date'] = $this->get_date_i18n( explode( ' ', $array_item['modification_date'] )[0] ); - + $array_item['document_mimetype'] = $this->get_document_mimetype(); return apply_filters('tainacan-item-to-array', $array_item, $this); } @@ -274,6 +274,15 @@ class Item extends Entity { return $this->get_mapped_property( 'document_type' ); } + /** + * Return the document mimetype + * + * @return string + */ + function get_document_mimetype() { + return $this->get_document_type() == 'attachment' ? get_post_mime_type($this->get_document()) : $this->get_document_type(); + } + /** * Return the item document *