// see: https://basis.webers-testseite.de/

// register Widget Area 
function register_logo_widget_area() {
  register_sidebar(array(
    'name'          => 'Logo Widget Area',
    'id'            => 'logo_widget_area',
    'description'   => 'Widget Area im Logo Container',
    'before_widget' => '<section id="%1$s" class="widget clearfix %2$s">', 
    'after_widget'  => '<span class="seperator extralight-border"></span></section>', 
    'before_title'  => '<h3 class="widgettitle">', 
    'after_title'   => '</h3>',
  ));
}
add_action( 'widgets_init', 'register_logo_widget_area', 1001 );

// Insert widget area as sibling to anchor
function kriesi_logo_final_output($logo, $use_image, $headline_type, $sub, $alt, $link, $title) {
  // Optional: replace headline_type with div
  $logo_tag = 'div'; 
  
  if ( is_active_sidebar( 'logo_widget_area' ) ) {
    ob_start();
    dynamic_sidebar( 'logo_widget_area' );
    $widget_content = ob_get_clean();
    
    // Replace headline_type with your own tag and insert widget
    $logo = str_replace('<' . $headline_type, '<' . $logo_tag, $logo);
    $logo = str_replace('</' . $headline_type . '>', $widget_content . '</' . $logo_tag . '>', $logo);
  } else {
    // Replace the tag even without a widget
    $logo = str_replace('<' . $headline_type, '<' . $logo_tag, $logo);
    $logo = str_replace('</' . $headline_type . '>', '</' . $logo_tag . '>', $logo);
  }
  
  return $logo;
}
add_filter('avf_logo_final_output', 'kriesi_logo_final_output', 10, 7);
#top .logo {
  display: flex;
  flex-flow: row nowrap;
  justify-content: flex-start;
  align-content: center;
  align-items: center;
  gap: 20px;
}
#top .logo > a {
  display: flex;
  align-items: center;
  flex-shrink: 1;
}
#top .logo .widget {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: auto;
}
#top .logo .avia-buttonrow-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
}

#top .logo .widget .widgettitle {
  padding: 5px 0;
  margin-bottom: 5px
}