/home/bdqbpbxa/demo-subdomains/u-pod.goodface.com.ua/wp-content/themes/upod/front-page.php
<?php
  /*
    template name: front-page
  */

  get_header();
?>

<?php 
  $lang = pll_current_language();
  $where_button = 'where_button-' . $lang;
  $where_button_obj = get_field($where_button, 'option');
?>

<main>

	<section class="main-section -white-block check-on-viewport">

		<div class="container">
			<div class="text-box animation">

				<h1 class="title title-1 mobile-1">
					<?php echo do_shortcode(get_field('main-title'));?>
				</h1>

				<p class="text text-1 mobile-1">
          <?php the_field('main_subtitle');?>
				</p>

				<div class="button-container">
					<a href="<?php echo $where_button_obj['url']?>" class="button -big">
            <?php echo $where_button_obj['title']?>
					</a>
				</div>

			</div>

			<div class="main-section__animation-container animation">

				<div class="main-section__animation-block">
					<div class="main-section__animation-list" style="animation-duration: 70s;">
            <?php
              $main_slider = get_field('main_slider');
							$slider_1 = $main_slider['slider_1'];
              foreach($slider_1 as $item):
								$product_img = get_field('product_img', $item);
            ?>
              <div class="main-section__animation-box">
                <img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
                <div class="main-section__animation-text">
                  <h5><?php the_field('product_name', $item);?></h5>
                  <p>
										<?php
											$price_edit = 'price_edit-' . $lang;
											$price_edit_obj = get_field($price_edit , 'option');
											echo $price_edit_obj['prefix'] . ' ';
										?>
										<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
									</p>
                </div>
              </div>
            <?php
              endforeach;
            ?>
					</div>

					<div class="main-section__animation-list" style="animation-duration: 70s;">
						<?php
								foreach($slider_1 as $item):
									$product_img = get_field('product_img', $item);
							?>
								<div class="main-section__animation-box">
								<img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
									<div class="main-section__animation-text">
										<h5><?php the_field('product_name', $item);?></h5>
										<p>
											<?php
												$price_edit = 'price_edit-' . $lang;
												$price_edit_obj = get_field($price_edit , 'option');
												echo $price_edit_obj['prefix'] . ' ';
											?>
											<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
										</p>
									</div>
								</div>
							<?php
								endforeach;
							?>
					</div>
				</div>

        <div class="main-section__animation-block">
					<div class="main-section__animation-list" style="animation-duration: 50s;">
						<?php
								$slider_2 = $main_slider['slider_2'];
								foreach($slider_2 as $item):
									$product_img = get_field('product_img', $item);
							?>
								<div class="main-section__animation-box">
								<img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
									<div class="main-section__animation-text">
										<h5><?php the_field('product_name', $item);?></h5>
										<p>
											<?php
												$price_edit = 'price_edit-' . $lang;
												$price_edit_obj = get_field($price_edit , 'option');
												echo $price_edit_obj['prefix'] . ' ';
											?>
											<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
										</p>
									</div>
								</div>
							<?php
								endforeach;
							?>
					</div>

					<div class="main-section__animation-list" style="animation-duration: 50s;">
						<?php
								foreach($slider_2 as $item):
									$product_img = get_field('product_img', $item);
							?>
								<div class="main-section__animation-box">
								<img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
									<div class="main-section__animation-text">
										<h5><?php the_field('product_name', $item);?></h5>
										<p>
											<?php
												$price_edit = 'price_edit-' . $lang;
												$price_edit_obj = get_field($price_edit , 'option');
												echo $price_edit_obj['prefix'] . ' ';
											?>
											<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
										</p>
									</div>
								</div>
							<?php
								endforeach;
							?>
					</div>
				</div>

				<div class="main-section__animation-block">
					<div class="main-section__animation-list" style="animation-duration: 70s;">
						<?php
								$slider_3 = $main_slider['slider_3'];
								foreach($slider_3 as $item):
									$product_img = get_field('product_img', $item);
							?>
								<div class="main-section__animation-box">
								<img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
									<div class="main-section__animation-text">
										<h5><?php the_field('product_name', $item);?></h5>
										<p>
											<?php
												$price_edit = 'price_edit-' . $lang;
												$price_edit_obj = get_field($price_edit , 'option');
												echo $price_edit_obj['prefix'] . ' ';
											?>
											<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
										</p>
									</div>
								</div>
							<?php
								endforeach;
							?>
					</div>

					<div class="main-section__animation-list" style="animation-duration: 70s;">
						<?php
								foreach($slider_3 as $item):
									$product_img = get_field('product_img', $item);
							?>
								<div class="main-section__animation-box">
								<img class="lazyload" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
								src="<?php echo $product_img['url'];?>" 
								alt="<?php echo $product_img['alt'];?>"
								>
									<div class="main-section__animation-text">
										<h5><?php the_field('product_name', $item);?></h5>
										<p>
											<?php
												$price_edit = 'price_edit-' . $lang;
												$price_edit_obj = get_field($price_edit , 'option');
												echo $price_edit_obj['prefix'] . ' ';
											?>
											<strong><?php the_field('product_price', $item);?></strong> <?php echo ' ' . $price_edit_obj['valuta'];?>
										</p>
									</div>
								</div>
							<?php
								endforeach;
							?>
					</div>
				</div>

			</div>

		</div>

	</section>

	<section class="brands-section">

		<div class="container animation">

			<div class="title-box">

				<h2 class="title title-2 mobile-2">    
          <?php echo do_shortcode(get_field('partners_title'));?>
				</h2>

			</div>

			<div class="brands-section__catalog">

			<?php
				$brand_list = get_field('brand_list');
				foreach($brand_list as $item):
					$brand_name = get_field('brand_name', $item);
					$brand_title = get_the_title($item);
			?>
				<a href="<?php echo get_permalink($item);?>" class="brands-section__brands">
					<div class="img">
							<?php
								$brand_preview = get_field('brand_preview', $item);
							?>
						<img class="brands lazyload" 
						src="<?php echo $brand_preview['url'];?>" 
						srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg"
						alt="<?php echo $brand_preview['alt'];?>"
						>
							<?php
								$brand_logo = get_field('brand_logo', $item);
							?>
						<img class="logo lazyload" src="<?php echo $brand_logo['url'];?>" 
						srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg"
						alt="<?php echo $brand_logo['alt'];?>"
						>
					</div>
					<div class="description">
						<h4 class="title">
							<?php echo $brand_name?>
							<?php
								$brand_country = get_field('brand_country', $item);
							?>
							<img class="lazyload" 
							src="<?php echo $brand_country['url'];?>" 
							srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
							alt="<?php echo $brand_country['alt'];?>">
						</h4>
						<div class="number-box">
							<div>
								<p>
									<?php
										$models_brand_page_title = 'models_brand_page_title-' . $lang;
										$models_brand_page_title_obj = get_field($models_brand_page_title, 'option');
										echo $models_brand_page_title_obj['plural_2'];
									?>:
								</p>
								<?php
									$global_model = [];
									$global_model_taste = [];
									$global_counter = 0;
									$posts = get_posts( array(
										'numberposts' => -1,
										'post_type'   => 'product',
										'meta_query' => [
											[
												'key' => 'brand',
												'value' => $item,
											],
										],
									) );
									foreach($posts as $post){
										setup_postdata($post);
										$brands = get_field('brand');
										$product_taste = get_field('product_taste');
										$global_model[] = get_the_title($brands);

										if ($global_counter == 0) {
											foreach($product_taste as $item) {
												$global_model_taste[get_the_title($brands)][] = $item['name'];
											}
										} else {
											foreach($global_model_taste as $key => $brand_model) {
												foreach($product_taste as $taste_item) {
													if (!in_array($taste_item['name'], $brand_model)) {
														$brand_model[] = $taste_item['name'];
													}
												}											
											}
										}

										$global_counter += 1;
									}
									wp_reset_postdata();

								?>
								<strong>
									<?php
										$count = array_count_values($global_model);
										echo $count[$brand_title];
									?>
								</strong>
							</div>
							<div>
								<p>
									<?php
										$models_brand_taste = 'models_brand_taste-' . $lang;
										$models_brand_taste_obj = get_field($models_brand_taste, 'option');
										echo $models_brand_taste_obj['plural_2'];
									?>:
								</p>
								<strong>
									<?php
										$taste_count = count($global_model_taste[$brand_title]);
										echo $taste_count;
									?>
								</strong>
							</div>
						</div>
					</div>

				</a>
			<?php
				endforeach;
			?>

        <div class="brands-section__brands for-partner">
					<div class="img">
						<?php
							$brand_parners_img = get_field('brand_parners_img');
						?>
						<img class="lazyload" 
						src="<?php echo $brand_parners_img['url']?>" 
						srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
						alt="<?php echo $brand_parners_img['alt']?>"
						>
					</div>
					<h5 class="title title-3 mobile-3">
						<?php the_field('brand_partners_title');?>
					</h5>
					<p class="text text-2 mobile-1">
						<?php the_field('brand_partners_subtitle');?>
					</p>
					<div class="button -big open-modal-window">
            <?php the_field('brand_partners_button');?>
					</div>
				</div>
			</div>
		</div>
	</section>

	

	<article class="benefits-section -white-block">

		<div class="container animation">

			<div class="title-box">

				<h2 class="title title-2 mobile-2">
          <?php echo do_shortcode(get_field('preferences_title'))?>
				</h2>

			</div>			

			<div class="benefits-block animation">
				<div class="img">
					<?php
						$preferences_img = get_field('preferences_img');
					?>
					<img class="lazyload" 
					src="<?php echo $preferences_img['url'];?>" 
					srcset="<?php echo $preferences_img['alt'];?>" 
					alt="Преимущества наших брендов - UPOD.com.ua"/>
				</div>

				
        <?php 
          $preferences_list = get_field('preferences_list');
        ?>
				<div class="benefits-text">
					<div class="benefits-text-box" id="benefits-text-top-left">
						<div class="line"></div>
						<p class="text">
							<?php echo $preferences_list['preferences_1']?>
						</p>
					</div>
					<div class="benefits-text-box" id="benefits-text-top-right">
						<div class="line"></div>
						<p class="text">
							<?php echo $preferences_list['preferences_2']?>
						</p>
					</div>
					<div class="benefits-text-box" id="benefits-text-bot-left">
						<div class="line"></div>
						<p class="text">
							<?php echo $preferences_list['preferences_3']?>
						</p>
					</div>
					<div class="benefits-text-box" id="benefits-text-bot-right">
						<div class="line"></div>
						<p class="text">
							<?php echo $preferences_list['preferences_4']?>
						</p>
					</div>
				</div>
			</div>

			<div class="button-container">
				<a href="<?php echo $where_button_obj['url']?>" class="button -big">
          <?php echo $where_button_obj['title']?>
				</a>
			</div>
		</div>
	</article>

	

	<div class="mission-section">

		<div class="container animation">

			<div class="title-box">

				<h2 class="title title-2 mobile-2">
          <?php the_field('UPOD_description')?>
				</h2>

			</div>

			

			<div class="mission-section__social-block">
				<p class="text text-2 mobile-2">
					<?php the_field('UPOD_description-soc_title')?>
				</p>

				<div class="mission-section__social">
          <?php
						if(get_field('instagram', 'option')):
					?>
            <a class="title title-3 mobile-3" href="<?php the_field('instagram', 'option')?>" target="_blank">
              <img class="lazyload" src="<?php echo get_template_directory_uri();?>/assets/img/index/instagram-color-icon.svg" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg"
                  alt="Instagram - UPOD.com.ua">
              instagram
            </a>
          <?php
						endif;
						if(get_field('fb', 'option')):
					?>
            <a class="title title-3 mobile-3" href="<?php the_field('fb', 'option')?>" target="_blank">
              <img class="lazyload" src="<?php echo get_template_directory_uri();?>/assets/img/index/facebook-color-icon.svg" srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg"
                  alt="Facebook - UPOD.com.ua">
              facebook
            </a>
          <?php
						endif;
					?>

				</div>

			</div>

			

			<div class="mission-section__img">
        <?php
          $UPOD_description_img = get_field('UPOD_description-img');
          foreach($UPOD_description_img as $key => $item):
					$value = ($key+1)/2;
          $value_replaced = str_replace('.', '', $value);
        ?>
          <div class="img parallax" data-enllax-ratio="0.<?php echo $value_replaced; ?>" data-enllax-type="foreground">
            <img class="lazyload" 
						src="<?php echo $item['url']?>" 
						srcset="<?php echo get_template_directory_uri();?>/assets/img/srcset.svg" 
						alt="<?php echo $item['alt']?>">
          </div>
        <?php endforeach;?>
			</div>

		</div>

	</div>


<?php
  get_footer();
?>