From fea2fd50c8b69cca351cadf0d283e1c479a9a563 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 14 Sep 2021 13:45:28 -0300 Subject: [PATCH 1/2] feat: add document in exposers json --- src/classes/exposers/class-tainacan-json-flat.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/classes/exposers/class-tainacan-json-flat.php b/src/classes/exposers/class-tainacan-json-flat.php index e3dae58ac..607868b33 100644 --- a/src/classes/exposers/class-tainacan-json-flat.php +++ b/src/classes/exposers/class-tainacan-json-flat.php @@ -59,10 +59,23 @@ class JSON_flat extends Exposer { ); } ); + $item_document = array( + 'type' => $item['document_type'], + 'value' => '' + ); + if($item_document['type'] == 'url') { + $item_document['value'] = $item['document']; + } elseif ( $item_document['type'] == 'text' ) { + $item_document['value'] = $item['document_as_html']; + } elseif ( $item_document['type'] == 'attachment' ) { + $item_document['value'] = wp_get_attachment_url($item['document']); + } + return [ 'id' => $item['id'], 'data' => $item_data, 'url' => $item['url'], + 'document' => $item_document, 'thumbnail' => isset($item['_thumbnail_id']) ? wp_get_attachment_image_src($item['_thumbnail_id'], 'full') : false, 'creation_date' => isset($item['creation_date']) ? $item['creation_date'] : '', 'modification_date' => isset($item['modification_date']) ? $item['modification_date'] : '' From 880bcfe7b78caf6591f95c1fb86d30e5b554d103 Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 14 Sep 2021 13:48:51 -0300 Subject: [PATCH 2/2] feat: tainacan override set log slug --- src/classes/tainacan-utils.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/classes/tainacan-utils.php b/src/classes/tainacan-utils.php index acdb51d0e..5094a6ca4 100644 --- a/src/classes/tainacan-utils.php +++ b/src/classes/tainacan-utils.php @@ -37,4 +37,16 @@ if(!function_exists("is_post_status_viewable")) { return $post_status->publicly_queryable || ( $post_status->_builtin && $post_status->public ); } -} \ No newline at end of file +} + + +function tainacan_set_log_slug( $override, $slug, $post_ID, $post_status, $post_type, $post_parent ) { + if ( 'tainacan-log' === $post_type ) { + if ( $post_ID ) { + return uniqid( $post_type . '-' . $post_ID ); + } + return uniqid( $post_type . '-' ); + } + return $override; +} +add_filter( 'pre_wp_unique_post_slug', 'tainacan_set_log_slug', 10, 6 ); \ No newline at end of file