Creates two new filters for manipulating $args in functions that render metadata section and item metadata.

This commit is contained in:
mateuswetah 2024-08-06 10:30:22 -03:00
parent a6a6e7b89e
commit c4d51afe63
1 changed files with 15 additions and 0 deletions

View File

@ -587,6 +587,7 @@ class Item extends Entity {
'metadatum_index' => null 'metadatum_index' => null
); );
$args = wp_parse_args($args, $defaults); $args = wp_parse_args($args, $defaults);
$item_metadata = array(); $item_metadata = array();
// If a single metadata is passed, we use it instead of fetching more // 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); $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']) { if ($item_metadatum->has_value() || !$args['hide_empty']) {
// Gets the metadata type object to use it if we need the slug // 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); $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 // Gets the metadata section inner metadata list
$metadata_section_metadata_list = $metadata_section->get_metadata_object_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 ); $has_metadata_list = (is_array($metadata_section_metadata_list) && count($metadata_section_metadata_list) > 0 );