Modifies the logic for rendering item thumbnail inside first section.
This commit is contained in:
parent
6ebca214e4
commit
b3713dc22a
|
@ -43,8 +43,11 @@ if ( TAINACAN_BLOCKSY_IS_CHILD_THEME || ( TAINACAN_BLOCKSY_IS_BLOCKSY_ACTIVATED
|
|||
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. */
|
||||
define('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER', true);
|
||||
define('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER', true);
|
||||
if ( !defined('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER') )
|
||||
define('TAINACAN_DISABLE_ITEM_THE_CONTENT_FILTER', true);
|
||||
|
||||
if ( !defined('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER') )
|
||||
define('TAINACAN_DISABLE_TAXONOMY_THE_CONTENT_FILTER', true);
|
||||
|
||||
require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/plugin.php';
|
||||
}
|
||||
|
|
|
@ -10,70 +10,32 @@
|
|||
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';
|
||||
|
||||
|
||||
/**
|
||||
* The new metadata sections function makes it a bit more complicated to add
|
||||
* the thumbnail in the middle of the metadata.
|
||||
* 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 ) {
|
||||
|
||||
// Gets collection so we can obtain firtst metadatum
|
||||
$collection = tainacan_get_collection();
|
||||
add_filter('tainacan-get-metadata-section-as-html-before-metadata-list--index-0', function( $before_description, $metadata_section) {
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="tainacan-item-section__metadata-thumbnail">
|
||||
<h3 class="tainacan-metadata-label"><?php _e( 'Thumbnail', 'tainacan-blocksy' ); ?></h3>
|
||||
<p class="tainacan-metadata-value"><?php the_post_thumbnail('tainacan-medium-full'); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$extra_content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $before_description . $extra_content;
|
||||
|
||||
if ( !is_null($collection) ) {
|
||||
}, 10, 2);
|
||||
|
||||
// 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();
|
||||
?>
|
||||
<div class="tainacan-item-section__metadata-thumbnail">
|
||||
<h3 class="tainacan-metadata-label"><?php _e( 'Thumbnail', 'tainacan-blocksy' ); ?></h3>
|
||||
<p class="tainacan-metadata-value"><?php the_post_thumbnail('tainacan-medium-full'); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$extra_content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $extra_content . $before;
|
||||
|
||||
}, 10, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$metadata_args = array(
|
||||
|
|
Loading…
Reference in New Issue