<?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('testimonial') ) ? $confin_id : false;
$confin_meta  = get_post_meta( $confin_id, 'page_type_metabox', true );
if ($confin_meta) {
  $confin_topbar_options = $confin_meta['topbar_options'];
} else {
  $confin_topbar_options = '';
}
// Define Theme Options and Metabox varials in right way!
if ($confin_meta) {
  if ($confin_topbar_options === 'custom' && $confin_topbar_options !== 'default') {
    $confin_top_left          = $confin_meta['top_left'];
    $confin_top_right          = $confin_meta['top_right'];
    $confin_hide_topbar        = $confin_topbar_options;
    $confin_topbar_bg          = $confin_meta['topbar_bg'];
    if ($confin_topbar_bg) {
      $confin_topbar_bg = 'background-color: '. $confin_topbar_bg .';';
    } else {$confin_topbar_bg = '';}
  } else {
    $confin_top_left          = cs_get_option('top_left');
    $confin_top_right          = cs_get_option('top_right');
    $confin_hide_topbar        = cs_get_option('top_bar');
    $confin_topbar_bg          = '';
  }
} else {
  // Theme Options fields
  $confin_top_left         = cs_get_option('top_left');
  $confin_top_right          = cs_get_option('top_right');
  $confin_hide_topbar        = cs_get_option('top_bar');
  $confin_topbar_bg          = '';
}
// All options
if ( $confin_meta && $confin_topbar_options === 'custom' && $confin_topbar_options !== 'default' ) {
  $confin_top_right = ( $confin_top_right ) ? $confin_meta['top_right'] : cs_get_option('top_right');
  $confin_top_left = ( $confin_top_left ) ? $confin_meta['top_left'] : cs_get_option('top_left');
} else {
  $confin_top_right = cs_get_option('top_right');
  $confin_top_left = cs_get_option('top_left');
}
if ( $confin_meta && $confin_topbar_options !== 'default' ) {
  if ( $confin_topbar_options === 'hide_topbar' ) {
    $confin_hide_topbar = 'hide';
  } else {
    $confin_hide_topbar = 'show';
  }
} else {
  $confin_hide_topbar_check = cs_get_option( 'top_bar' );
  if ( $confin_hide_topbar_check === true ) {
     $confin_hide_topbar = 'hide';
  } else {
     $confin_hide_topbar = 'show';
  }
}
if ( $confin_meta ) {
  $confin_topbar_bg = ( $confin_topbar_bg ) ? $confin_meta['topbar_bg'] : '';
} else {
  $confin_topbar_bg = '';
}
if ( $confin_topbar_bg ) {
  $confin_topbar_bg = 'background-color: '. $confin_topbar_bg .';';
} else { $confin_topbar_bg = ''; }

if( $confin_top_left || $confin_top_right ) {
?>
 <!-- header top area start -->
  <div class="topbar" style="<?php echo esc_attr( $confin_topbar_bg ); ?>">
      <div class="container">
          <div class="row">
              <?php if($confin_top_left) { ?>
              <div class="col col-sm-7">
                   <?php echo do_shortcode( $confin_top_left ); ?>
              </div>
              <?php } if($confin_top_right) { ?>
              <div class="col col-sm-5">
                <div class="social-quote">
                   <?php echo do_shortcode( $confin_top_right ); ?>
                  </div>
              </div>
              <?php } ?>
          </div>
      </div>
  </div>
<!-- header top area end -->
<?php } // Hide Topbar - From Metabox