/** * Output the current post overall review and a small image compatible with google hreviews. * * @global WP_Post|null $post The current post, if available. * @global bool $preview True if the current page is add listing preview page. False if not. * @global object $post_images Image objects of current post if available. * @since 1.0.0 * @package GeoDirectory */ function geodir_detail_page_review_rating() { global $post, $preview, $post_images; ob_start(); // Start buffering; /** * This is called before the rating html in the function geodir_detail_page_review_rating(). * * This is called outside the check for an actual rating and the check for preview page. * * @since 1.0.0 */ do_action('geodir_before_detail_page_review_rating'); $comment_count = geodir_get_review_count_total($post->ID); $post_avgratings = geodir_get_post_rating($post->ID); if ($post_avgratings != 0 && !$preview) { /** * This is called before the rating html in the function geodir_detail_page_review_rating(). * * This is called inside the check for an actual rating and the check for preview page. * * @since 1.0.0 * @param float $post_avgratings Average rating for the surrent post. * @param int $post->ID Current post ID. */ do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID); $html = '<p style=" float:left;">'; $html .= geodir_get_rating_stars($post_avgratings, $post->ID); $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; $post_avgratings = is_float($post_avgratings) || strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3 ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; $html .= '<span class="item">'; $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; if ($post_images) { foreach ($post_images as $img) { $post_img = $img->src; break; } } if (isset($post_img) && $post_img) { $html .= '<br /><img src="' . $post_img . '" class="photo hreview-img" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo hreview-img" />'; } $html .= '</span>'; echo $html .= '</div>'; /** * This is called after the rating html in the function geodir_detail_page_review_rating(). * * This is called inside the check for an actual rating and the check for preview page. * * @since 1.0.0 * @param float $post_avgratings Average rating for the surrent post. * @param int $post->ID Current post ID. */ do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID); } /** * This is called before the rating html in the function geodir_detail_page_review_rating(). * * This is called outside the check for an actual rating and the check for preview page. * * @since 1.0.0 */ do_action('geodir_after_detail_page_review_rating'); $content_html = ob_get_clean(); if (trim($content_html) != '') { $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; } if ((int) get_option('geodir_disable_rating_info_section') != 1) { /** * Filter the geodir_detail_page_review_rating() function content. * * @since 1.0.0 * @param string $content_html The output html of the geodir_detail_page_review_rating() function. */ echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html); } }
</div> <?php } ?> <?php /** This action is documented in geodirectory-templates/listing-listview.php */ do_action('geodir_after_listing_post_excerpt', $post); ?> </div> <!-- gd-content ends here--> <footer class="geodir-entry-meta"> <div class="geodir-addinfo clearfix"> <?php $review_show = geodir_is_reviews_show('listview'); if ($review_show) { $post_avgratings = geodir_get_post_rating($post->ID); /** This action is documented in geodirectory-templates/listing-listview.php */ do_action('geodir_before_review_rating_stars_on_listview', $post_avgratings, $post->ID); echo geodir_get_rating_stars($post_avgratings, $post->ID); /** This action is documented in geodirectory-templates/listing-listview.php */ do_action('geodir_after_review_rating_stars_on_listview', $post_avgratings, $post->ID); ?> <a href="<?php comments_link(); ?> " class="geodir-pcomments"><i class="fa fa-comments"></i> <?php geodir_comments_number($post->rating_count); ?> </a> <?php
/** * Returns average overall rating of a Post. Depreciated since ver 1.3.6. * * @since 1.0.0 * @package GeoDirectory * @param int $post_id The post ID. * @internal Depreciated since ver 1.3.6. * @return array|bool|int|mixed|null|string */ function geodir_get_commentoverall_number($post_id = 0) { return geodir_get_post_rating($post_id); }
/** * Set post Map Marker info html. * * @since 1.0.0 * @package GeoDirectory * @global array $geodir_addon_list List of active GeoDirectory extensions. * @param object $postinfo_obj The post details object. * @param string $post_preview Is this a post preview?. * @return mixed|string|void */ function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') { global $preview; $srcharr = array("'", "/", "-", '"', '\\'); $replarr = array("′", "⁄", "–", "“", ''); if (isset($_SESSION['listing']) && isset($post_preview) && $post_preview != '') { $ID = ''; $plink = ''; if (isset($postinfo_obj->pid)) { $ID = $postinfo_obj->pid; $plink = get_permalink($ID); } $title = str_replace($srcharr, $replarr, $postinfo_obj->post_title); $lat = $postinfo_obj->post_latitude; $lng = $postinfo_obj->post_longitude; $address = str_replace($srcharr, $replarr, $postinfo_obj->post_address); $contact = str_replace($srcharr, $replarr, $postinfo_obj->geodir_contact); $timing = str_replace($srcharr, $replarr, $postinfo_obj->geodir_timing); } else { $ID = $postinfo_obj->post_id; $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan $plink = get_permalink($ID); $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); $address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan $contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8')); $timing = str_replace($srcharr, $replarr, geodir_get_post_meta($ID, 'geodir_timing', true)); } // filter field as per price package global $geodir_addon_list; if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') { $post_type = get_post_type($ID); $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; $field_name = 'geodir_contact'; if (!check_field_visibility($package_id, $field_name, $post_type)) { $contact = ''; } $field_name = 'geodir_timing'; if (!check_field_visibility($package_id, $field_name, $post_type)) { $timing = ''; } } if ($lat && $lng) { ob_start(); ?> <div class="gd-bubble" style="height: 100px;max-height: 100px;"> <div class="gd-bubble-inside"> <?php $comment_count = ''; $rating_star = ''; if ($ID != '') { $rating_star = ''; $comment_count = geodir_get_review_count_total($ID); if (!$preview) { $post_avgratings = geodir_get_post_rating($ID); $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); /** * Filter to change rating stars * * You can use this filter to change Rating stars. * * @since 1.0.0 * @package GeoDirectory * @param string $rating_star Rating stars. * @param float $post_avgratings Average ratings of the post. * @param int $ID The post ID. */ $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID); } } ?> <div class="geodir-bubble_desc"> <h4> <a href="<?php if ($plink != '') { echo $plink; } else { echo 'javascript:void(0);'; } ?> "><?php echo $title; ?> </a> </h4> <?php if (isset($_SESSION['listing']) && isset($post_preview) && $post_preview != '') { $post_images = array(); if (!empty($postinfo_obj->post_images)) { $post_images = explode(",", $postinfo_obj->post_images); } if (!empty($post_images)) { ?> <div class="geodir-bubble_image"><a href="<?php if ($plink != '') { echo $plink; } else { echo 'javascript:void(0);'; } ?> "><img alt="bubble image" style="max-height:50px;" src="<?php echo $post_images[0]; ?> "/></a></div> <?php } } else { if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) { ?> <div class="geodir-bubble_image"><a href="<?php echo $plink; ?> "><?php echo $image; ?> </a></div> <?php } } ?> <div class="geodir-bubble-meta-side"> <span class="geodir_address"><i class="fa fa-home"></i> <?php echo $address; ?> </span> <?php if ($contact) { ?> <span class="geodir_contact"><i class="fa fa-phone"></i> <?php echo $contact; ?> </span><?php } ?> <?php if ($timing) { ?> <span class="geodir_timing"><i class="fa fa-clock-o"></i> <?php echo $timing; ?> </span><?php } /** * Fires after the meta info in the map info window. * * This can be used to add more info to the map info window after the normal meta info. * * @since 1.4.2 * @param object $postinfo_obj The posts info as an object. * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * */ do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview); ?> </div> <?php if (isset($postinfo_obj->recurring_dates)) { $recuring_data = unserialize($postinfo_obj->recurring_dates); $output = ''; $output .= '<div class="geodir_event_schedule">'; $event_recurring_dates = explode(',', $recuring_data['event_recurring_dates']); $starttimes = isset($recuring_data['starttime']) ? $recuring_data['starttime'] : ''; $endtimes = isset($recuring_data['endtime']) ? $recuring_data['endtime'] : ''; $e = 0; foreach ($event_recurring_dates as $key => $date) { if (strtotime($date) < strtotime(date("Y-m-d"))) { continue; } // if the event is old don't show it on the map $e++; if ($e == 2) { break; } // only show 3 event dates $output .= '<p>'; //$geodir_num_dates++; if (isset($recuring_data['different_times']) && $recuring_data['different_times'] == '1') { $starttimes = isset($recuring_data['starttimes'][$key]) ? $recuring_data['starttimes'][$key] : ''; $endtimes = isset($recuring_data['endtimes'][$key]) ? $recuring_data['endtimes'][$key] : ''; } $sdate = strtotime($date . ' ' . $starttimes); $edate = strtotime($date . ' ' . $endtimes); if ($starttimes > $endtimes) { $edate = strtotime($date . ' ' . $endtimes . " +1 day"); } global $geodir_date_time_format; $output .= '<i class="fa fa-caret-right"></i>' . date($geodir_date_time_format, $sdate); //$output .= __(' To', GEODIREVENTS_TEXTDOMAIN).' '; $output .= '<br />'; $output .= '<i class="fa fa-caret-left"></i>' . date($geodir_date_time_format, $edate); //.'<br />'; $output .= '</p>'; } $output .= '</div>'; echo $output; } if ($ID) { $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID); ?> <div class="geodir-bubble-meta-fade"></div> <div class="geodir-bubble-meta-bottom"> <span class="geodir-bubble-rating"><?php echo $rating_star; ?> </span> <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?> </span> <span class="geodir-bubble-reviews"><a href="<?php echo get_comments_link($ID); ?> " class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?> </a></span> </div> <?php } ?> </div> </div> </div> <?php $html = ob_get_clean(); /** * Filter to change infowindow html * * You can use this filter to change infowindow html. * * @since 1.0.0 * @package GeoDirectory * @param string $html Infowindow html. * @param object $postinfo_obj The Post object. * @param bool|string $post_preview Is this a post preview? */ $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview); return $html; } }
/** * Set post Map Marker info html. * * @since 1.0.0 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". * @package GeoDirectory * @global array $geodir_addon_list List of active GeoDirectory extensions. * @param object $postinfo_obj The post details object. * @param string $post_preview Is this a post preview?. * @return mixed|string|void */ function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') { global $preview; $srcharr = array("'", "/", "-", '"', '\\'); $replarr = array("′", "⁄", "–", "“", ''); if (isset($_SESSION['listing']) && isset($post_preview) && $post_preview != '') { $ID = ''; $plink = ''; if (isset($postinfo_obj->pid)) { $ID = $postinfo_obj->pid; $plink = get_permalink($ID); } $title = str_replace($srcharr, $replarr, $postinfo_obj->post_title); $lat = $postinfo_obj->post_latitude; $lng = $postinfo_obj->post_longitude; $address = str_replace($srcharr, $replarr, $postinfo_obj->post_address); $contact = str_replace($srcharr, $replarr, $postinfo_obj->geodir_contact); $timing = str_replace($srcharr, $replarr, $postinfo_obj->geodir_timing); } else { $ID = $postinfo_obj->post_id; $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan $plink = get_permalink($ID); $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); $address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan $contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8')); $timing = str_replace($srcharr, $replarr, geodir_get_post_meta($ID, 'geodir_timing', true)); } // filter field as per price package global $geodir_addon_list; if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') { $post_type = get_post_type($ID); $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; $field_name = 'geodir_contact'; if (!check_field_visibility($package_id, $field_name, $post_type)) { $contact = ''; } $field_name = 'geodir_timing'; if (!check_field_visibility($package_id, $field_name, $post_type)) { $timing = ''; } } if ($lat && $lng) { ob_start(); ?> <div class="gd-bubble" style=""> <div class="gd-bubble-inside"> <?php $comment_count = ''; $rating_star = ''; if ($ID != '') { $rating_star = ''; $comment_count = geodir_get_review_count_total($ID); if (!$preview) { $post_avgratings = geodir_get_post_rating($ID); $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); /** * Filter to change rating stars * * You can use this filter to change Rating stars. * * @since 1.0.0 * @package GeoDirectory * @param string $rating_star Rating stars. * @param float $post_avgratings Average ratings of the post. * @param int $ID The post ID. */ $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID); } } ?> <div class="geodir-bubble_desc"> <h4> <a href="<?php if ($plink != '') { echo $plink; } else { echo 'javascript:void(0);'; } ?> "><?php echo $title; ?> </a> </h4> <?php if (isset($_SESSION['listing']) && isset($post_preview) && $post_preview != '') { $post_images = array(); if (!empty($postinfo_obj->post_images)) { $post_images = explode(",", $postinfo_obj->post_images); } if (!empty($post_images)) { ?> <div class="geodir-bubble_image"><a href="<?php if ($plink != '') { echo $plink; } else { echo 'javascript:void(0);'; } ?> "><img alt="bubble image" style="max-height:50px;" src="<?php echo $post_images[0]; ?> "/></a></div> <?php } else { echo '<div class="geodir-bubble_image"></div>'; } } else { if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) { ?> <div class="geodir-bubble_image"><a href="<?php echo $plink; ?> "><?php echo $image; ?> </a></div> <?php } else { echo '<div class="geodir-bubble_image"></div>'; } } ?> <div class="geodir-bubble-meta-side"> <?php /** * Fires before the meta info in the map info window. * * This can be used to add more info to the map info window before the normal meta info. * * @since 1.5.4 * @param int $ID The post id. * @param object $postinfo_obj The posts info as an object. * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * */ do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview); ?> <span class="geodir_address"><i class="fa fa-home"></i> <?php echo $address; ?> </span> <?php if ($contact) { ?> <span class="geodir_contact"><i class="fa fa-phone"></i> <?php echo $contact; ?> </span><?php } ?> <?php if ($timing) { ?> <span class="geodir_timing"><i class="fa fa-clock-o"></i> <?php echo $timing; ?> </span><?php } /** * Fires after the meta info in the map info window. * * This can be used to add more info to the map info window after the normal meta info. * * @since 1.4.2 * @param object $postinfo_obj The posts info as an object. * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * */ do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview); ?> </div> <?php if ($ID) { $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID); ?> <div class="geodir-bubble-meta-fade"></div> <div class="geodir-bubble-meta-bottom"> <span class="geodir-bubble-rating"><?php echo $rating_star; ?> </span> <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?> </span> <span class="geodir-bubble-reviews"><a href="<?php echo get_comments_link($ID); ?> " class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?> </a></span> </div> <?php } ?> </div> </div> </div> <?php $html = ob_get_clean(); /** * Filter to change infowindow html * * You can use this filter to change infowindow html. * * @since 1.0.0 * @package GeoDirectory * @param string $html Infowindow html. * @param object $postinfo_obj The Post object. * @param bool|string $post_preview Is this a post preview? */ $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview); return $html; } }
/** * Output the posts microdata in the source code. * * This micordata is used by things like Google as a standard way of declaring things like telephone numbers etc. * * @global bool $preview True of on a preview page. False if not. * @global object $post The current post object. * @since 1.0.0 * @since 1.5.4 Changed to JSON-LD and added filters. * @since 1.5.7 Added $post param. * @param object $post Optional. The post object or blank. * @package GeoDirectory */ function geodir_action_details_micordata($post = '') { global $preview; if (empty($post)) { global $post; } if ($preview || !geodir_is_page('detail')) { return; } // url $c_url = geodir_curPageURL(); // post reviews $post_reviews = get_comments(array('post_id' => $post->ID, 'status' => 'approve')); if (empty($post_reviews)) { $reviews = ''; } else { foreach ($post_reviews as $review) { $reviews[] = array("@type" => "Review", "author" => $review->comment_author, "datePublished" => $review->comment_date, "description" => $review->comment_content, "reviewRating" => array("@type" => "Rating", "bestRating" => "5", "ratingValue" => geodir_get_commentoverall($review->comment_ID), "worstRating" => "1")); } } // post images $post_images = geodir_get_images($post->ID, 'thumbnail', get_option('geodir_listing_no_img')); if (empty($post_images)) { $images = ''; } else { $i_arr = array(); foreach ($post_images as $img) { $i_arr[] = $img->src; } if (count($i_arr) == 1) { $images = $i_arr[0]; } else { $images = $i_arr; } } //print_r($post); // external links $external_links = array(); $external_links[] = $post->geodir_website; $external_links[] = $post->geodir_twitter; $external_links[] = $post->geodir_facebook; $external_links = array_filter($external_links); if (!empty($external_links)) { $external_links = array_values($external_links); } // reviews $comment_count = geodir_get_review_count_total($post->ID); $post_avgratings = geodir_get_post_rating($post->ID); // schema type $schema_type = 'LocalBusiness'; if (isset($post->default_category) && $post->default_category) { $schema_type = get_tax_meta($post->default_category, 'ct_cat_schema', false, $post->post_type); if (!$schema_type && $post->post_type == 'gd_event') { $schema_type = 'Event'; } } $schema = array(); $schema['@context'] = "http://schema.org"; $schema['@type'] = $schema_type; $schema['name'] = $post->post_name; $schema['description'] = wp_strip_all_tags($post->post_content, true); $schema['telephone'] = $post->geodir_contact; $schema['url'] = $c_url; $schema['sameAs'] = $external_links; $schema['image'] = $images; $schema['address'] = array("@type" => "PostalAddress", "streetAddress" => $post->post_address, "addressLocality" => $post->post_city, "addressRegion" => $post->post_region, "addressCountry" => $post->post_country, "postalCode" => $post->post_zip); if ($post->post_latitude && $post->post_longitude) { $schema['geo'] = array("@type" => "GeoCoordinates", "latitude" => $post->post_latitude, "longitude" => $post->post_longitude); } if ($post_avgratings) { $schema['aggregateRating'] = array("@type" => "AggregateRating", "ratingValue" => $post_avgratings, "bestRating" => "5", "worstRating" => "1", "ratingCount" => $comment_count); } $schema['review'] = $reviews; /** * Allow the schema JSON-LD info to be filtered. * * @since 1.5.4 * @since 1.5.7 Added $post variable. * @param array $schema The array of schema data to be filtered. * @param object $post The post object. */ $schema = apply_filters('geodir_details_schema', $schema, $post); echo '<script type="application/ld+json">' . json_encode($schema) . '</script>'; }