<?php defined('ABSPATH') or die("No script kiddies please!");

//echo "epgr-shortcode.php";
$post_id = $atts['id'];
/* Get API KEY */
$egpr_reviews = get_option('egp_reviews');
$default_obj = new EGPR_Activation();
$default_array  = $default_obj->egpr_default_settings();
$nverified_api_key = (isset($egpr_reviews['nverified_api_key']) && $egpr_reviews['nverified_api_key'] != '') ? esc_attr($egpr_reviews['nverified_api_key']) : '';
$check_cache = (isset($egpr_reviews['check_cache']) && $egpr_reviews['check_cache'] == 'true') ? 'true' : 'false';
$cache_period = (isset($egpr_reviews['cache_period']) && $egpr_reviews['cache_period'] != '') ? intval($egpr_reviews['cache_period']) : $default_array['cache_period'];
/* Get API KEY END */

/* Get Google Map Settings Start */
$gmap_settings = get_post_meta($post_id, 'egpr_meta_option', true);
$location_name = (isset($gmap_settings['location_name']) && $gmap_settings['location_name'] != '') ? esc_attr($gmap_settings['location_name']) : '';
$place_id = (isset($gmap_settings['place_id']) && $gmap_settings['place_id'] != '') ? esc_attr($gmap_settings['place_id']) : '';
/* Get Google Map Settings END */

/* Get all review common settings Start */
$review_settings = get_post_meta($post_id, 'egpr_review_settings', true);
$totalnumberreviews = (isset($review_settings['total_number_nonverified_reviews']) && $review_settings['total_number_nonverified_reviews'] != '') ? intval($review_settings['total_number_nonverified_reviews']) : '5';
if(isset($atts['number_reviews']) && $atts['number_reviews'] != ''){
   $total_number_reviews = $atts['number_reviews'];
}else{
    $total_number_reviews = $totalnumberreviews;
}
$hide_usr_image = (isset($review_settings['hide_usr_image']) && $review_settings['hide_usr_image'] == 'true') ? 1 : 0;
$hide_user_name = (isset($review_settings['hide_user_name']) && $review_settings['hide_user_name'] == 'true') ? 1 : 0;
$hide_user_rating = (isset($review_settings['hide_user_rating']) && $review_settings['hide_user_rating'] == 'true') ? 1 : 0;
$hide_avg_rating = (isset($review_settings['hide_avg_rating']) && $review_settings['hide_avg_rating'] == 'true') ? 1 : 0;

$show_5star_rating = (isset($review_settings['show_5star_rating']) && $review_settings['show_5star_rating'] == 'true') ? "true" : "false";
$show_description = (isset($review_settings['show_description']) && $review_settings['show_description'] != '') ? esc_attr($review_settings['show_description']) : '';
$word_limit = (isset($review_settings['show_desc_limit_rating']) && $review_settings['show_desc_limit_rating'] != '') ? esc_attr($review_settings['show_desc_limit_rating']) : '300';
$desc_text_show = (isset($review_settings['desc_text_show']) && $review_settings['desc_text_show'] != '') ? esc_attr($review_settings['desc_text_show']) : 'Read More';
$desc_text_hide = (isset($review_settings['desc_text_hide']) && $review_settings['desc_text_hide'] != '') ? esc_attr($review_settings['desc_text_hide']) : 'Read Less';
$show_only_badge = (isset($review_settings['show_only_badge']) && $review_settings['show_only_badge'] == 'true') ? "true" : "false";
$total_review_count = (isset($review_settings['total_review_count']) && $review_settings['total_review_count'] != '')?esc_attr($review_settings['total_review_count']):'6';
$price_range = (isset($review_settings['price_range']) && $review_settings['price_range'] != '')?esc_attr($review_settings['price_range']):'';
$language_code = (isset($review_settings['language_code']) && $review_settings['language_code'] != '')?esc_attr($review_settings['language_code']):'en';
/* Get all review common settings end */

/* Get Review Template settings Start */
$template_settings = get_post_meta($post_id, 'egpr_display_settings', true);
//$this->displayArr($template_settings);
$showreviews = (isset($template_settings['show_reviews']) && $template_settings['show_reviews'] == 'true') ? 'true' : 'false';
if(isset($atts['show_review']) && $atts['show_review'] != ''){
if($atts['show_review'] == 1){
$show_reviews = "true";
}else{
$show_reviews = "false";
}
} else{
$show_reviews = $showreviews;
}

$rtemplate = (isset($template_settings['choose_template']) && $template_settings['choose_template'] != '') ? $template_settings['choose_template'] : 'template1';
if(isset($atts['review_template']) && $atts['review_template'] != ''){
   $choose_template = $atts['review_template'];
}else{
    $choose_template = $rtemplate;
}

$enable_review_animation = (isset($template_settings['enable_review_animation']) && $template_settings['enable_review_animation'] == 'true') ? "true" : "false";
$ranimationtype = (isset($template_settings['review_animation_type']) && $template_settings['review_animation_type'] != '') ? $template_settings['review_animation_type'] : '';
if(isset($atts['show_review_animation']) && $atts['show_review_animation']  == 1){
  if(isset($atts['review_animation_type']) && $atts['review_animation_type'] != ''){
      $review_animation_type = 'wow animated '.$atts['review_animation_type'];
      $review_animation = $atts['review_animation_type'];
  }else{
       $review_animation_type = '';
       $review_animation = '';
  }
}else{
  if($enable_review_animation == "true"){
    if(isset($atts['review_animation_type']) && $atts['review_animation_type'] != ''){
      $review_animation_type = 'wow animated '.$atts['review_animation_type'];
      $review_animation = $atts['review_animation_type'];
  }else{
      $review_animation_type = 'wow animated '.$ranimationtype;
      $review_animation = $ranimationtype;
  }
  }else{
     $review_animation_type = '';
     $review_animation = '';
  }

}


$layouttype = (isset($template_settings['layout_type']) && $template_settings['layout_type'] != '') ? $template_settings['layout_type'] : 'list';
if(isset($atts['layout_type']) && $atts['layout_type'] != ''){
  $layout_type = $atts['layout_type'];
}else{
 $layout_type = $layouttype;
}
$bposition = (isset($template_settings['badge_position']) && $template_settings['badge_position'] != '') ? $template_settings['badge_position'] : 'horizontal';
$disable_user_links = (isset($template_settings['disable_user_links']) && $template_settings['disable_user_links'] == 'true') ? "true" : "false";
$disable_date = (isset($template_settings['disable_date']) && $template_settings['disable_date'] == 'true') ? "true" : "false";

if(isset($atts['position']) && $atts['position'] != ''){
  if($atts['position'] == "hide"){
      $badge_position = '';
  }else{
      $badge_position = $atts['position'];
  }

}else{
 $badge_position = $bposition;
}

$pager_show = (isset($template_settings['slider']['pager']) && $template_settings['slider']['pager'] == "true") ? "1" : "0";
$pagertype = (isset($template_settings['slider']['pager_type']) && $template_settings['slider']['pager_type'] != "") ? $template_settings['slider']['pager_type'] : "dot";
if(isset($atts['pager_type']) && $atts['pager_type'] != ''){
  $pager_type = $atts['pager_type'];
}else{
 $pager_type = $pagertype;
}
$mode = (isset($template_settings['slider']['mode']) && $template_settings['slider']['mode'] != "") ? esc_attr($template_settings['slider']['mode']) : "horizontal";
$autoplay = (isset($template_settings['slider']['autoplay']) && $template_settings['slider']['autoplay'] == "true") ? "1" : "0";
$controls = (isset($template_settings['slider']['controls']) && $template_settings['slider']['controls'] == "true") ? "1" : "0";
$adaptive_height = (isset($template_settings['slider']['adaptive_height']) && $template_settings['slider']['adaptive_height'] == "true") ? 1 : 0;
$controlstype = (isset($template_settings['slider']['controls_type']) && $template_settings['slider']['controls_type'] != "") ? $template_settings['slider']['controls_type'] : "arrow";
if(isset($atts['controls_type']) && $atts['controls_type'] != ''){
  $controls_type = $atts['controls_type'];
}else{
 $controls_type = $controlstype;
}

$speed = (isset($template_settings['slider']['speed']) && $template_settings['slider']['speed'] != "") ? esc_attr($template_settings['slider']['speed']) : "1000";
$pause = (isset($template_settings['slider']['pause']) && $template_settings['slider']['pause'] != "") ? esc_attr($template_settings['slider']['pause']) : "2000";

/* Get Review Template settings END */

/* Badge settings */
$badge_settings = get_post_meta($post_id, 'egpr_badge_settings', true);
//$this->displayArr( $badge_settings );
$showbadge = (isset($badge_settings['show_badge']) && $badge_settings['show_badge'] == 'true') ? "true" : "false";
if(isset($atts['show_badge']) && $atts['show_badge'] != ''){
if($atts['show_badge'] == 1){
$show_badge = "true";
}else{
$show_badge = "false";
}
} else{
$show_badge = $showbadge;
}
$btemplate = (isset($badge_settings['choose_badge_template']) && $badge_settings['choose_badge_template'] != '') ? $badge_settings['choose_badge_template'] : 'template1';
if(isset($atts['badge_template']) && $atts['badge_template'] != ''){
   $badge_template = $atts['badge_template'];
}else{
    $badge_template = $btemplate;
}

$showheader = (isset($badge_settings['show_header']) && $badge_settings['show_header'] == 'true') ? "true" : "false";
if(isset($atts['show_header']) && $atts['show_header'] != ''){
if($atts['show_header'] == 1){
$show_header = "true";
}else{
$show_header = "false";
}
} else{
$show_header = $showheader;
}
$htemplate = (isset($badge_settings['choose_header_template']) && $badge_settings['choose_header_template'] != '') ? $badge_settings['choose_header_template'] : 'template1';
if(isset($atts['header_template']) && $atts['header_template'] != ''){
   $header_template = $atts['header_template'];
}else{
    $header_template = $htemplate;
}
$enable_banimation = (isset($badge_settings['enable_banimation']) && $badge_settings['enable_banimation'] == 'true') ? "true" : "false";
$animation_name = (isset($badge_settings['animation_name']) && $badge_settings['animation_name'] != '') ? $badge_settings['animation_name'] : '';

if(isset($atts['show_badge_animation']) && $atts['show_badge_animation']  == 1){
  if(isset($atts['badge_animation_type']) && $atts['badge_animation_type'] != ''){
      $badge_animation_type = 'wow animated '.$atts['badge_animation_type'];
      $badge_animation = $atts['badge_animation_type'];
  }else{
       $badge_animation_type = '';
       $badge_animation = '';
  }
}else{
  if($enable_banimation == "true"){
    if(isset($atts['badge_animation_type']) && $atts['badge_animation_type'] != ''){
      $badge_animation_type = 'wow animated '.$atts['badge_animation_type'];
      $badge_animation = $atts['badge_animation_type'];
    }else{
        $badge_animation_type = 'wow animated '.$animation_name;
        $badge_animation = $animation_name;
    }
  }else{
     $badge_animation_type = '';
     $badge_animation = '';
  }

}


/* Get Review Rate Us Button settings Start */
$rateus_settings = get_post_meta($post_id, 'egpr_rateus_settings', true);
$enablerateus = (isset($rateus_settings['enable']) && $rateus_settings['enable'] == "true") ? "1" : "0";
if(isset($atts['show_rate_us_button']) && $atts['show_rate_us_button'] != ''){
if($atts['show_rate_us_button'] == 1){
$enable_rateus = "1";
}else{
$enable_rateus = "0";
}
} else{
$enable_rateus = $enablerateus;
}
$texttitle = (isset($rateus_settings['text_title']) && $rateus_settings['text_title'] != "") ? esc_attr($rateus_settings['text_title']) : __("Write a review",EGPR_TD);
if(isset($atts['text_title']) && $atts['text_title'] != ''){
  $text_title = $atts['text_title'];
}else{
   $text_title = $texttitle;
}
$link_target = (isset($rateus_settings['link_target']) && $rateus_settings['link_target'] != "") ? esc_attr($rateus_settings['link_target']) : "_blank";

$link_type = (isset($rateus_settings['link_type']) && $rateus_settings['link_type'] != "") ? esc_attr($rateus_settings['link_type']) : "default";
$rateus_default_customurl = (isset($rateus_settings['custom_url']) && $rateus_settings['custom_url'] != "") ? esc_url($rateus_settings['custom_url']) : "";
if(isset($atts['custom_url']) && $atts['custom_url'] != ''){
  $custom_url = $atts['custom_url'];
}else{
   $custom_url = $rateus_default_customurl;
}
/* Get Review Rate Us Button settings END */

/* Get Review View ALL  Button settings Start */
$viewall_settings = get_post_meta($post_id, 'egpr_viewall_settings', true);
$enable_view_all_btn = (isset($viewall_settings['enable']) && $viewall_settings['enable'] == "true") ? "1" : "0";
$enable_nofollow = (isset($viewall_settings['enable_nofollow']) && $viewall_settings['enable_nofollow'] == "true") ? "1" : "0";
if(isset($atts['enable_viewall']) && $atts['enable_viewall'] != ''){
if($atts['enable_viewall'] == 1){
$enable_viewall = "1";
}else{
$enable_viewall = "0";
}
} else{
$enable_viewall = $enable_view_all_btn;
}
$textvtitle = (isset($viewall_settings['text_btitle']) && $viewall_settings['text_btitle'] != "") ? esc_attr($viewall_settings['text_btitle']) : __("See all reviews",EGPR_TD);
if(isset($atts['view_all_button_title']) && $atts['view_all_button_title'] != ''){
  $text_vbtitle = $atts['view_all_button_title'];
}else{
   $text_vbtitle = $textvtitle;
}
$vblink_target = (isset($viewall_settings['link_target']) && $viewall_settings['link_target'] != "") ? esc_attr($viewall_settings['link_target']) : "_self";
$viewallcustom_url = (isset($viewall_settings['custom_url']) && $viewall_settings['custom_url'] != "") ? esc_url($viewall_settings['custom_url']) : "";

/* Get Review View ALL Button settings END */


$random_num = rand(111111111, 999999999);

/* Get all Reviews and business badge Details */
$all_reviews = EGPR_API_Settings::get_google_review_api($check_cache, $cache_period, $nverified_api_key, $place_id,$language_code);

// $this->displayArr($all_reviews );
// exit();

if (isset($all_reviews['result']['reviews']) && !empty($all_reviews['result']['reviews'])) {
    $reviews = $all_reviews['result']['reviews'];
} else {
    $reviews = array();
}
if ($show_5star_rating == "true") {
    $cnt = 1;
} else {
    $cnt = 0;
}



$reviews = $this->get_filtered_reviews($reviews, $total_number_reviews, $cnt);
if (isset($all_reviews['result']) && !empty($all_reviews['result'])) {
    $all_results = $all_reviews['result'];
} else {
    $all_results = array();
}
$business_name = (isset($all_results['name']) && $all_results['name'] != '') ? $all_results['name'] : '';
$url = (isset($all_results['url']) && $all_results['url'] != '') ? $all_results['url'] : '';
$website = (isset($all_results['website']) && $all_results['website'] != '') ? $all_results['website'] : '';
$photo_avatar = (isset($all_results['photos'][0]['photo_reference']) && $all_results['photos'][0]['photo_reference'] != '' ) ? $all_results['photos'][0]['photo_reference'] : '';
$avg_star = (isset($all_results['rating']) && $all_results['rating'] != '') ? $all_results['rating'] : '';
$formatted_phone_number = (isset($all_results['formatted_phone_number']) && $all_results['formatted_phone_number'] != '') ? $all_results['formatted_phone_number'] : '';
$international_phone_number = (isset($all_results['international_phone_number']) && $all_results['international_phone_number'] != '') ? $all_results['international_phone_number'] : '';
if($formatted_phone_number != ''){
  $phone_number = $formatted_phone_number;
}else{
  $phone_number = $international_phone_number;
}
$address_components = (isset($all_results['address_components']) && $all_results['address_components'] != '') ? $all_results['address_components'] : array();

//view all custom url
if(isset($atts['viewall_custom_url']) && $atts['viewall_custom_url']  != ''){
   $viewall_custom_url = $atts['viewall_custom_url'];
}else{
  if($viewallcustom_url != ''){
   $viewall_custom_url = $viewallcustom_url;
  }else{
    $viewall_custom_url = $url;
  }
}
?>
<?php
if($layout_type == "slider"){
    if($mode == "vertical"){
      $class_slidermode = "egpr-slide-vertical";
    }else{
      $class_slidermode = "";
    }
    if ($pager_show == "1") {
        if ($pager_type == "pagination") {
            $show_paginationclass = "egpr-show-pagination";
        } else {
            $show_paginationclass = "egpr-pager-dot-type";
        }
    } else {
        $show_paginationclass = "egpr-hidepager";
    }
    if ($controls == 1) {
        if ($controls_type == "text") {
            $show_control_class = "egpr-control-text-type";
        } else {
            $show_control_class = "egpr-arrow-text-type";
        }
    } else {
        $show_control_class = "egpr-hidecontrols";
    }
}else{
    $show_paginationclass = '';
    $show_control_class  = '';
    $class_slidermode = "";
}

if($show_badge == "true"){
  $badge_position_class = "egpr-badge-".$badge_position;
}else{
  $badge_position_class = '';
}
if(isset($all_reviews['error_message']) && $all_reviews['error_message'] != ''){
  ?>
<div class="egpr_error_msg_wrapper">
  <?php echo $all_reviews['error_message'];?>
</div>
  <?php
}else{
  ?><div class="egpr-reviews-main-wrapper <?php echo (isset($enable_floating_review) && $enable_floating_review == 1 )?"egpr-floating-reviews":""; ?> <?php echo ($show_5star_rating == 'true')?"egpr-show-5-star-rating":""; ?> egpr-review-<?php echo esc_attr($choose_template); ?> egpr-layout-<?php echo esc_attr($layout_type); ?> <?php echo esc_attr($badge_position_class);?>-position <?php echo $class_slidermode; ?> <?php echo $show_control_class; ?> <?php echo $show_paginationclass; ?>" id="egpr-reviews-outer-wrap-<?php echo $random_num; ?>" data-id="<?php echo $post_id;?>" >
        <div class="egpr-inner-wrap egpr-clearfix">
<?php if(!empty($address_components)){
   for($i = 0; $i < count($address_components); $i++){
     $types = (isset($address_components[$i]['types'][0]) && $address_components[$i]['types'][0] != '') ? $address_components[$i]['types'][0] : '';
     if( $types  == "route" ){
      $streetAddress = (isset($address_components[$i]['long_name']) && $address_components[$i]['long_name'] != '') ? $address_components[$i]['long_name'] : '';
     }else if($types  == "locality"){
      $addressLocality = (isset($address_components[$i]['long_name']) && $address_components[$i]['long_name'] != '') ? $address_components[$i]['long_name'] : '';
     }else if($types  == "postal_code"){
      $postalCode = (isset($address_components[$i]['long_name']) && $address_components[$i]['long_name'] != '') ? $address_components[$i]['long_name'] : '';
     }else if($types  == "administrative_area_level_1"){
     $addressRegion = (isset($address_components[$i]['long_name']) && $address_components[$i]['long_name'] != '') ? $address_components[$i]['long_name'] : '';
     }
    }
 }
$image_business = "https://maps.googleapis.com/maps/api/place/photo?photoreference=".$photo_avatar."&maxwidth=1300&maxheight=500&key=".$nverified_api_key;
 ?>
<div class="hidden" style="display:none;">
    <div itemscope="" itemtype="http://schema.org/LocalBusiness">
     <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
        <meta itemprop="ratingValue" content="<?php echo $avg_star; ?>">
        <span itemprop="reviewCount"><?php if($total_review_count != ''){ echo $total_review_count;}?></span>
    </div>
     <meta itemprop="image" content="<?php if($image_business != ''){ echo $image_business;}?>">
     <meta itemprop="priceRange" content="<?php if($price_range != ''){ echo $price_range;}?>">
      <meta itemprop="name" content="<?php if($business_name != ''){ echo $business_name;}?> Reviews1">
      <address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
        <span itemprop="streetAddress"><?php if($streetAddress != ''){ echo $streetAddress;}?></span><br>
        <span itemprop="addressLocality"><?php if($addressLocality != ''){ echo $addressLocality;}?></span>,
        <span itemprop="addressRegion"><?php if($addressRegion != ''){ echo $addressRegion;}?></span>
        <span itemprop="postalCode"><?php if($postalCode != ''){ echo $postalCode; }?></span><br>
      </address>
     <span itemprop="telephone">
        <?php if($phone_number != ''){ echo $phone_number; }?>
      </span>
    </div>
</div>
    <?php
    if(isset($atts['badge_link']) && $atts['badge_link'] == "disabled"){
        $badge_link = 1;
    } else {
        $badge_link = 0;
    }

    if ($show_badge == "true") {
        include(EGPR_PATH . 'inc/frontend/shortcode/egpr-business-badge.php');
    }
    ?>
   <?php if ($show_reviews == "true") {  ?>
          <div class="egpr-google-reviews-wrap egpr-review-<?php echo esc_attr($choose_template); ?>">
          <?php } ?>
            <?php if ($show_reviews == "true") {
               if (isset($reviews) && !empty($reviews)) {
                ?>
                <div class="egpr-review-section-outer-new-wrap egpr-<?php echo $review_animation ?> ">
                  <div class="egpr-review-section">
                    <div class="egpr-all-reviews-wrapper <?php echo $review_animation_type;?>" <?php if($review_animation_type != '') echo 'data-wow-duration="2s" data-wow-delay="0.4s"'; else echo '';?>>
                      <?php
                         include(EGPR_PATH . 'inc/frontend/shortcode/templates/egpr-review-'.$choose_template.'.php');
                        ?>
                    </div>
                  </div>
              </div>
             <?php  }
                } ?>
             <?php
             if ($enable_rateus == 1 || $enable_viewall == 1) { ?>
                <div class="egpr-rateus-button-wrap">
                <?php if($enable_rateus == 1){ ?>
                <?php  if($link_type == "default"){ ?>
                    <a href="https://search.google.com/local/writereview?placeid=<?php echo esc_attr($place_id); ?>" target="<?php echo esc_attr($link_target); ?>" class="egpr-rate-button"><?php echo esc_attr($text_title); ?></a>
                <?php
                  }else { ?>
                    <a href="<?php echo esc_url($custom_url); ?>" target="<?php echo esc_attr($link_target); ?>" class="egpr-rate-button"><?php echo esc_attr($text_title); ?></a>
                <?php
                    }
                  } ?>
                 <?php
                 if($enable_viewall == 1){ ?>
                    <a href="<?php echo esc_attr($viewall_custom_url); ?>" <?php if($enable_nofollow == 1) echo 'rel="nofollow"';?> class="egpr-viewall-button" target="<?php echo esc_attr($vblink_target); ?>"><?php echo esc_attr($text_vbtitle); ?></a>
                <?php } ?>
                </div>
             <?php } ?>
          <?php if ($show_reviews == "true") {  ?>
            </div>
          <?php } ?>
</div>
<?php
$custom_settings = get_post_meta($post_id, 'egpr_custom_settings', true);
$enable_custom = (isset($custom_settings['custom_enable']) && $custom_settings['custom_enable'] == "true") ? "true" : "false";
if($enable_custom == "true"){
$reviewer_fcolor = (isset($custom_settings['reviewer_fcolor']) && $custom_settings['reviewer_fcolor'] != "") ? esc_attr($custom_settings['reviewer_fcolor'] ) : "";
$reviewer_fhcolor = (isset($custom_settings['reviewer_fhcolor']) && $custom_settings['reviewer_fhcolor'] != "") ? esc_attr($custom_settings['reviewer_fhcolor'] ) : "";
$reviewer_fsize = (isset($custom_settings['reviewer_fsize']) && $custom_settings['reviewer_fsize'] != "") ? esc_attr($custom_settings['reviewer_fsize'] ) : "";
$font_family = (isset($custom_settings['font_family']) && $custom_settings['font_family'] != "") ? esc_attr($custom_settings['font_family'] ) : "";

$desc_size = (isset($custom_settings['desc_size']) && $custom_settings['desc_size'] != "") ? esc_attr($custom_settings['desc_size'] ) : "";
$desc_fcolor = (isset($custom_settings['desc_fcolor']) && $custom_settings['desc_fcolor'] != "") ? esc_attr($custom_settings['desc_fcolor'] ) : "";
$date_fcolor = (isset($custom_settings['date_fcolor']) && $custom_settings['date_fcolor'] != "") ? esc_attr($custom_settings['date_fcolor'] ) : "";
$desc_font_family = (isset($custom_settings['desc_font_family']) && $custom_settings['desc_font_family'] != "") ? esc_attr($custom_settings['desc_font_family'] ) : "";

$rating_color = (isset($custom_settings['rating_color']) && $custom_settings['rating_color'] != "") ? esc_attr($custom_settings['rating_color'] ) : "";
$button_color = (isset($custom_settings['button_color']) && $custom_settings['button_color'] != "") ? esc_attr($custom_settings['button_color'] ) : "";
$button_hcolor = (isset($custom_settings['button_hcolor']) && $custom_settings['button_hcolor'] != "") ? esc_attr($custom_settings['button_hcolor'] ) : "";
$button_fsize = (isset($custom_settings['button_fsize']) && $custom_settings['button_fsize'] != "") ? esc_attr($custom_settings['button_fsize'] ) : "";
//rate us button
$text_font_size = (isset($custom_settings['text_font_size']) && $custom_settings['text_font_size'] != "") ? esc_attr($custom_settings['text_font_size'] ) : "";
$text_fcolor = (isset($custom_settings['text_fcolor']) && $custom_settings['text_fcolor'] != "") ? esc_attr($custom_settings['text_fcolor'] ) : "";
$text_fhcolor = (isset($custom_settings['text_fhcolor']) && $custom_settings['text_fhcolor'] != "") ? esc_attr($custom_settings['text_fhcolor'] ) : "";
$button_bg_color = (isset($custom_settings['button_bg_color']) && $custom_settings['button_bg_color'] != "") ? esc_attr($custom_settings['button_bg_color'] ) : "";
$button_bg_hcolor = (isset($custom_settings['button_bg_hcolor']) && $custom_settings['button_bg_hcolor'] != "") ? esc_attr($custom_settings['button_bg_hcolor'] ) : "";
$rbutton_font_family = (isset($custom_settings['rbutton_font_family']) && $custom_settings['rbutton_font_family'] != "") ? esc_attr($custom_settings['rbutton_font_family'] ) : "";

$button_border_color = (isset($custom_settings['button_border_color']) && $custom_settings['button_border_color'] != "") ? esc_attr($custom_settings['button_border_color'] ) : "";
$button_border_hcolor = (isset($custom_settings['button_border_hcolor']) && $custom_settings['button_border_hcolor'] != "") ? esc_attr($custom_settings['button_border_hcolor'] ) : "";
//view all button
$viewall_font_size = (isset($custom_settings['viewall_font_size']) && $custom_settings['viewall_font_size'] != "") ? esc_attr($custom_settings['viewall_font_size'] ) : "";
$viewall_text_fcolor = (isset($custom_settings['viewall_text_fcolor']) && $custom_settings['viewall_text_fcolor'] != "") ? esc_attr($custom_settings['viewall_text_fcolor'] ) : "";
$viewall_text_fhcolor = (isset($custom_settings['viewall_text_fhcolor']) && $custom_settings['viewall_text_fhcolor'] != "") ? esc_attr($custom_settings['viewall_text_fhcolor'] ) : "";
$viewbutton_border_color = (isset($custom_settings['viewbutton_border_color']) && $custom_settings['viewbutton_border_color'] != "") ? esc_attr($custom_settings['viewbutton_border_color'] ) : "";
$viewbutton_border_hcolor = (isset($custom_settings['viewbutton_border_hcolor']) && $custom_settings['viewbutton_border_hcolor'] != "") ? esc_attr($custom_settings['viewbutton_border_hcolor'] ) : "";
$viewbutton_font_family = (isset($custom_settings['viewbutton_font_family']) && $custom_settings['viewbutton_font_family'] != "") ? esc_attr($custom_settings['viewbutton_font_family'] ) : "";
$viewall_button_bg_color = (isset($custom_settings['viewall_button_bg_color']) && $custom_settings['viewall_button_bg_color'] != "") ? esc_attr($custom_settings['viewall_button_bg_color'] ) : "";
$viewall_button_bg_hcolor = (isset($custom_settings['viewall_button_bg_hcolor']) && $custom_settings['viewall_button_bg_hcolor'] != "") ? esc_attr($custom_settings['viewall_button_bg_hcolor'] ) : "";
$dot_color = (isset($custom_settings['dot_color']) && $custom_settings['dot_color'] != "") ? esc_attr($custom_settings['dot_color'] ) : "";
$dot_active_color = (isset($custom_settings['dot_active_color']) && $custom_settings['dot_active_color'] != "") ? esc_attr($custom_settings['dot_active_color'] ) : "";
$pager_active_color = (isset($custom_settings['pager_active_color']) && $custom_settings['pager_active_color'] != "") ? esc_attr($custom_settings['pager_active_color'] ) : "";
$arrow_bgcolor = (isset($custom_settings['arrow_bgcolor']) && $custom_settings['arrow_bgcolor'] != "") ? esc_attr($custom_settings['arrow_bgcolor'] ) : "";
$arrow_bghcolor = (isset($custom_settings['arrow_bghcolor']) && $custom_settings['arrow_bghcolor'] != "") ? esc_attr($custom_settings['arrow_bghcolor'] ) : "";
$arrow_color = (isset($custom_settings['arrow_color']) && $custom_settings['arrow_color'] != "") ? esc_attr($custom_settings['arrow_color'] ) : "";
$arrow_hcolor = (isset($custom_settings['arrow_hcolor']) && $custom_settings['arrow_hcolor'] != "") ? esc_attr($custom_settings['arrow_hcolor'] ) : "";
  include(EGPR_PATH . 'inc/frontend/custom-style.php');
}
?>
</div>
<?php } ?>
<script type="application/ld+json">
  {
  "@context": "http://schema.org",
  "@type" : "LocalBusiness",
  "name" : "<?php echo $business_name;?>",
  "telephone" : "<?php echo $phone_number;?>",
  "image": "<?php echo $image_business;?>",
  "priceRange" : "<?php echo $price_range;?>",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "<?php echo $avg_star; ?>",
    "reviewCount": "<?php echo $total_review_count ;?>"
  },
  "address" : {
    "@type" : "PostalAddress",
    "streetAddress" : "<?php echo $streetAddress;?>",
    "addressLocality" : "<?php echo $addressLocality;?>",
    "addressRegion" : "<?php echo $addressRegion;?>",
    "postalCode" : "<?php echo $postalCode;?>"
  }
  }
</script>
