
<!doctype html>

<html <?php echo get_language_attributes(); ?>>
<?php echo $__env->make('partials.head', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<body id="method" <?php body_class('renewal2023') ?>><?php wp_body_open(); ?>
  <div class="pacewrap">

    <div id="container">
      <?php echo $__env->make('partials.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

      <article>

        <div class="page_titleheader">
          <div class="row row-0 position-relative">
            <p class="pagetitlebg_left col-md-4 plr-0"><img src="<?= App\asset_path('images/service/top_pattern_left.png'); ?>" alt=""></p>

            <div class="col-lg-3 col-md-11 offset-md-1 plr-0 align-self-center">
              <p class="pagetitlebg_right col-lg-4 col-md-12 plr-0"><img src="<?= App\asset_path('images/service/top_pattern_right.png'); ?>" alt=""></p>
              <h1 class="en weight_bold"><?php echo get_the_title(); ?></h1>
            </div>
            <div id="mv" class="col-lg-8 col-md-12 plr-0">
              <div class="mv">
              </div>
            </div>
          </div>
        </div>

        <section class="main" id="latest_news">
          <div class="row plr-0 col-lg-10 col-md-10 offset-md-1 col-sm-10 offset-sm-1 pb-5 pb-sm-0">
            <?php
            // ACFフィールドからデータを取得
            $show_sf = get_field('show_sf'); // 真偽値
            $sf_title = get_field('sf_title'); // タイトル
            $sf_url = get_field('sf_url'); // URL
            $sf_image = get_field('sf_image'); // 画像URL
            $sf_date = get_field('sf_date'); // 日付
            $sf_cat = get_field('sf_cat'); // カテゴリ
            $sf_target = get_field('sf_target'); // リンクターゲット（真偽値）
            
            // show_sfがtrueの場合のみコンテンツを表示
            if ($show_sf):
            ?>
            <!-- Special Feature -->
            <div class="container mb-5 pb-md-5 special_feature">
              <h2 class="page_title en">Special Feature</h2>

              <div class="d-lg-flex d-md-block d-sm-block flex-row-reverse align-items-center">
                <div class="col-lg-6 col-md-12 col-sm-12 my-3 my-lg-0 pr-0 pl-0 img-wrap">
                  <a href="<?php echo esc_url($sf_url); ?>" <?php echo $sf_target ? 'target="_blank"' : ''; ?>>
                    <img class="sf-thumb" src="<?php echo esc_url($sf_image); ?>" class="img-fluid lazyload"
                      alt="<?php echo esc_attr($sf_title); ?>"></a>
                </div>
                <div class="desc-wrap col-lg-6 offset-lg-0 col-md-12 offset-md-0 pr-0 pl-0 pr-md-5">
                  <div class="title">
                    <a href="<?php echo esc_url($sf_url); ?>" <?php echo $sf_target ? 'target="_blank"' : ''; ?>>
                      <h2 class="title weight_bold"><?php echo esc_html($sf_title); ?></h2>
                    </a>
                  </div>
                  <div>
                    <p class="d-flex">
                      <time class="en"><?php echo esc_html($sf_date); ?></time>
                      <?php if ($sf_cat): // カテゴリが存在する場合 ?>
                      <span class="cat"><?php echo esc_html($sf_cat); ?></span>
                      <?php endif; ?>
                    </p>
                    <a class="text_link en mt-lg-5 d-none d-lg-inline" href="<?php echo esc_url($sf_url); ?>" <?php echo $sf_target ? 'target="_blank"' : ''; ?>>
                      View More <i class="fas fa-chevron-right"></i>
                    </a>
                  </div>
                </div>
              </div>
            </div>
            <?php endif; ?>


            <!-- Voice一覧 -->
            <div class="container pb-5 pb-md-0">
              <h2 class="page_title title-with-link en mb-4">Voice<a
                  href="<?php echo e(home_url('/method/search/?category=voice')); ?>" class="text_link en">View
                  All <i class="fas fa-chevron-right"></i></a></h2>
              <div class="row post_row">
                <?php
                $post_data_array = voice_api_data(4);
                
                foreach ($post_data_array as $post_data) {
                    echo '<div class="col-lg-3 col-md-6 col-sm-12 post_box">';
                    echo '<a href="' . esc_url($post_data['link']) . '" class="thumbnail" target="_blank">';
                
                    if (!empty($post_data['thumbnail'])) {
                        echo '<img width="300" height="200" data-src="' . esc_url($post_data['thumbnail']) . '" data-srcset="' . esc_url($post_data['thumbnail']) . '"  alt="' . esc_html($post_data['title']) . '" class="img-fluid lazyload">';
                    }
                    echo '</a>';
                    if (!empty($post_data['date'])) {
                        echo '<time class="en">' . $post_data['date'] . '</time>';
                    }
                    echo '<h2><a href="' . esc_url($post_data['link']) . '">' . esc_html($post_data['title']) . '</a></h2>';
                    echo '</div>';
                }
                ?>
              </div>

              <div class="sp_titlelink"><a href="<?php echo e(home_url('/method/search/?category=voice')); ?>"
                  class="titlelink en">View All <i class="fas fa-chevron-right"></i></a>
              </div>
            </div>

            <!-- イベントセミナー一覧 -->
            <div class="container pb-5 pb-md-0">
              <h2 class="page_title title-with-link en mb-4">Event・Seminar<a
                  href="<?php echo e(home_url('/method/search/?category=seminar')); ?>" class="text_link en">View
                  All <i class="fas fa-chevron-right"></i></a></h2>
              <div class="row post_row">
                <?php
                // カスタム投稿タイプ news_release から カスタムタクソノミー ncat の投稿を取得
                $query = new WP_Query([
                    'post_type' => 'news_release', // カスタム投稿タイプ
                    'posts_per_page' => 4, // 取得する投稿数
                    'tax_query' => [
                        [
                            'taxonomy' => 'ncat', // カスタムタクソノミー
                            'field' => 'slug',
                            'terms' => 'seminar', // タクソノミーのスラグ名
                        ],
                    ],
                ]);
                
                while ($query->have_posts()):
                    $query->the_post();
                    echo '<div class="col-lg-3 col-md-6 col-sm-12 post_box">';
                    echo '<a href="' . esc_url(get_the_permalink()) . '" class="thumbnail" target="_blank">';
                
                    if (has_post_thumbnail()) {
                        the_post_thumbnail('medium', ['class' => 'img-fluid']);
                    }
                    echo '</a>';
                    echo '<time class="en">' . get_the_date('Y.m.d') . '</time>';
                    echo '<h2><a href="' . esc_url(get_the_permalink()) . '">' . get_the_title() . '</a></h2>';
                    echo '</div>';
                endwhile;
                
                // リセット投稿データ（重要）
                wp_reset_postdata();
                ?>
              </div>


              <div class="sp_titlelink"><a href="<?php echo e(home_url('/method/search/?category=seminar')); ?>"
                  class="titlelink en">View All</a>
              </div>
            </div>


            <!-- Studio Column一覧 -->
            <div class="container pb-5 pb-md-0">
              <h2 class="page_title title-with-link en mb-4">Column<a
                  href="<?php echo e(home_url('/method/search/?category=column')); ?>" class="text_link en">View
                  All <i class="fas fa-chevron-right"></i></a></h2>
              <div class="row post_row">
                <?php
                $post_data_array = api_data('https://bitstar.tokyo/studio/wp-json/wp/v2/column?_embed', 4);
                
                foreach ($post_data_array as $post_data) {
                    echo '<div class="col-lg-3 col-md-6 col-sm-12 post_box">';
                    echo '<a href="' . esc_url($post_data['link']) . '" class="thumbnail" target="_blank">';
                
                    if (!empty($post_data['thumbnail'])) {
                        echo '<img width="300" height="200" data-src="' . esc_url($post_data['thumbnail']) . '" data-srcset="' . esc_url($post_data['thumbnail']) . '"  alt="' . esc_html($post_data['title']) . '" class="img-fluid lazyload">';
                    }
                    echo '</a>';
                    if (!empty($post_data['date'])) {
                        echo '<time class="en">' . $post_data['date'] . '</time>';
                    }
                    echo '<h2><a href="' . esc_url($post_data['link']) . '">' . esc_html($post_data['title']) . '</a></h2>';
                    echo '</div>';
                }
                ?>
              </div>

              <div class="sp_titlelink"><a href="<?php echo e(home_url('/method/search/?category=column')); ?>"
                  class="titlelink en">View All</a>
              </div>
            </div>


            <!-- 資料DL 一覧 -->
            <div class="container">
              <h2 class="page_title title-with-link en mb-4">Download<a
                  href="<?php echo e(home_url('/method/search/?category=request')); ?>" class="text_link en">View
                  All <i class="fas fa-chevron-right"></i></a></h2>
              <div class="row post_row">
                <?php
                $post_data_array = api_data('https://bitstar.tokyo/wp-json/wp/v2/request?_embed', 4);
                
                foreach ($post_data_array as $post_data) {
                    echo '<div class="col-lg-3 col-md-6 col-sm-12 post_box">';
                    echo '<a href="' . esc_url($post_data['link']) . '" class="thumbnail" target="_blank">';
                
                    if (!empty($post_data['thumbnail'])) {
                        echo '<img width="300" height="200" data-src="' . esc_url($post_data['thumbnail']) . '" data-srcset="' . esc_url($post_data['thumbnail']) . '"  alt="' . esc_html($post_data['title']) . '" class="img-fluid lazyload">';
                    }
                    echo '</a>';
                    if (!empty($post_data['date'])) {
                        echo '<time class="en">' . $post_data['date'] . '</time>';
                    }
                    echo '<h2><a href="' . esc_url($post_data['link']) . '">' . esc_html($post_data['title']) . '</a></h2>';
                    echo '</div>';
                }
                ?>
              </div>

              <div class="sp_titlelink"><a href="<?php echo e(home_url('/method/search/?category=request')); ?>"
                  class="titlelink en">View All</a>
              </div>
            </div>


          </div>

        </section>
      </article>



      <?php do_action('get_footer') ?>
      <?php echo $__env->make('partials.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
      <?php wp_footer() ?>

    </div>
  </div>

  <!-- Start of HubSpot Embed Code -->
  <script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/40110885.js"></script>
  <!-- End of HubSpot Embed Code -->
</body>

</html>
