<?php
$topbar_layout = rwmb_meta("mb-topbar-layout", ["object_type" => "setting"], "options");
if ($topbar_layout !== "topbar-none") { ?>

<div id="topbar">
  <div class="container">
    <div class="row">
      <?php
      if ($topbar_layout == "topbar-left") {
        echo '<div class="topbar-left">';
        $topbar_left_items = rwmb_meta("topbar-items-left", ["object_type" => "setting"], "options");
        foreach ($topbar_left_items as $topbar_left_item) {
          if (empty($topbar_left_item[1])) {
            echo '<span class="' . $topbar_left_item[2] . '">' . $topbar_left_item[0] . "</span>";
          } else {
            echo '<a class="' . $topbar_left_item[2] . '" href="' . $topbar_left_item[1] . '">' . $topbar_left_item[0] . "</a>";
          }
        }
        echo "</div>";
      }
      if ($topbar_layout == "topbar-center") {
        echo '<div class="topbar-center">';
        $topbar_center_items = rwmb_meta("topbar-items-center", ["object_type" => "setting"], "options");
        foreach ($topbar_center_items as $topbar_center_item) {
          if (empty($topbar_center_item[1])) {
            echo '<span class="' . $topbar_center_item[2] . '">' . $topbar_center_item[0] . "</span>";
          } else {
            echo '<a class="' . $topbar_center_item[2] . '" href="' . $topbar_center_item[1] . '">' . $topbar_center_item[0] . "</a>";
          }
        }
        echo "</div>";
      }
      if ($topbar_layout == "topbar-right") {
        echo '<div class="topbar-right">';
        $topbar_right_items = rwmb_meta("topbar-items-right", ["object_type" => "setting"], "options");
        foreach ($topbar_right_items as $topbar_right_item) {
          if (empty($topbar_right_item[1])) {
            echo '<span class="' . $topbar_right_item[2] . '">' . $topbar_right_item[0] . "</span>";
          } else {
            echo '<a class="' . $topbar_right_item[2] . '" href="' . $topbar_right_item[1] . '">' . $topbar_right_item[0] . "</a>";
          }
        }
        echo "</div>";
      }
      if ($topbar_layout == "topbar-both") {
        echo '<div class="topbar-left">';
        $topbar_left_items = rwmb_meta("topbar-items-left", ["object_type" => "setting"], "options");
        foreach ($topbar_left_items as $topbar_left_item) {
          if (empty($topbar_left_item[1])) {
            echo '<span class="' . $topbar_left_item[2] . '">' . $topbar_left_item[0] . "</span>";
          } else {
            echo '<a class="' . $topbar_left_item[2] . '" href="' . $topbar_left_item[1] . '">' . $topbar_left_item[0] . "</a>";
          }
        }
        echo "</div>";
        echo '<div class="topbar-right">';
        $topbar_right_items = rwmb_meta("topbar-items-right", ["object_type" => "setting"], "options");
        foreach ($topbar_right_items as $topbar_right_item) {
          if (empty($topbar_right_item[1])) {
            echo '<span class="' . $topbar_right_item[2] . '">' . $topbar_right_item[0] . "</span>";
          } else {
            echo '<a class="' . $topbar_right_item[2] . '" href="' . $topbar_right_item[1] . '">' . $topbar_right_item[0] . "</a>";
          }
        }
        echo "</div>";
      }
      ?>
    </div>
  </div>
</div>

<?php }
?>