<?php
// Metabox
global $post;
$confin_id    = ( isset( $post ) ) ? $post->ID : false;
$confin_id    = ( is_home() ) ? get_option( 'page_for_posts' ) : $confin_id;
$confin_id    = ( ! is_tag() && ! is_archive() && ! is_search() && ! is_404() && ! is_singular('service') ) ? $confin_id : false;
$confin_meta  = get_post_meta( $confin_id, 'page_type_metabox', true );
// Header Style
if ( $confin_meta ) {
  $confin_header_design  = $confin_meta['select_header_design'];
} else {
  $confin_header_design  = cs_get_option( 'select_header_design' );
}

if ( $confin_header_design === 'default' ) {
  $confin_header_design_actual  = cs_get_option( 'select_header_design' );
} else {
  $confin_header_design_actual = ( $confin_header_design ) ? $confin_header_design : cs_get_option('select_header_design');
}
$confin_header_design_actual = $confin_header_design_actual ? $confin_header_design_actual : 'style_two';

$confin_logo = cs_get_option( 'confin_logo' );
$confin_trlogo = cs_get_option( 'confin_trlogo' );
$logo_url = wp_get_attachment_url( $confin_logo );
$logo_alt = get_post_meta( $confin_logo, '_wp_attachment_image_alt', true );
$trlogo_url = wp_get_attachment_url( $confin_trlogo );
$trlogo_alt = get_post_meta( $confin_trlogo, '_wp_attachment_image_alt', true );

if ( $logo_url ) {
  $logo_url = $logo_url;
} else {
 $logo_url = CONFIN_IMAGES.'/logo.png';
}

if ( $trlogo_url ) {
  $trlogo_url = $trlogo_url;
} else {
 $trlogo_url = CONFIN_IMAGES.'/tr-logo.png';
}

if ( $confin_header_design_actual == 'style_three' ) {
  $confin_logo_url = $trlogo_url;
  $confin_logo_alt = $trlogo_alt;
} else {
  $confin_logo_url = $logo_url;
  $confin_logo_alt = $logo_alt;
}

if ( has_nav_menu( 'primary' ) ) {
  $logo_padding = ' has_menu ';
}
else {
   $logo_padding = ' dont_has_menu ';
}


// Logo Spacings
// Logo Spacings
$confin_brand_logo_top = cs_get_option( 'confin_logo_top' );
$confin_brand_logo_bottom = cs_get_option( 'confin_logo_bottom' );
if ( $confin_brand_logo_top ) {
  $confin_brand_logo_top = 'padding-top:'. confin_check_px( $confin_brand_logo_top ) .';';
} else { $confin_brand_logo_top = ''; }
if ( $confin_brand_logo_bottom ) {
  $confin_brand_logo_bottom = 'padding-bottom:'. confin_check_px( $confin_brand_logo_bottom ) .';';
} else { $confin_brand_logo_bottom = ''; }
if ( $confin_logo ) {
?>
  <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>"  style="<?php echo esc_attr( $confin_brand_logo_top.$confin_brand_logo_bottom ); ?>">
    <img src="<?php echo esc_url( $confin_logo_url ); ?>" alt=" <?php echo esc_attr( $confin_logo_alt ); ?>">
  </a>
<?php 
} elseif( has_custom_logo() ) {
      the_custom_logo();
} else {
?>
  <a class="navbar-brand" href="<?php echo esc_url( home_url( '/' ) ); ?>"  style="<?php echo esc_attr( $confin_brand_logo_top.$confin_brand_logo_bottom ); ?>">
    <img src="<?php echo esc_url( $confin_logo_url ); ?>" alt="<?php echo get_bloginfo('name'); ?>">
  </a>
<?php
}
