Skip to content

Instantly share code, notes, and snippets.

@sulmanpucit
Created March 12, 2021 19:45
Show Gist options
  • Save sulmanpucit/7ba72b750aa9f4600dd7cf01a79ff373 to your computer and use it in GitHub Desktop.
Save sulmanpucit/7ba72b750aa9f4600dd7cf01a79ff373 to your computer and use it in GitHub Desktop.
<?php
// Template Name: Service Directory
?>
<?php get_header(); ?>
<?php
/**
* Instantiate the Avada_Contact class
*/
//$avada_contact = new Avada_Contact();
?>
<div id="content" <?php Avada()->layout->add_style('content_style'); ?>>
<?php
while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php echo avada_render_rich_snippets_for_pages(); ?>
<?php //echo avada_featured_images_for_pages();
register_session();
// echo home_url($wp->request);
$query_args = array();
$query = wp_parse_url( $YOUR_URL );
$permalink = get_option( 'permalink_structure' );
if ( empty( $permalink ) ) {
$query_args = $query['query'];
}
// echo home_url( add_query_arg( $query_args , $wp->request ) );
$slug = (get_query_var('u')) ? get_query_var('u') : '';
// print_r($_SESSION);
if($slug!=$_SESSION['slug']){
$_SESSION=array();
}
$_SESSION['slug']= $slug;
$pageRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && ($_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0' || $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache');
if ($pageRefreshed == 1) {
// echo "Yes page Refreshed";
$_SESSION['area']='';
$_SESSION['lod_amen_array']='';
} else {
//enter code here
// echo "No";
}
// print_r($_SESSION);
global $post;
$media_meta = get_post_meta($post->ID, 'post_media', TRUE);
$intro_text = get_post_meta($post->ID, 'post_field_intro_text', true);
$header_width = get_post_meta($post->ID, 'pyre_header_100_width', true);
if ($header_width == 'yes') {
$header = 'fusion-row-no';
} else {
$header = 'fusion-row';
}
/*featured images*/
$media = array();
if (has_post_thumbnail()) {
$full_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$media[] = $full_image[0];
}
$feat_2 = Avada()->settings->get('posts_slideshow_number');
$x = 2;
while ($x <= $feat_2) {
$attachment_new_id = kd_mfi_get_featured_image_id('featured-image-' . $x, 'post');
if ($attachment_new_id) {
$full_images = wp_get_attachment_image_src($attachment_new_id, 'full');
$media[] = $full_images[0];
}
$x++;
}
if (count($media) == 1) {
$nav_status = false;
}
$theme_title_on = Avada()->settings->get('page_title_bar_text');
$page_title_on = get_post_meta($post->ID, 'pyre_page_title', true);
if (count($media) > 1) {
$head_class = "featured-slider";
} else {
$head_class = "featured-img";
}
if (!empty($media)) {
?>
<div class="post-image-banner <?php echo $header . ' ' . $head_class; ?>">
<?php
if (count($media) == 1) {
foreach ($media as $media_url) {
$url = $media_url;
echo '<div class="single-feat-img"><img src="' . $url . '" alt="Blog Slideshow Post"/></div>';
}
} elseif (count($media) > 1) {
echo '<div class="fusion-flexslider fusion-flexslider-loading flexslider-posts-with-excerpt">';
echo '<ul class="slides">';
foreach ($media as $media_url) {
$url = $media_url;
echo '<li>';
echo '<img src="' . $url . '" alt="Blog Slideshow Post"/>';
echo '<div class="slide-excerpt">';
echo '<div class="excerpt-container">';
//echo '<p>'.$intro_text.'</p>';
echo '</div>';
echo '</div>';
echo '</li>';
}
echo '</ul>';
echo '<div class="fusion-clearfix"></div>';
echo '</div>';
/*if(($theme_title_on == 1) && ($page_title_on != 'no')){
echo '<div class="single-img-title"><h1>'.get_the_title($post->ID).'</h1></div>';
}*/
}
?>
</div>
<?php
} // !empty($media)
?>
<div class="list-title post-content">
<?php
// print_r($loc_area);
$slug = (get_query_var('u')) ? get_query_var('u') : '';
if ($slug != '') {
$directAttr = get_term_by('slug', $slug, 'directory_attributes');
if (!empty($directAttr)) {
echo '<div class="page-title"><h1>' . $directAttr->name . '</h1></div>';
filter_listings_title($directAttr->name);
} else {
// echo '<div class="page-title"><h1>' . get_the_title($post->ID) . '</h1></div>';
echo '<div class="page-title"><h1>Not found category ' . ($slug) . '</h1></div>';
}
} else {
$urlEncode = '';
$slug = $urlEncode;
// echo '<div class="page-title"><h1>' . get_the_title($post->ID) . '</h1></div>';
}
?>
</div>
<div class="fusion-panel panel-default fusion-faq-post history ">
<?php
$lod_type = 'lod-type';
$sort = (get_query_var('sort')) ? get_query_var('sort') : '';
// $sort=$_GET['sort'];
$ascsortclass = "asc-sort";
$descsortclass = "desc-sort";
if ($sort == 'asc') {
$ascsortclass = $ascsortclass . " sort-active";
$descsortclass = "desc-sort";
} else if ($sort == 'desc') {
$ascsortclass = "asc-sort";
$descsortclass = $descsortclass . " sort-active";
}
// if (!empty($_GET['lod-type'])) {
if (!empty($lod_type)&&!empty($directAttr)) { ?>
<div class="clearfix log-items clear">
<?php
echo '<div class="check-form">';
// lodging type
$lod_type_array = $term_object->term_id; ?>
<form name="form1" method="post">
<div class="form-wrap">
<?php //echo '<div class="row clearfix lod-tpfm">';
echo '<div class="select-wrap">';
echo '<select name="area">';
$loc_area = $_POST['area'];
if(empty($loc_area)){
$loc_area=$_SESSION['area'];
}else{
$_SESSION['area']=$loc_area;
}
if (empty($loc_area)) {
$loc_area = 'null';
}
$checked_1 = '';
$checked_2 = '';
$checked_3 = '';
if (!empty($loc_area)) {
if ($loc_area == 'null') {
$checked_1 = 'selected';
} elseif ($loc_area == 'local') {
$checked_2 = 'selected';
} elseif ($loc_area == 'ooa') {
$checked_3 = 'selected';
}
} else {
$checked_1 = 'selected';
$checked_2 = '';
$checked_3 = '';
}
echo '<option value="null" ' . $checked_1 . '>LOCATION</option>';
echo '<option value="local" ' . $checked_2 . '>IN LEAVENWORTH</option>';
echo '<option value="ooa" ' . $checked_3 . '>NEARBY & OUT-OF-TOWN</option>';
echo '</select>';
// lodging aminity
$args2 = array(
'type' => 'listings',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'lodging_attributes',
'pad_counts' => false
);
echo '<select name="lod-amen[]"><option selected="selected" disabled>Choose your amenities</option>';
$categories2 = get_categories($args2);
$lod_amen_array = $_POST['lod-amen'];
if (empty($lod_amen_array)) {
$lod_amen_array = $_SESSION['lod_amen_array'];
} else {
$_SESSION['lod_amen_array'] = $lod_amen_array;
}
foreach ($categories2 as $aminity_cat) {
if (!empty($lod_amen_array)) {
if (in_array($aminity_cat->term_id, $lod_amen_array)) {
$checked1 = 'selected';
} else {
$checked1 = '';
}
}
echo '<option value="' . $aminity_cat->term_id . '" ' . $checked1 . '>' . $aminity_cat->name . '</option>';
}
echo '</select>';
$slugUrl = (get_query_var('u')) ? '/' . get_query_var('u') : '';
$sort = (get_query_var('sort')) ? "/sort/" . get_query_var('sort') : '';
$pagedno = (get_query_var('paged')) ? "/page/" . get_query_var('paged') : '';
$siteUrl = get_site_url() . '/listings' . $slugUrl;
$ascUrl = $siteUrl . '/sort/asc' . $pagedno;
//$descUrl = $siteUrl . '/sort/desc' . $pagedno;
$descUrl = $siteUrl . $pagedno;
// echo get_current_page_url();
/*
echo '<div class="sort-name">';
echo '<a class="' . $ascsortclass . '" href="' . $ascUrl . '">';
echo '<span >';
echo 'Ascending';
echo '</span>';
echo '</a>';
echo '<a class="' . $descsortclass . '" href="' . $descUrl . '">';
echo '<span >';
echo 'Descending';
echo '</span>';
echo '</a>';
echo '</div>';
*/
echo '<div class="sort-name"><b>Alphabetical order</b>';
if(empty($sort)){
echo '<a class="' . $ascsortclass . '" href="' . $ascUrl . '"><span >Ascending</span></a>';
}else{
echo '<a class="' . $descsortclass . '" href="' . $descUrl . '"><span >Descending</span></a>';
}
// echo '<a class="' . $ascsortclass . '" href="' . $ascUrl . '"><span >Ascending</span></a>';
// echo '<a class="' . $descsortclass . '" href="' . $descUrl . '"><span >Descending</span></a>';
echo '</div>';
echo '</div>';
echo '<input type="submit" name="submit" value="Search Button" id="submit" class="fusion-button-wrapper button-flat button-round button-large button-default button-1">'; ?>
</div>
</form>
<?php
echo '</div>';
?>
</div>
<?php } ?>
<div class="post-content">
<?php if (($theme_title_on == 1) && ($page_title_on != 'no')) {
// echo '<div class="page-title"><h1>' . get_the_title($post->ID) . '</h1></div>';
} ?>
<?php the_content(); ?>
<?php
$lod_type_array = $term_object->term_id;
$lod_amen_array = $_POST['lod-amen'];
if (empty($lod_amen_array)) {
$lod_amen_array = $_SESSION['lod_amen_array'];
} else {
$_SESSION['lod_amen_array'] = $lod_amen_array;
}
$sort = (get_query_var('sort')) ? get_query_var('sort') : '';
// $sort=$_GET['sort'];
// print_r($sort);
$OrderBy = 'meta_value_num rand';
$order = 'rand';
$orderNonfeatured = 'desc';
$orderByNonfeatured = 'date';
if ($sort != '') {
if ($sort == 'asc') {
$order = 'ASC';
$OrderBy = 'name';
$orderByNonfeatured = 'name';
$orderNonfeatured = 'ASC';
} else if ($sort == 'desc') {
// print_r("sadjbs");
$order = 'DESC';
$OrderBy = 'name';
$orderByNonfeatured='name';
$orderNonfeatured = 'DESC';
}
}
$loc_area = $_POST['area'];
if(empty($loc_area)){
$loc_area=$_SESSION['area'];
}else{
$_SESSION['area']=$loc_area;
}
if (empty($loc_area)) {
$loc_area = 'null';
}
$category = array(136, 162);
$groupcat = array(29);
// $slug='bed__breakfast';
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$countlistargs = array(
'post_type' => 'listings',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'list_membership',
'value' => array(0),
'compare' => 'IN',
),
)
);
$grouplistargsFeatured = array(
'post_type' => 'listings',
'posts_per_page' => -1,
'post_status' => 'publish',
// 'paged' => $paged,
'order' => $order,
// 'orderby' => 'meta_value_num rand',
'orderby' => $OrderBy,
// 'order'=> 'DESC',
// 'orderby' => 'meta_value',
'meta_query' => array(
array(
'key' => 'list_membership',
'value' => array(4, 5, 6, 7),
'compare' => 'IN',
),
)
);
$grouplistargsNonFeatured = array(
'post_type' => 'listings',
'posts_per_page' => 20,
'post_status' => 'publish',
'paged' => $paged,
'order' => $orderNonfeatured,
// 'orderby' => 'meta_value_num rand',
'orderby' => $orderByNonfeatured,
// 'order'=> 'DESC',
// 'orderby' => 'meta_value',
'meta_query' => array(
array(
'key' => 'list_membership',
'value' => array(0),
'compare' => 'IN',
),
)
);
if ($slug != '') {
$grouplistargsFeatured['tax_query'] = array(
array(
'taxonomy' => 'directory_attributes',
'field' => 'slug',
'operator' => 'IN',
// 'terms' => $groupcat,
'terms' => $slug
// 'terms' => $groupcat,
),
// array(
// 'taxonomy' => 'directory_attributes',
// 'field' => 'id',
// 'terms' => $lod_type_array
// )
);
$grouplistargsNonFeatured['tax_query'] = array(
array(
'taxonomy' => 'directory_attributes',
'field' => 'slug',
'operator' => 'IN',
// 'terms' => $groupcat,
'terms' => $slug
// 'terms' => $groupcat,
)
);
$countlistargs['tax_query'] = array(
array(
'taxonomy' => 'directory_attributes',
'field' => 'slug',
'operator' => 'IN',
// 'terms' => $groupcat,
'terms' => $slug
// 'terms' => $groupcat,
)
);
}
$the_query = new WP_Query($countlistargs);
// print_r(count($the_query));
$main_query = $the_query->posts;
$pids = array();
foreach ($main_query as $main_val) {
$pid = $main_val->ID;
$bid = get_post_meta($pid, 'business_listing', true);
$aminity_db_val = get_post_meta($pid, 'field_lodging_amenities_list', true);
if (!empty($lod_amen_array)) {
if (!empty($aminity_db_val)) {
$lod_amen_array_cnt = count($lod_amen_array);
$result = array_intersect($lod_amen_array, $aminity_db_val);
$res_cnt = count($result);
if ($lod_amen_array_cnt == $res_cnt) {
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
//elseif($loc_area == 'ooa') { $pids[] = $pid; }
} else {
$pids[] = $pid;
}
$i++;
}
}
} // if $lod_amen_array
else {
$pid = $main_val->ID;
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
} else {
$pids[] = $pid;
}
} // else $lod_amen_array
}
$the_query->found_posts = count($pids);
$grpostsfeatured_array = get_posts($grouplistargsFeatured);
// print_r($grpostsfeatured_array);
$grpostsnonfeatured_array = get_posts($grouplistargsNonFeatured);
$main_query = $grpostsfeatured_array;
$pids = array();
foreach ($main_query as $main_val) {
$pid = $main_val->ID;
$bid = get_post_meta($pid, 'business_listing', true);
$aminity_db_val = get_post_meta($pid, 'field_lodging_amenities_list', true);
if (!empty($lod_amen_array)) {
if (!empty($aminity_db_val)) {
$lod_amen_array_cnt = count($lod_amen_array);
$result = array_intersect($lod_amen_array, $aminity_db_val);
$res_cnt = count($result);
if ($lod_amen_array_cnt == $res_cnt) {
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
//elseif($loc_area == 'ooa') { $pids[] = $pid; }
} else {
$pids[] = $pid;
}
$i++;
}
}
} // if $lod_amen_array
else {
$pid = $main_val->ID;
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
} else {
$pids[] = $pid;
}
} // else $lod_amen_array
} // for each
//Service Directory
$args12 = array(
'type' => 'listings',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'parent' => 9,
'exclude' => array(136,203),
'include' => '',
'number' => '',
'taxonomy' => 'directory_attributes',
'pad_counts' => false
);
$categories1 = get_categories( $args12 );
$args133 = array(
'type' => 'listings',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 1,
'parent' => 2,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'directory_attributes',
'pad_counts' => false
);
$categories2 = get_categories( $args133 );
$categories = array_merge($categories1,$categories2);
$sorted_categories = array();
foreach($categories1 as $cat1){
$sorted_categories[$cat1->term_id] = array('term_id' => $cat1->term_id, 'name' => $cat1->name, 'slug' => $cat1->slug);
}
$temp_categories = array();
foreach ($sorted_categories as $key => $row)
{
$temp_categories[$key] = $row['name'];
}
array_multisort($temp_categories, SORT_ASC, $sorted_categories);
if(empty($_GET['cat_id'])) {
echo '<div class="ser-row col-md-3"><div class="service-cats clearfix">';
foreach($sorted_categories as $cat) {
$cat_link = get_category_link( $cat["term_id"] );
$ser_terms[] = $cat["term_id"];
if($_GET['cat_id'] == $cat["term_id"]) { $active= 'active'; }
else { $active= ''; }
echo '<div class="fusion-button-wrapper '.$active.'">';
//<a href="?cat_id='.$cat->term_id.'/#serv-result" class="button-flat button-round button-large button-default button-1">
echo '<a href="'.$cat_link.'" class="button-flat button-round button-large button-default button-1">';
echo '<span class="fusion-button-text">'.$cat["name"].'</span>
</a>
</div>';
}
echo '</div></div>';
}
//Featuerd Listing
echo '<div class="col-md-9 listings-wrapper">';
echo '<div class="featured-list">';
echo '<div class="list-wrap">';
// print_r("all");
// print_r($allpostArray);
// print_r($pids);
$mapLoad=false;
for ($i = 0; $i < count($pids) && $i < 9; $i++) {
// print_r($grpostsnonfeatured_array);
$pid = $pids[$i];
$post_det = get_post($pid);
$bid = get_post_meta($pid, 'business_listing', true);
$business_post = get_post($bid);
//print_r($post_det);
$title = $post_det->post_title;
$content = $post_det->post_content;
$trimContent=substr($post_det->post_content,0,200);
$post_author_id = $post_det->post_author;
$email = get_post_meta($bid, 'business_e-mail', 'true');
$business_tel = get_post_meta($bid, 'business_phone', 'true');
$secondary_phone = get_post_meta($bid, 'business_secondary_phone', TRUE);
$website = get_post_meta($bid, 'business_website', 'true');
//Listing details
$listing_email = get_post_meta($pid, 'listing_email', 'true');
$listing_primary_phone = get_post_meta($pid, 'listing_primary_phone', true);
$listing_secondary_phone = get_post_meta($pid, 'listing_secondary_phone', true);
$listing_website = get_post_meta($pid, 'listing_website', 'true');
//Assigning values either from listing or from business
$email = ($listing_email) ? $listing_email : $email;
$business_tel = ($listing_primary_phone) ? $listing_primary_phone : $business_tel;
$secondary_phone = ($listing_secondary_phone) ? $listing_secondary_phone : $secondary_phone;
$website = ($listing_website) ? $listing_website : $website;
$membership = get_post_meta($pid, 'list_membership', true);
$img_url = wp_get_attachment_url(get_post_thumbnail_id($pid));
if ($membership == 4 || $membership == 5 || $membership == 6 || $membership == 7) {
$h3class = 'class="icon"';
} else {
$h3class = '';
}
if ($membership == 4 || $membership == 5 || $membership == 6 || $membership == 7) {
$deatured_post = true;
// echo "featured";
$feclass = 'fea-listing';
} else {
$deatured_post = false;
$feclass = 'nonfea-listing';
}
echo '<div class="item"><div class="list-popup">';
if ($deatured_post == true) {
echo '<span class="feali">Featured</span>';
}
$aminity_db_val1 = get_post_meta($pid, 'field_lodging_amenities_list', true);
$img_url = wp_get_attachment_url(get_post_thumbnail_id($pid));
if (!empty($img_url)) {
$onclick = '';
if ($title == 'Mountain Springs Lodge') {
$onclick = 'onClick="ga(\'send\', \'event\', { eventCategory: \'Outbound\', eventAction: \'Link-click-image\', eventLabel: \'Mt-Springs\'});"';
}
echo '<a class="utm-ser-img" href="' . $website . '" target="_blank" ' . $onclick . ' ><img width="100%" src="' . $img_url . '"> </a>';
}
echo '<div class="inner">';
echo '<h3 ' . $h3class . '>' . $title . '</h3>';
get_post_meta($pid, 'list_membership', true);
echo '<p class="full-content">' . $content . '</p>';
if(!empty($website)){
// $website = addhttp($website);
$httpwebsite = $website;
// $httpwebsite = addhttp($httpwebsite);
$httpwebsite = preg_replace("(^(http|https)://)", "", $httpwebsite );
$httpwebsite = preg_replace("(^www.)", "", $httpwebsite );
$httpwebsite="www.".$httpwebsite;
echo '<p class="website"><a target="_blank" href="' . addhttp($website) . '" >' . $httpwebsite . '</a></p>';
}
$sleep = get_post_meta($pid, 'field_sleep', true);
if (!empty($sleep)) {
echo '<b>Sleep up to' . $sleep . '</b>';
}
echo '<div class="acc-content">';
$aminity_db_val1 = get_post_meta($pid, 'field_lodging_amenities_list', true);
if (!empty($aminity_db_val1)) {
echo '<p><b>Amenities</b></p><ul class="amen-list">';
foreach ($aminity_db_val1 as $lod) {
$terms = get_term_by('id', $lod, 'lodging_attributes');
if (!empty($terms)) {
echo '<li>' . $t_name = $terms->name . '</li>';
$t_slug = $terms->slug;
}
}
}
echo '</ul><ul class="contact-details">';
if (!empty($business_tel)) {
echo '<li><b>Contact</b><a href="tel:' . $business_tel . '" class="phone">' . $business_tel . '</a></lo>';
}
if (!empty($secondary_phone)) {
echo '<li><b>Contact</b><a href="tel:' . $secondary_phone . '" class="phone">' . $secondary_phone . '</a></li>';
}
// echo '</ul>';
//business
$post_author_id = $post_det->post_author;
$physicaladdress_line = get_post_meta($bid, 'physical_address_line_one', TRUE);
$physicaladdress_city = get_post_meta($bid, 'p_city', TRUE);
$physicaladdress_state = get_post_meta($bid, 'p_state_or_province', TRUE);
$physicaladdress_postcode = get_post_meta($bid, 'p_postal_code', TRUE);
$social_urls = get_post_meta($bid, 'business_social', TRUE);
//listing
$physicaladdress_listing_line1 = get_post_meta($pid, 'listing_address1', true);
$physicaladdress_listing_city = get_post_meta($pid, 'listing_city', true);
$physicaladdress_listing_state = get_post_meta($pid, 'listing_state', TRUE);
if ($physicaladdress_listing_state == 'null')
$physicaladdress_listing_state = '';
$physicaladdress_listing_postcode = get_post_meta($pid, 'listing_zip_code', true);
$listing_social_urls = get_post_meta($pid, 'listing_social', true);
$physicaladdress_line = ($physicaladdress_listing_line1) ? $physicaladdress_listing_line1 : $physicaladdress_line;
$physicaladdress_city = ($physicaladdress_listing_city) ? $physicaladdress_listing_city : $physicaladdress_city;
$physicaladdress_state = ($physicaladdress_listing_state) ? $physicaladdress_listing_state : $physicaladdress_state;
$physicaladdress_postcode = ($physicaladdress_listing_postcode) ? $physicaladdress_listing_postcode : $physicaladdress_postcode;
if (!empty($listing_social_urls)) {
$social_urls = $listing_social_urls;
}
// echo '<div class="social-wrap">';
if (!empty($website)) {
/*$web = substr($website,0,3);
if($web == 'www' || $web != 'htt') {
$website = 'http://'.$website;
}
echo '<a target="_blank" href="'.$website.'"><span class="icon"><i class="fa fa-globe"></i></span><span class="icon-title">Website</span></a>';*/
$website = addhttp($website);
$onclick = '';
if ($title == 'Mountain Springs Lodge') {
$onclick = 'onClick="ga(\'send\', \'event\', { eventCategory: \'Outbound\', eventAction: \'Link-click-text\', eventLabel: \'Mt-Springs\'});"';
}
echo '<li><p><b>Website</b><a target="_blank" href="' . $website . '" ' . $onclick . ' >' . $website . '</a></p></li>';
}
if (!empty($email)) {
echo '<li><p><b>Email</b><a target="_blank" href="mailto:' . $email . '">' . $email . '</a></p></li>';
}
echo '</ul>';
if (!empty($social_urls)) {
echo '<ul class="social-details">';
if (!empty($listing_social_urls)) {
$sval = 'listing_social';
} else {
$sval = 'business_social';
}
foreach ($social_urls as $social_links) {
//$social_links_value = $social_links['business_social'];
$social_links_value = $social_links[$sval];
$str = preg_replace('#^https?://#', '', rtrim($social_links_value, '/'));
$explode = explode('www.', $str);
if (!empty($explode[1])) {
$explode1 = explode('.com/', $explode[1]);
$spanclas = $explode1[0];
} else {
$explode1 = explode('.com/', $explode[0]);
$spanclas = $explode1[0];
}
$social_val = substr($social_links_value, 0, 3);
if ($social_val == 'www' || $social_val != 'htt') {
$social_links_value = 'http://' . $social_links_value;
}
echo '<li><a class="utm-web" target="_blank" href="' . $social_links_value . '">' . $spanclas . '</a></li>';
}
echo '</ul>';
}
if ((!empty($address)) && ($hide_phy == 'No')) {
echo '<p><b>Getting Here</b></p>';
echo '<div class="map-wrap">';
$address_formatted = str_replace(' ', '+', $address);
$address_formatted = str_replace(',', '+', $address_formatted);
$title_formatted = str_replace(' ', '+', $title);
$map_value = $title_formatted . '+' . $address_formatted;
// echo '<p><iframe src="https://www.google.com/maps/embed?q='.$map_value.' width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" tabindex="0"></iframe></p>';
// echo '<p><iframe src="https://maps.google.com/maps/embed?pb=' . $map_value . '"></iframe></p>';
// echo '<p><iframe src="https://maps.google.com/maps/embed/place/' . $map_value . '"></iframe></p>';
// echo 'https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
// &markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
// &markers=color:red%7Clabel:C%7C40.718217,-73.998284';
// echo '<iframe width="600" height="450" frameborder="0" style="border:0" src="https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
// &markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
// &markers=color:red%7Clabel:C%7C40.718217,-73.998284" allowfullscreen></iframe>';
// if($mapLoad==false){
echo '<iframe width="600" height="450" frameborder="0" style="border:0" data-src="https://www.google.com/maps/embed/v1/place?key='. Avada()->settings->get( 'gmap_api' ) .'&q=' . $map_value . '" allowfullscreen></iframe>';
$mapLoad=true;
// }
echo '</div>';
echo '<p>'.$map_value.'</p>';
}
if (!empty($physicaladdress_line) || !empty($physicaladdress_city) || !empty($physicaladdress_state) || !empty($physicaladdress_postcode)) {
$address = $physicaladdress_line . ', ' . $physicaladdress_city . ' ' . $physicaladdress_state . ' ' . $physicaladdress_postcode;
if (!empty($address)) {
$hide_phy = get_post_meta($bid, 'hide_physical_address', TRUE);
if ($hide_phy == 'No')
echo '<p class="wed-address">' . $address . '</p>';
elseif ($hide_phy == 'Custom') {
$custom_text_val = get_post_meta($bid, 'physical_address_custom_text', TRUE);
if ($custom_text_val != '')
echo '<p class="wed-address">' . $custom_text_val . '</p>';
}
//else
//echo '<div class="wed-address">See Website</div>';
}
}
// echo '</div></div>';
echo '</div>';
echo '<div class="read-more"><span class="see-more">See More Details</span><span class="plus-btn"></span><span class="hide-dtl">Hide Details</span></div></div>';
echo '</div>';
echo '</div>'; //clearfix
}
echo '</div>';
echo '</div>'; // featured
//NON featuered listing
echo '<div class="non-featured-list">';
echo '<div class="list-wrap">';
// print_r("all");
// print_r($allpostArray);
$main_query = $grpostsnonfeatured_array;
$pids = array();
foreach ($main_query as $main_val) {
$pid = $main_val->ID;
$bid = get_post_meta($pid, 'business_listing', true);
$aminity_db_val = get_post_meta($pid, 'field_lodging_amenities_list', true);
if (!empty($lod_amen_array)) {
if (!empty($aminity_db_val)) {
$lod_amen_array_cnt = count($lod_amen_array);
$result = array_intersect($lod_amen_array, $aminity_db_val);
$res_cnt = count($result);
if ($lod_amen_array_cnt == $res_cnt) {
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
//elseif($loc_area == 'ooa') { $pids[] = $pid; }
} else {
$pids[] = $pid;
}
$i++;
}
}
} // if $lod_amen_array
else {
$pid = $main_val->ID;
$post_author_id = $main_val->post_author;
$region = get_post_meta($bid);
$location = $region['region'][0];
if ($loc_area != 'null') {
if ($loc_area == $location) {
$pids[] = $pid;
}
} else {
$pids[] = $pid;
}
} // else $lod_amen_array
}
for ($i = 0; $i < count($pids); $i++) {
// print_r($grpostsnonfeatured_array);
$pid = $pids[$i];
$post_det = get_post($pid);
$bid = get_post_meta($pid, 'business_listing', true);
$business_post = get_post($bid);
//print_r($post_det);
$title = $post_det->post_title;
$content = $post_det->post_content;
$post_author_id = $post_det->post_author;
$email = get_post_meta($bid, 'business_e-mail', 'true');
$business_tel = get_post_meta($bid, 'business_phone', 'true');
$secondary_phone = get_post_meta($bid, 'business_secondary_phone', TRUE);
$website = get_post_meta($bid, 'business_website', 'true');
//Listing details
$listing_email = get_post_meta($pid, 'listing_email', 'true');
$listing_primary_phone = get_post_meta($pid, 'listing_primary_phone', true);
$listing_secondary_phone = get_post_meta($pid, 'listing_secondary_phone', true);
$listing_website = get_post_meta($pid, 'listing_website', 'true');
//Assigning values either from listing or from business
$email = ($listing_email) ? $listing_email : $email;
$business_tel = ($listing_primary_phone) ? $listing_primary_phone : $business_tel;
$secondary_phone = ($listing_secondary_phone) ? $listing_secondary_phone : $secondary_phone;
$website = ($listing_website) ? $listing_website : $website;
$membership = get_post_meta($pid, 'list_membership', true);
$img_url = wp_get_attachment_url(get_post_thumbnail_id($pid));
if ($membership == 4 || $membership == 5 || $membership == 6 || $membership == 7) {
$h3class = 'class="icon"';
} else {
$h3class = '';
}
if ($membership == 4 || $membership == 5 || $membership == 6 || $membership == 7) {
$deatured_post = true;
// echo "featured";
$feclass = 'fea-listing';
} else {
$deatured_post = false;
$feclass = 'nonfea-listing';
}
echo '<div class="item"><div class="list-popup">';
if ($deatured_post == true) {
echo '<span class="feali">Featured</span>';
}
$aminity_db_val1 = get_post_meta($pid, 'field_lodging_amenities_list', true);
$img_url = wp_get_attachment_url(get_post_thumbnail_id($pid));
if (!empty($img_url)) {
$onclick = '';
if ($title == 'Mountain Springs Lodge') {
$onclick = 'onClick="ga(\'send\', \'event\', { eventCategory: \'Outbound\', eventAction: \'Link-click-image\', eventLabel: \'Mt-Springs\'});"';
}
echo '<a class="utm-ser-img" href="' . $website . '" target="_blank" ' . $onclick . ' ><img width="100%" src="' . $img_url . '"> </a>';
}
echo '<div class="inner">';
echo '<h3 ' . $h3class . '>' . $title . '</h3>';
get_post_meta($pid, 'list_membership', true);
// echo '<p>' . $content . '</p>';
echo '<p class="full-content">' . $content . '</p>';
if(!empty($website)){
// $website = addhttp($website);
$httpwebsite = $website;
// $httpwebsite = addhttp($httpwebsite);
$httpwebsite = preg_replace("(^(http|https)://)", "", $httpwebsite );
$httpwebsite = preg_replace("(^www.)", "", $httpwebsite );
$httpwebsite="www.".$httpwebsite;
echo '<p class="website"><a target="_blank" href="' . addhttp($website) . '" >' . $httpwebsite . '</a></p>';
}
$sleep = get_post_meta($pid, 'field_sleep', true);
if (!empty($sleep)) {
echo '<b>Sleep up to' . $sleep . '</b>';
}
echo '<div class="acc-content">';
$aminity_db_val1 = get_post_meta($pid, 'field_lodging_amenities_list', true);
if (!empty($aminity_db_val1)) {
echo '<p><b>Amenities</b></p><ul class="amen-list">';
foreach ($aminity_db_val1 as $lod) {
$terms = get_term_by('id', $lod, 'lodging_attributes');
if (!empty($terms)) {
echo '<li>' . $t_name = $terms->name . '</li>';
$t_slug = $terms->slug;
}
}
}
echo '</ul><ul class="contact-details">';
if (!empty($business_tel)) {
echo '<li><b>Contact</b><a href="tel:' . $business_tel . '" class="phone">' . $business_tel . '</a></lo>';
}
if (!empty($secondary_phone)) {
echo '<li><b>Contact</b><a href="tel:' . $secondary_phone . '" class="phone">' . $secondary_phone . '</a></li>';
}
echo '</ul>';
//business
$post_author_id = $post_det->post_author;
$physicaladdress_line = get_post_meta($bid, 'physical_address_line_one', TRUE);
$physicaladdress_city = get_post_meta($bid, 'p_city', TRUE);
$physicaladdress_state = get_post_meta($bid, 'p_state_or_province', TRUE);
$physicaladdress_postcode = get_post_meta($bid, 'p_postal_code', TRUE);
$social_urls = get_post_meta($bid, 'business_social', TRUE);
//listing
$physicaladdress_listing_line1 = get_post_meta($pid, 'listing_address1', true);
$physicaladdress_listing_city = get_post_meta($pid, 'listing_city', true);
$physicaladdress_listing_state = get_post_meta($pid, 'listing_state', TRUE);
if ($physicaladdress_listing_state == 'null')
$physicaladdress_listing_state = '';
$physicaladdress_listing_postcode = get_post_meta($pid, 'listing_zip_code', true);
$listing_social_urls = get_post_meta($pid, 'listing_social', true);
$physicaladdress_line = ($physicaladdress_listing_line1) ? $physicaladdress_listing_line1 : $physicaladdress_line;
$physicaladdress_city = ($physicaladdress_listing_city) ? $physicaladdress_listing_city : $physicaladdress_city;
$physicaladdress_state = ($physicaladdress_listing_state) ? $physicaladdress_listing_state : $physicaladdress_state;
$physicaladdress_postcode = ($physicaladdress_listing_postcode) ? $physicaladdress_listing_postcode : $physicaladdress_postcode;
if (!empty($listing_social_urls)) {
$social_urls = $listing_social_urls;
}
echo '<div class="social-wrap">';
if (!empty($website)) {
/*$web = substr($website,0,3);
if($web == 'www' || $web != 'htt') {
$website = 'http://'.$website;
}
echo '<a target="_blank" href="'.$website.'"><span class="icon"><i class="fa fa-globe"></i></span><span class="icon-title">Website</span></a>';*/
$website = addhttp($website);
$onclick = '';
if ($title == 'Mountain Springs Lodge') {
$onclick = 'onClick="ga(\'send\', \'event\', { eventCategory: \'Outbound\', eventAction: \'Link-click-text\', eventLabel: \'Mt-Springs\'});"';
}
echo '<p><b>Website</b><a target="_blank" href="' . $website . '" ' . $onclick . ' >' . $website . '</a></p>';
}
if (!empty($email)) {
echo '<p><b>Email</b><a target="_blank" href="mailto:' . $email . '">' . $email . '</a></p>';
}
if (!empty($social_urls)) {
echo '<ul class="social-details">';
if (!empty($listing_social_urls)) {
$sval = 'listing_social';
} else {
$sval = 'business_social';
}
foreach ($social_urls as $social_links) {
//$social_links_value = $social_links['business_social'];
$social_links_value = $social_links[$sval];
$str = preg_replace('#^https?://#', '', rtrim($social_links_value, '/'));
$explode = explode('www.', $str);
if (!empty($explode[1])) {
$explode1 = explode('.com/', $explode[1]);
$spanclas = $explode1[0];
} else {
$explode1 = explode('.com/', $explode[0]);
$spanclas = $explode1[0];
}
$social_val = substr($social_links_value, 0, 3);
if ($social_val == 'www' || $social_val != 'htt') {
$social_links_value = 'http://' . $social_links_value;
}
echo '<li><a class="utm-web" target="_blank" href="' . $social_links_value . '">' . $spanclas . '</a></li>';
}
echo '</ul>';
}
if ((!empty($address)) && ($hide_phy == 'No')) {
echo '<p><b>Getting Here</b></p>';
echo '<div class="map-wrap">';
$address_formatted = str_replace(' ', '+', $address);
$address_formatted = str_replace(',', '+', $address_formatted);
$title_formatted = str_replace(' ', '+', $title);
$map_value = $title_formatted . '+' . $address_formatted;
echo '<p><iframe width="600" height="450" frameborder="0" style="border:0" data-src="https://www.google.com/maps/embed/v1/place?key='. Avada()->settings->get( 'gmap_api' ) .'&q=' . $map_value . '" allowfullscreen></iframe></p>';
echo '</div>';
//echo '<p>'.$map_value.'"></p>';
}
if (!empty($physicaladdress_line) || !empty($physicaladdress_city) || !empty($physicaladdress_state) || !empty($physicaladdress_postcode)) {
$address = $physicaladdress_line . ', ' . $physicaladdress_city . ' ' . $physicaladdress_state . ' ' . $physicaladdress_postcode;
if (!empty($address)) {
$hide_phy = get_post_meta($bid, 'hide_physical_address', TRUE);
if ($hide_phy == 'No')
echo '<p class="wed-address">' . $address . '</p>';
elseif ($hide_phy == 'Custom') {
$custom_text_val = get_post_meta($bid, 'physical_address_custom_text', TRUE);
if ($custom_text_val != '')
echo '<p class="wed-address">' . $custom_text_val . '</p>';
}
//else
//echo '<div class="wed-address">See Website</div>';
}
}
echo '</div></div>';
echo '<div class="read-more"><span class="see-more">See More Details</span><span class="plus-btn"></span><span class="hide-dtl">Hide Details</span></div></div>';
echo '</div>';
echo '</div>'; //clearfix
}
echo '</div>';
echo '</div>'; //non featured
echo '</div>';
?>
</div>
<!-- <div class="pagination"><?php echo pagination_bar($the_query); ?></nav>
</div> -->
<?php endwhile; ?>
</div>
<?php do_action('avada_after_content'); ?>
</div>
</div>
<?php get_footer();
// Omit closing PHP tag to avoid "Headers already sent" issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment