From 4f8785fbee171516bc03a56e75e8d89e284c0d8c Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Tue, 6 Aug 2024 10:30:22 -0300 Subject: [PATCH] Creates two new filters for manipulating $args in functions that render metadata section and item metadata. --- src/classes/entities/class-tainacan-item.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index 2c9b58f5d..a8fb33fdb 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -587,6 +587,7 @@ class Item extends Entity { 'metadatum_index' => null ); $args = wp_parse_args($args, $defaults); + $item_metadata = array(); // If a single metadata is passed, we use it instead of fetching more @@ -749,6 +750,13 @@ class Item extends Entity { ); $args = wp_parse_args($args, $defaults); + /** + * Filter the arguments passed to the get_item_metadatum_as_html function + * @param array $args The arguments passed to the function + * @param object $metadata_section The Item Metadatum object + */ + $args = apply_filters( 'tainacan-get-item-metadatum-as-html-filter-args', $args, $item_metadatum ); + if ($item_metadatum->has_value() || !$args['hide_empty']) { // Gets the metadata type object to use it if we need the slug @@ -1230,6 +1238,13 @@ class Item extends Entity { ); $args = wp_parse_args($args, $defaults); + /** + * Filter the arguments passed to the get_metadata_section_as_html function + * @param array $args The arguments passed to the function + * @param object $metadata_section The Metadata Section object + */ + $args = apply_filters( 'tainacan-get-metadata-section-as-html-filter-args', $args, $metadata_section ); + // Gets the metadata section inner metadata list $metadata_section_metadata_list = $metadata_section->get_metadata_object_list(); $has_metadata_list = (is_array($metadata_section_metadata_list) && count($metadata_section_metadata_list) > 0 );