/**
 * Adds overall rating to the admin comments.
 *
 * @since 1.0.0
 * @package GeoDirectory_Review_Rating_Manager
 *
 * @param array $a Comment actions.
 * @return mixed
 */
function geodir_reviewrating_comment_meta_row_action($a)
{
    global $comment;
    $rating = geodir_get_commentoverall($comment->comment_ID);
    if ($rating != 0) {
        $comment_ratings = geodir_reviewrating_get_comment_rating_by_id($comment->comment_ID);
        echo geodir_reviewrating_draw_overall_rating($comment_ratings->overall_rating);
    }
    return $a;
}
Example #2
0
/**
 * Add rating information in comment text.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @param string $content The comment content.
 * @param object|string $comment The comment object.
 * @return string The comment content.
 */
function geodir_wrap_comment_text($content, $comment = '')
{
    $rating = 0;
    if (!empty($comment)) {
        $rating = geodir_get_commentoverall($comment->comment_ID);
    }
    if ($rating != 0 && !is_admin()) {
        return '<div>' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
    } else {
        return $content;
    }
}
/**
 * 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>';
}