Function Reference: geodir_detail_page_review_rating

Summary

Output the current post overall review and a small image compatible with google hreviews.

Deprecated

1.6.3 Use geodir_action_details_micordata()

Global Values

$post
(WP_Post|null) (required) The current post, if available.

Default: None
$preview
(bool) (required) True if the current page is add listing preview page. False if not.

Default: None
$post_images
(object) (required) Image objects of current post if available.

Default: None

Package

GeoDirectory

See

geodir_action_details_micordata()

Change Log

Since: 1.0.0

1.6.16 Changes for disable review stars for certain post type.

Actions

‘geodir_before_detail_page_review_rating’ [Line: 1105]

‘geodir_before_review_rating_stars_on_detail’ [Line: 1120]

‘geodir_after_review_rating_stars_on_detail’ [Line: 1157]

‘geodir_after_detail_page_review_rating’ [Line: 1166]

Filters

‘geodir_detail_page_review_rating_html’ [Line: 1178]

Source File

geodir_detail_page_review_rating() is located in geodirectory_hooks_actions.php [Line: 1090]

Source Code

function geodir_detail_page_review_rating()
{
    global $post, $preview, $post_images;
    
    if (!empty($post->ID) && geodir_cpt_has_rating_disabled((int)$post->ID)) {
        return;
    }
    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 current post.
         * @param int $post->ID Current post ID.
         */
        do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);

        $html = '

'; $html .= geodir_get_rating_stars($post_avgratings, $post->ID); $html .= '

'; $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 .= '' . $post_avgratings . ' / 5 ' . __("based on", 'geodirectory') . ' ' . $comment_count . ' ' . $reviews_text . '
'; $html .= ''; $html .= '' . $post->post_title . ''; if ($post_images) { foreach ($post_images as $img) { $post_img = $img->src; break; } } if (isset($post_img) && $post_img) { $html .= '
' . esc_attr($post->post_title) . ''; } $html .= '
'; echo $html .= '
'; /** * 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 current 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 = '
' . $content_html . '
'; } 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); } }