Adds option to display post featured image on the site header banner. #32

This commit is contained in:
mateuswetah 2021-04-23 14:29:10 -03:00
parent 0b223a7656
commit 217c100e7f
4 changed files with 30 additions and 4 deletions

View File

@ -494,7 +494,7 @@ nav {
nav.menu-belowheader {
.container-fluid {
margin: 0px 16px 0px 0px !important;
margin: 0px 16px 0px -6px !important;
}
#menubelowHeader > ul > li.menu-item {
padding-left: 0px;

View File

@ -599,6 +599,24 @@ function tainacan_customize_register( $wp_customize ) {
'fallback_refresh' => true
) );
/**
* Adds option to display featured image on site header
*/
$wp_customize->add_setting( 'tainacan_featured_image_on_header_banner', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'tainacan_callback_sanitize_checkbox'
) );
$wp_customize->add_control( 'tainacan_featured_image_on_header_banner', array(
'type' => 'checkbox',
'priority' => 99, // Within the section.
'section' => 'header_image',
'label' => __( 'Display post or page featured image on the header banner', 'tainacan-interface' ),
'description' => __( 'Toggle to display the current post or page featured image, if available on the header banner instead of the default image. This feature also hides the featured image in the post content.', 'tainacan-interface' )
) );
/**
* Bellow are customizer options exclusivelly related to Tainacan pages.
*/

View File

@ -1,5 +1,9 @@
<?php if ( false == get_theme_mod( 'tainacan_hide_header_banner', false ) ) : ?>
<?php if ( false == get_theme_mod( 'tainacan_hide_header_banner', false ) ) :
if ( !is_singular() || false == get_theme_mod('tainacan_featured_image_on_header_banner', false) || !has_post_thumbnail() ) : ?>
<div <?php if ( get_header_image() ) : ?>class="page-header header-filter clear-filter page-height" style="background-image: url('<?php header_image(); ?>')"<?php else : ?>class="page-header header-filter clear-filter align-items-center" style="background-image: url('<?php echo esc_url( get_template_directory_uri() ) ?>/assets/images/capa.png')"<?php endif; ?>>
<?php else: ?>
<div class="page-header header-filter clear-filter page-height" style="background-image: url('<?php echo get_the_post_thumbnail_url(); ?>')">
<?php endif; ?>
<div class="container-fluid p-0 ph-title-description">
<?php if ( false == get_theme_mod( 'tainacan_hide_site_title_on_header_banner', false ) ) : ?>
<div

View File

@ -33,7 +33,11 @@
</button>
</div>
</div>
<?php the_post_thumbnail(); ?>
<?php
if ( get_theme_mod('tainacan_featured_image_on_header_banner', false) == false ) {
the_post_thumbnail();
}
?>
</header>
<?php endif; ?>
<section class="tainacan-content text-black margin-two-column">