Modifies the logic for rendering item thumbnail inside first section.

This commit is contained in:
mateuswetah 2023-05-29 21:55:15 -03:00
parent 6ebca214e4
commit b3713dc22a
2 changed files with 22 additions and 57 deletions

View File

@ -43,7 +43,10 @@ if ( TAINACAN_BLOCKSY_IS_CHILD_THEME || ( TAINACAN_BLOCKSY_IS_BLOCKSY_ACTIVATED
if ( !TAINACAN_BLOCKSY_IS_CHILD_THEME ) { if ( !TAINACAN_BLOCKSY_IS_CHILD_THEME ) {
/* Disables Tainacan Theme Helper the_content filter, which is used to build a custom item and taxonomy (terms list) template. */ /* Disables Tainacan Theme Helper the_content filter, which is used to build a custom item and taxonomy (terms list) template. */
if ( !defined('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER') )
define('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER', true); define('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER', true);
if ( !defined('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER') )
define('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER', true); define('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER', true);
require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/plugin.php'; require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/plugin.php';

View File

@ -10,52 +10,16 @@
in_array($section_layout, ['metadata-section-type-2', 'metadata-section-type-3', 'metadata-section-type-4']) && in_array($section_layout, ['metadata-section-type-2', 'metadata-section-type-3', 'metadata-section-type-4']) &&
get_theme_mod($prefix . '_metadata_sections_separate_default_section', 'no') === 'yes'; get_theme_mod($prefix . '_metadata_sections_separate_default_section', 'no') === 'yes';
/** /**
* The new metadata sections function makes it a bit more complicated to add * The new metadata sections function makes it a bit more complicated to add
* the thumbnail in the middle of the metadata. * the thumbnail in the middle of the metadata.
* So we have some logic that is only needed if it is set. * So we have some logic that is only needed if it is set.
* The following uses a filter to add it right above the first metadatum in the first section. * The following uses a filter to add it right above the first metadatum in the default section.
**/ **/
if ( has_post_thumbnail() && $show_thumbnail_with_metadata ) { if ( has_post_thumbnail() && $show_thumbnail_with_metadata ) {
// Gets collection so we can obtain firtst metadatum add_filter('tainacan-get-metadata-section-as-html-before-metadata-list--index-0', function( $before_description, $metadata_section) {
$collection = tainacan_get_collection();
if ( !is_null($collection) ) {
// Gets array of metadata order
$metadata_order = $collection->get_metadata_order();
if ( is_array($metadata_order) ) {
$first_metadatum_id = -1;
foreach( $metadata_order as $metadatum ) {
// Checks if the metadata is enabled
if ( isset($metadatum['enabled']) && $metadatum['enabled'] && isset($metadatum['id']) ) {
$first_metadatum_id = $metadatum['id'];
// IF we are not displaying the title here, we must look for the second metadata
if ( $exclude_title_metadata ) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$metadatum_object = $Tainacan_Metadata->fetch($first_metadatum_id);
$metadata_type_object = $metadatum_object->get_metadata_type_object();
if ( $metadata_type_object->get_related_mapped_prop() == 'title' ) {
continue;
}
}
break;
}
}
if ( is_numeric($first_metadatum_id) && $first_metadatum_id >= 0 ) {
add_filter('tainacan-get-item-metadatum-as-html-before--id-' . $first_metadatum_id, function($before, $item_metadatum) {
ob_start(); ob_start();
?> ?>
@ -68,12 +32,10 @@
$extra_content = ob_get_contents(); $extra_content = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $extra_content . $before; return $before_description . $extra_content;
}, 10, 2); }, 10, 2);
}
}
}
} }
$metadata_args = array( $metadata_args = array(