Last active
February 7, 2020 11:28
-
-
Save Fobiya/9f11328a377b4fd3207baf449c344e79 to your computer and use it in GitHub Desktop.
wp ajax scroll section
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript'> | |
$( document ).ready(function() { | |
$('footer').addClass('none'); | |
var anchors = []; | |
var currentAnchor = -1; | |
var isAnimating = false; | |
$(function(){ | |
function updateAnchors() { | |
anchors = []; | |
$('section').each(function(i, element){ | |
anchors.push( $(element).offset().top ); | |
}); | |
} | |
$('body').on('mousewheel', function(e){ | |
if( isAnimating ) { | |
return false; | |
} | |
isAnimating = true; | |
// Increase or reset current anchor | |
if( e.originalEvent.wheelDelta >= 0 ) { | |
}else{ | |
var button = $(this), | |
data = { | |
'action': 'homer', | |
'section': '1', | |
'lang': <?php $my_current_lang = apply_filters('wpml_current_language', NULL); echo "'" . $my_current_lang . "'" ; ?> | |
}; | |
$.ajax({ // you can also use $.post here | |
url: ajax_url, | |
data : data, | |
type : 'POST', | |
beforeSend : function ( xhr ) { | |
// button.text('Loading...'); | |
}, | |
success : function( data ){ | |
document.querySelector('.sec_1').innerHTML = data; | |
$('.sec_1').removeClass('none').removeClass('sec_1').addClass('home__section_1').addClass('section__'); | |
$('.ion-ios-arrow-right').click(function() { | |
$home_contacts.slick('slickNext'); | |
}); | |
$('.ion-ios-arrow-left').click(function() { | |
$home_contacts.slick('slickPrev'); | |
}); | |
var $home_contacts = $('.home_contacts'); | |
$(document).ready(function() { | |
$home_contacts.slick({ | |
arrows: false, | |
dots: false, | |
autoplay: false, | |
speed: 900, | |
infinite: true, | |
slidesToShow: 1, | |
slidesToScroll: 1, | |
}); | |
}); | |
} | |
}); | |
} | |
if( currentAnchor > (anchors.length - 1) | |
|| currentAnchor < 0 ) { | |
currentAnchor = 0; | |
} | |
isAnimating = true; | |
}); | |
updateAnchors(); | |
}); | |
var ajax_url = "<?= admin_url('admin-ajax.php'); ?>"; | |
// let number = document.querySelector('a.link_calendar').dataset.section; | |
$(window).on('scroll',function(){ | |
var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop(); | |
if( scrollBottom < '1' && $('.home__section_1') ){ | |
var button = $(this), | |
data = { | |
'action': 'homer', | |
'section': '2', | |
'lang': <?php $my_current_lang = apply_filters('wpml_current_language', NULL); echo "'" . $my_current_lang . "'" ; ?> | |
}; | |
$.ajax({ // you can also use $.post here | |
url: ajax_url, | |
data : data, | |
type : 'POST', | |
beforeSend : function ( xhr ) { | |
// button.text('Loading...'); | |
}, | |
success : function( data ){ | |
document.querySelector('.sec_2').innerHTML = data; | |
document.querySelector('.sec_2').innerHTML = data; | |
$('.sec_2').removeClass('none').addClass('home__section_2').addClass('section__'); | |
} | |
}); | |
$(window).off('scroll'); | |
} | |
}); | |
$(window).on('scroll',function(){ | |
var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop(); | |
if( scrollBottom < '1' && $('.home__section_2') ){ | |
var button = $(this), | |
data = { | |
'action': 'homer', | |
'section': '3', | |
'lang': <?php $my_current_lang = apply_filters('wpml_current_language', NULL); echo "'" . $my_current_lang . "'" ; ?> | |
}; | |
$.ajax({ // you can also use $.post here | |
url: ajax_url, | |
data : data, | |
type : 'POST', | |
beforeSend : function ( xhr ) { | |
// button.text('Loading...'); | |
}, | |
success : function( data ){ | |
document.querySelector('.sec_3').innerHTML = data; | |
document.querySelector('.sec_3').innerHTML = data; | |
$('.sec_3').removeClass('none').addClass('home__section_3').addClass('section__'); | |
$('.ion-ios-arrow-right').click(function() { | |
$home_contacts.slick('slickNext'); | |
}); | |
$('.ion-ios-arrow-left').click(function() { | |
$home_contacts.slick('slickPrev'); | |
}); | |
var $home_contacts = $('.home_contacts'); | |
$(document).ready(function() { | |
$home_contacts.slick({ | |
arrows: false, | |
dots: false, | |
autoplay: false, | |
speed: 900, | |
infinite: true, | |
slidesToShow: 1, | |
slidesToScroll: 1, | |
}); | |
}); | |
} | |
}); | |
$(window).off('scroll') | |
} | |
}); | |
$(window).on('scroll',function(){ | |
var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop(); | |
if( scrollBottom < '1' && $('.home__section_3') ){ | |
$('footer').removeClass('none'); | |
} | |
}); | |
}); | |
</script> | |
/----------------------------------------------------------------- FUNCTION PHP ---------------------------------------------- | |
function home_pages() { | |
//.$_POST['section'] | |
//$getid = get_the_ID(); | |
if ( $_POST['lang'] == 'en' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'en' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'ru' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'ru' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'es' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'es' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'ar' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'ar' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'de' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'de' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'it' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'it' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'pl' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'pl' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
if ( $_POST['lang'] == 'pt-pt' ){ | |
$my_current_lang = apply_filters( 'wpml_current_language', NULL ); //Store current language | |
do_action( 'wpml_switch_language', 'pt-pt' ); //Switch to the language in which post exist | |
$query = new WP_Query( 'page_id=9' ); | |
while ( $query->have_posts() ) : $query->the_post(); | |
//$reg_link = get_permalink(get_field('registration_page', 'options')); | |
// check if the flexible content field has rows of data | |
if (have_rows('home_pages')) : | |
// loop through the rows of data | |
while (have_rows('home_pages')) : the_row(); ?> | |
<?php | |
if ( $_POST['section'] == '1' ){ | |
if ( get_row_layout() == 'home_section_'.$_POST['section'] ) : | |
?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<?php the_sub_field('content'); ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
<div class="col-xs-12 col-md-6 col-lg-6 col-xl-6 "> | |
<div class="box__img"> | |
<picture> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" media="(min-width: 801px)"> | |
<source srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2-mob.png" media="(max-width: 800px)"> | |
<img class="images_1" srcset="<?php echo get_template_directory_uri(); ?>/img/home-section2.png" alt="images_1"> | |
</picture> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '2' ){ | |
if (get_row_layout() == 'home_section_2') : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<div class="block__content"> | |
<p><?php the_sub_field('content'); ?></p> | |
</div> | |
</div> | |
</div> | |
<div class="row"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); ?> | |
<div class="col-xs-12 col-md-6 col-lg-4 col-xl-4"> | |
<div class="box__content"> | |
<h4><?php echo '0' . get_row_index(); ?></h4> | |
<h3><?php the_sub_field('title'); ?></h3> | |
<p><?php the_sub_field('paragraph'); ?></p> | |
<?php if (get_row_index() == '1') $two = 'Register Now'; | |
if (get_row_index() == '2') $two = 'Start Browsing'; | |
if (get_row_index() == '3') $two = 'Join Now'; ?> | |
<?= do_shortcode("[cta class='iris_blue' tittle='" . $two . "']"); ?> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
?> | |
<?php | |
if ( $_POST['section'] == '3' ){ | |
if (get_row_layout() == 'home_section_3' ) : ?> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<h2><?php the_sub_field('title'); ?></h2> | |
<p><?php the_sub_field('text_content'); ?></p> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12 col-md-12 col-lg-12 col-xl-12"> | |
<a class="arrow ion-ios-arrow-left"></a> | |
<a class="arrow ion-ios-arrow-right"></a> | |
<div class="home_contacts"> | |
<?php if (have_rows('box_list')) : ?> | |
<?php while (have_rows('box_list')) : the_row(); | |
// vars | |
$title = get_sub_field('title'); | |
$post = get_sub_field('post'); | |
$paragraph = get_sub_field('paragraph'); ?> | |
<div> | |
<div class="box__content"> | |
<div class="box__img"> | |
<img src="<?php the_sub_field('images') ?>" alt="user" class="user"> | |
</div> | |
<div class="box__info"> | |
<h4 class="name"><?php echo $title; ?></h4> | |
<span class="post"><?php echo $post; ?></span> | |
<p><?php echo $paragraph; ?></p> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div> | |
<?= do_shortcode("[cta class='iris_blue' tittle='Join Now']"); ?> | |
</div> | |
</div> | |
</div> | |
<?php | |
endif; | |
} | |
endwhile; | |
endif; | |
endwhile; | |
do_action( 'wpml_switch_language', $my_current_lang ); //Switch again to current language | |
} | |
wp_die(); | |
} | |
add_action( 'wp_ajax_nopriv_homer', 'home_pages', 7778889 ); | |
add_action( 'wp_ajax_homer', 'home_pages', 7778889 ); | |
/----------------------------------------------------------------- END FUNCTION PHP ---------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment