/**
     * Get the single review via ajax
     *
     * @param array $reviewOptions
     * @param array $ratingFormArray
     * @param int   $lastcommentid
     * @param bool  $ajax
     *
     * @return array|string
     */
    public static function build_user_rating_review_single($reviewOptions = array(), $ratingFormArray = array(), $lastcommentid, $ajax = false)
    {
        global $wpdb;
        $firstLabel = '';
        $post_id = !empty($reviewOptions['post_id']) ? $reviewOptions['post_id'] : get_the_ID();
        if (!empty($reviewOptions['form_id'])) {
            $ratingFormId = $reviewOptions['form_id'];
        } else {
            $defaultFormId = get_option('cbratingsystem_defaultratingForm');
            $ratingFormId = apply_filters('rating_form_array', $defaultFormId);
        }
        if (is_string($reviewOptions['theme']) and !empty($reviewOptions['theme'])) {
            $theme_key = $reviewOptions['theme'];
        } else {
            $theme_key = 'basic';
        }
        $reviews = CBRatingSystemData::get_user_ratings_with_ratingForm_lastID($lastcommentid, true);
        $output = $mainContent = '';
        if (!empty($reviews[0])) {
            if (!empty($reviews) and is_array($reviews)) {
                $jsArray = array();
                $shownReviews = 0;
                foreach ($reviews as $reviewKey => $review) {
                    $mainContent .= '<div id="cbrating-' . $ratingFormId . '-review-' . $review->id . '" data-review-id="' . $review->id . '" data-post-id="' . $post_id . '" data-form-id="' . $ratingFormId . '" class="cbratingsinglerevbox reviews_wrapper_' . $theme_key . '_theme review_wrapper review_wrapper_post-' . $post_id . '_form-' . $ratingFormId . ' review_wrapper_post-' . $post_id . '_form-' . $ratingFormId . '_review-' . $review->id . '">';
                    $mainContent .= '    <div class="cbratingboxinner ' . $reviewOptions['comment_status'] . ' reviews_rating_' . $theme_key . '_theme review_rating review_rating_review-' . $review->id . '">';
                    if (!empty($review->rating) and is_array($review->rating)) {
                        // User Details part.
                        if ($review->user_id != 0) {
                            $user_url = get_author_posts_url($review->user_id);
                            //$name     = get_the_author_meta( 'display_name', $review->user_id );
                            $name = get_user_meta($review->user_id, 'company_name', true);
                            if (!empty($user_url) && $ratingFormArray['show_user_link_in_review'] == '1') {
                                $name = '<a target="_blank" href="' . $user_url . '">' . $name . '</a>';
                            }
                            $name = apply_filters('cbrating_edit_review_user_link', $name, $review->user_id);
                            //finally check the settings
                            if ($ratingFormArray['show_user_avatar_in_review'] == '1') {
                                //                                        $gravatar = get_avatar( $review->user_id, 36 );
                                $gravatar = '<img src="' . WEPN_Helper::supplier_avatar($review->user_id, 'vendor-small-thumb') . '" />';
                            } else {
                                $gravatar = '';
                            }
                            $gravatar = apply_filters('cbrating_edit_review_user_avatar', $gravatar, $review->user_id);
                            $user_html = '  <p class="cbrating_user_name">' . (!empty($user_url) ? '<span class="user_gravatar">' . $gravatar . $name . '</span>' : '<span class="user_gravatar">' . $gravatar . $name . '</span>') . '</p>';
                            if (isset($ratingFormArray['buddypress_active']) && $ratingFormArray['buddypress_active'] == '1') {
                                if (function_exists('bp_is_active')) {
                                    $rating_review_filtered_authorlink = apply_filters('cbratingsystem_buddypress_authorlink', array('show_image' => $ratingFormArray['show_user_avatar_in_review'], 'show_link' => $ratingFormArray['show_user_link_in_review'], 'review_user_id' => $review->user_id, 'user_html' => $user_html));
                                    $user_html = $rating_review_filtered_authorlink['user_html'];
                                }
                            }
                        } else {
                            $user_url = '';
                            $name = !empty($review->user_name) ? $review->user_name : 'Anonymous';
                            if ($ratingFormArray['show_user_avatar_in_review'] == '1') {
                                $gravatar = get_avatar(0, 36, 'gravatar_default');
                            } else {
                                $gravatar = '';
                            }
                            $user_html = '  <p class="cbrating_user_name">' . (!empty($user_url) ? '<span class="user_gravatar">' . $gravatar . $name . '</span>' : '<span class="user_gravatar">' . $gravatar . $name . '</span>') . '</p>';
                        }
                        $user_html = apply_filters('cbrating_edit_review_user_info', $user_html, $review->user_id, $ratingFormArray, $reviewOptions, $review);
                        $mainContent .= '  <div class="reviews_user_details_' . $theme_key . '_theme review_user_details">
                                            			' . $user_html . '
                                            			<span class="user_rate_time"><a title="' . date('l, F d, Y \\a\\t j:ia', $review->created) . '" href="' . get_permalink($post_id) . '#cbrating-' . $ratingFormId . '-review-' . $review->id . '">' . CBRatingSystemFunctions::codeboxr_time_elapsed_string($review->created) . '</a></span>
                                        			</div>
                                        			<div class="clear" style="clear:both;"></div>
                        		';
                        // Criteria Display part.
                        $mainContent .= '<div data-form-id="' . $ratingFormId . '" class="all_criteria_warpper_' . $theme_key . '_theme all-criteria-wrapper all-criteria-wrapper-form-' . $ratingFormId . '">';
                        foreach ($review->rating as $criteriId => $value) {
                            if (is_numeric($criteriId)) {
                                $value = $value / 100 * $review->rating[$criteriId . '_starCount'];
                                $jsArray['review'][$review->id]['ratingForm'] = $ratingFormId;
                                $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_value'] = $value;
                                $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_count'] = $review->rating[$criteriId . '_starCount'];
                                $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_redOnlyHint'] = $review->rating[$criteriId . '_stars'][$value - 1];
                                $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_hints'] = $review->rating[$criteriId . '_stars'];
                                $imgtitle = '';
                                $hello = '';
                                $i = 0;
                                $ratvalue = round($value);
                                for (; $i < $ratvalue; $i++) {
                                    $hello .= '<img src="' . plugins_url('/images/star-on.png', __FILE__) . '" alt="' . $i . '" title="' . $imgtitle . '">';
                                }
                                $whiteimg = $review->rating[$criteriId . '_starCount'] - $ratvalue;
                                for ($j = 0; $j < $whiteimg; $j++) {
                                    $hello .= '<img src="' . plugins_url('/images/star-off.png', __FILE__) . '" alt="' . $j . '" title="' . $imgtitle . '">';
                                }
                                $mainContent .= '<div data-form-id="' . $ratingFormId . '" data-criteria-id="' . $criteriId . '" class="criteria_warpper_' . $theme_key . '_theme criteria-wrapper criteria-id-wrapper-' . $criteriId . ' criteria-id-wrapper-' . $criteriId . '-form-' . $ratingFormId . ' ">
			                                                <div class="criteria_label_warpper_' . $theme_key . '_theme criteria-label-wrapper">
			                                                    <span class="criteria-label criteria-label-id-' . $criteriId . '" ><strong>' . __($review->custom_criteria[$criteriId]['label'], 'cbratingsystem') . '</strong></span>
			                                                </div>
			                                                <div id="criteria-star-wrapper-' . $review->id . '"  data-form-id="' . $ratingFormId . '" data-criteria-id="' . $criteriId . '" class="criteria-star-wrapper criteria-star-wrapper-id-' . $firstLabel . ' criteria-star-wrapper-id-' . $criteriId . '-form-' . $ratingFormId . '"></div>
			                                                <div class="readonly_criteria_average_label_' . $theme_key . '_theme readonly-criteria-average-label criteria-average-label-form-' . $ratingFormId . '-label-' . $criteriId . '">
			                                                    <span class="starTitle">' . sanitize_text_field($review->rating[$criteriId . '_stars'][$value - 1]) . '</span>
			                                                </div>
		                                            </div>';
                            }
                        }
                        $mainContent .= '</div><div class="clear" style="clear:both;"></div>';
                        // Question Display part.
                        $mainContent .= '    <div data-form-id="' . $ratingFormId . '" class="question_wrapper_' . $theme_key . '_theme question-wrapper question-wrapper-form-' . $ratingFormId . '">';
                        if (!empty($review->question) && is_array($review->question)) {
                            foreach ($review->question as $questionId => $value) {
                                $single_question = $review->custom_question[$questionId];
                                $type = $single_question['field']['type'];
                                if (is_array($value)) {
                                    //$single_question =  $review->custom_question[$questionId];
                                    //$type       = $single_question['field']['type'];
                                    $seperated = isset($fieldArr['seperated']) ? intval($fieldArr['seperated']) : 0;
                                    $fieldArr = $single_question['field'][$type];
                                    $valuesText = array();
                                    foreach ($value as $key => $val) {
                                        $valuesText[$review->id][$questionId][] = '<strong>' . __(stripcslashes($fieldArr[$key]['text']), 'cbratingsystem') . '</strong>';
                                    }
                                    if (!empty($valuesText)) {
                                        $mainContent .= '
		                                        <div data-form-id="' . $ratingFormId . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $ratingFormId . ' ">
		                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
		                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
		                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
		                                                <span class="answer"><strong>' . implode(', ', $valuesText[$review->id][$questionId]) . '</strong></span>
		                                            </div>
		                                        </div>
		                                        ';
                                    }
                                } else {
                                    /*$type      = $review->custom_question['enabled'][$questionId]['field']['type'];
                                    		$fieldArr  = $review->custom_question['enabled'][$questionId]['field'][$type];
                                    		$seperated = $fieldArr['seperated'];*/
                                    //$single_question =  $review->custom_question[$questionId];
                                    $seperated = isset($single_question['field']['type']['seperated']) ? intval($single_question['field']['type']['seperated']) : 0;
                                    //$type       = $single_question['field']['type'];
                                    if ($seperated == 0) {
                                        if ($type == 'text') {
                                            $mainContent .= '
			                                        <div data-form-id="' . $ratingFormId . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $ratingFormId . ' ">
			                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
			                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
			                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
			                                                <span class="answer"><strong>' . $value . '</strong></span>
			                                            </div>
			                                        </div>';
                                        } else {
                                            $fieldArr = $single_question['field'][$type];
                                            $mainContent .= '
			                                        <div data-form-id="' . $ratingFormId . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $ratingFormId . ' ">
			                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
			                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
			                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
			                                                <span class="answer"><strong>' . ($value == 1 ? __('Yes', 'cbratingsystem') : __('No', 'cbratingsystem')) . '</strong></span>
			                                            </div>
			                                        </div>';
                                        }
                                    }
                                }
                                //end of else
                            }
                            //end of foreach
                        }
                        $mainContent .= '    </div>
                                        	<div class="clear" style="clear:both;"></div>';
                        // Comment Display part
                        if (!empty($review->comment) and is_string($review->comment)) {
                            $comment = CBRatingSystemFunctions::text_summary_mapper($review->comment);
                            /*
                            if ( is_array( $comment ) && ! empty( $comment['summury'] ) && isset( $comment['rest'] ) ) {
                            	$comment_output = ' <p class="comment">
                            		                                                    ' . stripslashes( $comment['summury'] ) .
                            		( ! empty( $comment['rest'] ) ?
                            			'   <span style="display:none;" class="read_more_paragraph disable_field">' . $comment['rest'] . '</span>' : '' ) .
                            		'</p>
                            		                                    <a href="#" class="js_read_link read_more"> ...More</a>';
                            } else {
                            	$comment_output = '<p class="comment">' . stripslashes($comment['summury']) . '</p>';
                            }
                            */
                            $comment_output = '<p class="comment">' . stripslashes($review->comment) . '</p>';
                            if ($reviewOptions['comment_status'] != 'approved') {
                                if ($reviewOptions['comment_status'] == 'unverified') {
                                    $review_status = 'Your comment is' . $reviewOptions['comment_status'] . '[please check your mail to verify]';
                                } else {
                                    $review_status = $reviewOptions['comment_status'];
                                }
                                $mainContent .= '<div class="review_user_rating_comment_' . $theme_key . '_theme review_user_rating_comment">
		                                            	        <strong>Comment : </strong> ' . $comment_output . ' (' . $review_status . ')' . '
		                                        	          </div>
		                                        	          <div class="clear" style="clear:both;"></div>
		                                     ';
                            } else {
                                $mainContent .= '<div class="review_user_rating_comment_' . $theme_key . '_theme review_user_rating_comment">
		                                            	            <strong>Comment : </strong> ' . $comment_output . '
		                                        	          </div>
		                                        	         <div class="clear" style="clear:both;"></div>
		                                     ';
                            }
                        }
                    }
                    // end if ( ! empty( $review->rating ) and is_array( $review->rating ) )
                    $mainContent .= '</div>';
                    $mainContent .= '</div><div class="clear" style="clear:both;"></div>';
                    $shownReviews++;
                }
                // end foreach
                $output .= $mainContent;
            }
            // end  if ( ! empty( $reviews ) and is_array( $reviews ) )
            $jsSettings = self::front_end_review_js_settings($reviews, $jsArray, $post_id, $ajax);
            $output .= '<script type="text/javascript">' . $jsSettings . '</script>';
            if ($ajax === true) {
                return array('html' => $mainContent . '<script type="text/javascript">' . $jsSettings . '</script>');
            }
            $output = array($output, $review);
            return $output;
        }
        // end  empty( $reviews[0]
    }
示例#2
0
    /**
     * @param $atts
     *
     * @return string
     */
    public static function cbratingsystem_top_rated_user($atts)
    {
        global $post;
        if (!is_object($post)) {
            return '';
        }
        //Example: [cbratingsystem rating_form_id=1]
        $options = shortcode_atts(array('post_id' => '', 'form_id' => '', 'user_id' => '', 'post_time' => '0', 'limit' => 10, 'posttype' => '0', 'post_filter' => '', 'order' => 'DESC', 'title' => __('Top Rated Users', 'cbratingsystem')), $atts);
        //var_dump($options);
        $limit = $options['limit'];
        if ($options['post_time'] != 0) {
            $date = CBRatingSystemFunctions::get_calculated_date($options['post_time']);
            $options['post_date'] = $date;
        }
        $data = CBRatingSystemData::get_top_rated_post($options, false, $limit);
        $cbrp_output = '<ul class="cbrp-top-rated-wpanel" style="">';
        if (!empty($data)) {
            foreach ($data as $newdata) {
                $cbrp_output .= '<li class="cbrp-top-rated-userlist">';
                $author_info = get_userdata((int) $newdata['post_author']);
                $cbrp_output .= '<div style=""> <a style="" href="' . get_author_posts_url((int) $newdata['post_author']) . ' ">' . $author_info->display_name . ' </a></div>
                    <div style=""> ' . $newdata['post_count'] . ' Posts</div>';
                $rating = $newdata['rating'] / 100 * 5;
                ?>
                    <script>
                        jQuery(document).ready(function ($) {
                            $('#cbrp-top-rated<?php 
                echo $newdata['post_author'] . '_' . $post->ID;
                ?>
').raty({
                                half    : true,
                                path    : '<?php 
                echo CB_RATINGSYSTEM_PLUGIN_DIR_IMG;
                ?>
',
                                score   : <?php 
                echo number_format($rating, 2, '.', '');
                ?>
,
                                readOnly: true,
                                hintList: ['', '', '', '', '']
                            });
                        });
                    </script>
                    <?php 
                $cbrp_output .= ' <strong>' . number_format($rating, 2, '.', '') . '/5</strong> ';
                $cbrp_output .= '<div id ="cbrp-top-rated' . $newdata['post_author'] . '_' . $post->ID . '" style=""></div>

                </li>';
            }
        } else {
            $cbrp_output .= ' <li class="cbrp-top-rated-userlist">' . __('No Results found', 'cbratingsystem') . ' </li>';
        }
        $cbrp_output .= '</ul>';
        return $cbrp_output;
    }
    /**
     * Returns Reviews Html Output
     *
     * @param  array   $reviewOptions
     * @param  array   $ratingFormArray
     * @param  boolean $ajax
     *
     * @return string
     */
    public static function build_user_rating_review($reviewOptions = array(), $ratingFormArray = array(), $ajax = false)
    {
        global $wpdb;
        $postID = isset($reviewOptions['post_id']) ? $reviewOptions['post_id'] : get_the_ID();
        $postID = (int) $postID;
        $post = get_post($postID);
        if (in_array($post->post_type, $ratingFormArray['post_types'])) {
            if (!empty($reviewOptions['form_id'])) {
                $form_id = $reviewOptions['form_id'];
            } else {
                $defaultFormId = get_option('cbratingsystem_defaultratingForm');
                $form_id = apply_filters('rating_form_array', $defaultFormId);
            }
            $form_id = (int) $form_id;
            if (!isset($reviewOptions['limit']['perpage'])) {
                // As we only need to get this ratingFormArray from DB to get the offset value.
                $ratingFormArray = CBRatingSystemData::get_ratingForm($form_id);
            }
            if (is_string($reviewOptions['theme']) and !empty($reviewOptions['theme'])) {
                $theme_key = $reviewOptions['theme'];
            } else {
                $theme_key = get_option('cbratingsystem_theme_key');
            }
            $page = isset($reviewOptions['limit']['page']) ? $reviewOptions['limit']['page'] : 1;
            if ($page <= 0) {
                $page = 1;
            }
            $perpage = isset($reviewOptions['limit']['perpage']) ? $reviewOptions['limit']['perpage'] : $ratingFormArray['review_limit'];
            //$start      = isset( $reviewOptions['limit']['start'] ) ? $reviewOptions['limit']['start']: (($page -1)*$perpage) ;
            //let's confirm the limit array once again
            $reviewOptions['limit']['page'] = $page;
            $reviewOptions['limit']['perpage'] = $perpage;
            //$reviewOptions['limit']['start']    = $start;
            $totalLimit = $wpdb->get_var("SELECT per_post_rating_count AS count FROM " . $wpdb->prefix . "cbratingsystem_ratings_summary WHERE form_id='{$form_id}' AND post_id='{$postID}'");
            $reviews = array();
            if ($totalLimit > $perpage) {
                $showLoadMoreButton = true;
                $reviews = CBRatingSystemData::get_user_ratings_with_ratingForm(array($form_id), array($postID), array(), '', 'time', 'DESC', $reviewOptions['limit'], true);
            } else {
                $showLoadMoreButton = false;
                $reviews = CBRatingSystemData::get_user_ratings_with_ratingForm(array($form_id), array($postID), array(), '', 'time', 'DESC', array(), true);
            }
            $output = $mainContent = '';
            $jsArray = array();
            $shownReviews = 0;
            $review_output = '';
            if (!empty($reviews[0])) {
                //$output .= '<h3 id="cbratingfrom_reviews_title-'.$form_id.'" class="cbratingfrom_reviews_title">' .sprintf( __( "Reviews (%d)", 'cbratingsystem' ), $totalLimit) . '</h3>';
                $review_heading = '<h3 id="cbratingfrom_reviews_title-' . $form_id . '" class="cbratingfrom_reviews_title">' . sprintf(__("Reviews (%d)", 'cbratingsystem'), $totalLimit) . '</h3>';
                $review_output .= '<div id="reviews_container_' . $postID . '" data-post-id="' . $postID . '" data-form-id="' . $form_id . '" class="reviews_container reviews_container_' . $theme_key . '_theme  reviews_container_post-' . $postID . '_form-' . $form_id . ' ">';
                $review_output .= '<div data-post-id="' . $postID . '" data-form-id="' . $form_id . '" class="reviews_container_div_' . $theme_key . '_theme reviews_container_div reviews_container_div_post-' . $postID . '_form-' . $form_id . ' ">';
                //$shownReviews = 0;
                if (!empty($reviews) && is_array($reviews)) {
                    //$shownReviews = 0;
                    //var_dump('manchu man');
                    //review loop
                    foreach ($reviews as $reviewKey => $review) {
                        /*echo '<pre>';
                        		print_r($review);
                        		echo '</pre>';*/
                        $comment_status = self::check_cpmment_status($review->comment_status, $review->user_session, $review->user_ip);
                        $show_reviews_user = self::check_permission($ratingFormArray['comment_view_allowed_users'], $review->user_session, $review->user_ip);
                        if ($show_reviews_user && $comment_status) {
                            //$output .= '<a name="cbrating-'.$form_id.'-review-'.$review->id.'" id="cbrating-'.$form_id.'-review-'.$review->id.'"></a>';
                            $mainContent .= '<div itemprop="review" itemscope itemtype="http://schema.org/Review" id="cbrating-' . $form_id . '-review-' . $review->id . '" data-review-id="' . $review->id . '" data-post-id="' . $postID . '" data-form-id="' . $form_id . '" class="reviews_wrapper_' . $theme_key . '_theme review_wrapper review_wrapper_post-' . $postID . '_form-' . $form_id . ' review_wrapper_post-' . $postID . '_form-' . $form_id . '_review-' . $review->id . '">';
                            $mainContent .= '    <div class="reviews_rating_' . $theme_key . '_theme review_rating review_rating_review-' . $review->id . '">';
                            if (!empty($review->rating) and is_array($review->rating)) {
                                // User Details part.
                                if ($review->user_id != 0) {
                                    $user_url = get_author_posts_url($review->user_id);
                                    //$name     = get_the_author_meta( 'display_name', $review->user_id );
                                    $name = get_user_meta($review->user_id, 'company_name', true);
                                    if (!empty($user_url) && $ratingFormArray['show_user_link_in_review'] == '1') {
                                        $name = '<a target="_blank" href="' . $user_url . '">' . $name . '</a>';
                                    }
                                    //finally check the settings
                                    if ($ratingFormArray['show_user_avatar_in_review'] == '1') {
                                        //                                        $gravatar = get_avatar( $review->user_id, 36 );
                                        $gravatar = '<img src="' . WEPN_Helper::supplier_avatar($review->user_id, 'vendor-small-thumb') . '" />';
                                        //wp_get_attachment_image( get_user_meta( $review->user_id, 'profile_image', true ), 'vendor-small-thumb' );
                                    } else {
                                        $gravatar = '';
                                    }
                                    $name = apply_filters('cbrating_edit_review_user_link', $name, $review->user_id);
                                    $gravatar = apply_filters('cbrating_edit_review_user_avatar', $gravatar, $review->user_id);
                                    $user_html = !empty($user_url) ? '<span itemprop="author" itemscope itemtype="http://schema.org/Person" class="user_gravatar">' . $gravatar . '<span itemprop="name">' . $name . '</span>' . '</span>' : '<span itemprop="author" itemscope itemtype="http://schema.org/Person" class="user_gravatar">' . $gravatar . '<span itemprop="name">' . $name . '</span>' . '</span>';
                                    if (isset($ratingFormArray['buddypress_active']) && intval($ratingFormArray['buddypress_active'])) {
                                        if (function_exists('bp_is_active')) {
                                            $rating_review_filtered_authorlink = apply_filters('cbratingsystem_buddypress_authorlink', array('show_image' => $ratingFormArray['show_user_avatar_in_review'], 'show_link' => $ratingFormArray['show_user_link_in_review'], 'review_user_id' => $review->user_id, 'user_html' => $user_html));
                                            $user_html = $rating_review_filtered_authorlink['user_html'];
                                        }
                                    }
                                } else {
                                    $user_url = '';
                                    $name = !empty($review->user_name) ? $review->user_name : __('Anonymous', 'cbratingsystem');
                                    if ($ratingFormArray['show_user_avatar_in_review'] == '1') {
                                        //                                        $gravatar  = get_avatar( 0, 36, 'gravatar_default' );
                                        //$gravatar = wp_get_attachment_image( get_user_meta( $review->user_id, 'profile_image', true ), 'vendor-small-thumb' );
                                        $gravatar = '<img src="' . WEPN_Helper::supplier_avatar($review->user_id, 'vendor-small-thumb') . '" />';
                                    } else {
                                        $gravatar = '';
                                    }
                                    $user_html = !empty($user_url) ? '<span class="user_gravatar">' . $gravatar . $name . '</span>' : '<span class="user_gravatar">' . $gravatar . $name . '</span>';
                                }
                                $modified_review = (array) $review;
                                $user_html = apply_filters('cbrating_edit_review_user_info', $user_html, $review->user_id, $ratingFormArray, $modified_review, $review);
                                $mainContent .= '    <div class="reviews_user_details_' . $theme_key . '_theme review_user_details">
                                                           <p class="cbrating_user_name">' . $user_html . '<span class="user_rate_value" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" title="' . sprintf(__('Rated %s out of 5', 'cbratingsystem'), $review->average / 100 * 5) . '">
														         ( <span itemprop="ratingValue">' . $review->average / 100 * 5 . '</span> ' . __('out of', 'cbratingsystem') . '  <span itemprop="bestRating">5</span> )
														    </span>' . '</p>' . '<span class="user_rate_time"><a title="' . date('l, F d, Y \\a\\t j:ia', $review->created) . '" href="' . get_permalink($postID) . '#cbrating-' . $form_id . '-review-' . $review->id . '">' . CBRatingSystemFunctions::codeboxr_time_elapsed_string($review->created) . '</a></span>
                                                        </div>
                                                        <div class="clear" style="clear:both;"></div> ';
                                /*$mainContent .='<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="'. sprintf( __( 'Rated %s out of 5', 'cbratingsystem' ), ( ( $review->average / 100 ) * 5 ) ) .'">
                                							<span ><strong itemprop="ratingValue">'.( ( $review->average / 100 ) * 5 ).'</strong> '. __( 'out of 5', 'cbratingsystem' ) .'</span>
                                		</div>';*/
                                $mainContent .= '    <div data-form-id="' . $form_id . '" class="all-criteria-wrapper all_criteria_warpper_' . $theme_key . '_theme  all-criteria-wrapper-form-' . $form_id . ' all-criteria-wrapper-form-' . $form_id . $theme_key . '_theme">';
                                foreach ($review->rating as $criteriId => $value) {
                                    if (is_numeric($criteriId)) {
                                        $firstLabel = '';
                                        $value = $value / 100 * $review->rating[$criteriId . '_starCount'];
                                        $jsArray['review'][$review->id]['ratingForm'] = $form_id;
                                        $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_value'] = $value;
                                        $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_count'] = $review->rating[$criteriId . '_starCount'];
                                        $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_redOnlyHint'] = $review->rating[$criteriId . '_stars'][$value - 1];
                                        $jsArray['review'][$review->id]['criteria']['review_' . $review->id . '_criteria_' . $criteriId . '_hints'] = $review->rating[$criteriId . '_stars'];
                                        $mainContent .= '<div data-form-id="' . $form_id . '" data-criteria-id="' . $criteriId . '" class="criteria_warpper_' . $theme_key . '_theme criteria-wrapper criteria-id-wrapper-' . $criteriId . ' criteria-id-wrapper-' . $criteriId . '-form-' . $form_id . ' ">
				                                                <div class="criteria_label_warpper_' . $theme_key . '_theme criteria-label-wrapper">
				                                                    <span class="criteria-label criteria-label-id-' . $criteriId . '" ><strong>' . __($review->custom_criteria[$criteriId]['label'], 'cbratingsystem') . '</strong></span>
				                                                </div>
				                                                <div data-form-id="' . $form_id . '" data-criteria-id="' . $criteriId . '" class="criteria-star-wrapper criteria-star-wrapper-id-' . $firstLabel . ' criteria-star-wrapper-id-' . $criteriId . '-form-' . $form_id . '" id="criteria-star-wrapper-' . $review->id . '"></div>
				                                                <div class="readonly_criteria_average_label_' . $theme_key . '_theme readonly-criteria-average-label criteria-average-label-form-' . $form_id . '-label-' . $criteriId . '">
				                                                    <span class="starTitle">' . sanitize_text_field($review->rating[$criteriId . '_stars'][$value - 1]) . '</span>
				                                                </div>
		                                                     </div> ';
                                    }
                                }
                                $mainContent .= '</div>
                                        <div class="clear" style="clear:both;"></div>';
                                ////////////////////////////////////////////////
                                // Question Display part.
                                $mainContent .= '<div data-form-id="' . $form_id . '" class="question_wrapper_' . $theme_key . '_theme question-wrapper question-wrapper-form-' . $form_id . '">';
                                if (!empty($review->question) && is_array($review->question)) {
                                    foreach ($review->question as $questionId => $question) {
                                        $single_question = $review->custom_question[$questionId];
                                        $type = $single_question['field']['type'];
                                        if (is_array($question)) {
                                            $fieldArr = $single_question['field'][$type];
                                            $seperated = isset($fieldArr['seperated']) ? intval($fieldArr['seperated']) : 0;
                                            $valuesText = array();
                                            foreach ($question as $key => $val) {
                                                $valuesText[$review->id][$questionId][] = '<strong>' . __(stripcslashes($fieldArr[$key]['text']), 'cbratingsystem') . '</strong>';
                                            }
                                            if (!empty($valuesText)) {
                                                $mainContent .= '
		                                        <div data-form-id="' . $form_id . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $form_id . ' ">
		                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
		                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
		                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
		                                                <span class="answer"><strong>' . implode(', ', $valuesText[$review->id][$questionId]) . '</strong></span>
		                                            </div>
		                                        </div>';
                                            }
                                        } else {
                                            $seperated = isset($single_question['field'][$type]['seperated']) ? intval($single_question['field'][$type]['seperated']) : 0;
                                            //either checkbox single select or text area
                                            if ($seperated == 0) {
                                                if ($type == 'text') {
                                                    $mainContent .= '
			                                        <div data-form-id="' . $form_id . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $form_id . ' ">
			                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
			                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
			                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
			                                                <span class="answer"><strong>' . $question . '</strong></span>
			                                            </div>
			                                        </div>';
                                                } else {
                                                    //$fieldArr   = $single_question['field'][$type];
                                                    $mainContent .= '
			                                        <div data-form-id="' . $form_id . '" data-q-id="' . $questionId . '" class="question_id_wrapper_' . $theme_key . '_theme question-id-wrapper-' . $questionId . ' question-id-wrapper-' . $questionId . '-form-' . $form_id . ' ">
			                                            <div class="question_label_wrapper_' . $theme_key . '_theme question-label-wrapper">
			                                                <span class="question-label question-label-id-' . $questionId . '" >' . (isset($review->custom_question[$questionId]) ? __(stripslashes($review->custom_question[$questionId]['title']), 'cbratingsystem') : '') . '</span>
			                                                <span class="question-label-hiphen">' . (isset($review->custom_question[$questionId]) ? ' - ' : '') . '</span>
			                                                <span class="answer"><strong>' . ($question == 1 ? __("Yes", 'cbratingsystem') : __("No", 'cbratingsystem')) . '</strong></span>
			                                            </div>
			                                        </div>';
                                                }
                                            }
                                        }
                                    }
                                    //end each single question loop
                                }
                                $mainContent .= '    </div>
                                        <div class="clear" style="clear:both;"></div>';
                                ///////////////////////////////////////////
                                // Comment Display part
                                if (!empty($review->comment) && is_string($review->comment)) {
                                    //$comment = CBRatingSystemFunctions :: text_summary_mapper( $review->comment );
                                    $comment = $review->comment;
                                    //$comment_output = '<p class="comment">' . htmlspecialchars($comment). '</p>';
                                    $comment_output = '<p itemprop="reviewBody" class="comment">' . stripslashes($comment) . '</p>';
                                    $mainContent .= '<div class="review_user_rating_comment_' . $theme_key . '_theme review_user_rating_comment">
                                           			 <strong>Comment : </strong> ' . $comment_output;
                                    if ($review->comment_status != 'approved') {
                                        $mainContent .= '<br> <strong>Comment Status : </strong> ' . ucfirst($review->comment_status) . '

                                       			    </div>
                                        		    <div class="clear" style="clear:both;"></div>
                                     ';
                                    } else {
                                        $mainContent .= '

                                       			 </div>
                                        		<div class="clear" style="clear:both;"></div>
                                    ';
                                    }
                                }
                                //////////////////////////////////////////////////
                            }
                            $mainContent .= '</div>';
                            $mainContent .= '</div>
						<div class="clear" style="clear:both;"></div>';
                            $shownReviews++;
                        }
                        // end of if approved
                    }
                    //end for each review
                    $review_output .= $mainContent;
                }
                $review_output .= '</div>';
                $review_output .= '</div>';
                if ($shownReviews > 0) {
                    $output .= $review_heading;
                }
                $output .= $review_output;
                //add the
                //var_dump($form_id);
                if ($showLoadMoreButton === true) {
                    //$output .= "<div class=\"load_more_button_".$theme_key."_theme load_more_button load_more_button_form-" . $form_id . "_post-$postID\" data-form-id=\"$form_id\" data-post-id=\"$postID\" data-offset=\"$offset\" data-start=\"$start\" data-end=\"$currentOffset\" clickable=\"true\">";
                    $output .= '<p class="cbratingload_more_button load_more_button load_more_button_' . $theme_key . '_theme  load_more_button_form-' . $form_id . '_post-' . $postID . '" >';
                    //$output .= '<a  href="#" data-form-id="'.$form_id.'" data-post-id="'.$postID.'" data-page="'.$page.'" data-perpage="'.$perpage.'" data-start="'.$start.'" clickable="true">'.__( 'Load More', 'cbratingsystem' );
                    $output .= '<a  href="#" data-form-id="' . $form_id . '" data-post-id="' . $postID . '" data-page="' . $page . '" data-perpage="' . $perpage . '"  clickable="true">' . __('Load More', 'cbratingsystem');
                    $output .= '<span style="display:none;" class="cbrating_waiting_icon cbrating_waiting_icon_form-' . $form_id . '_post-' . $postID . '"><img alt="' . __("Loading", 'cbratingsystem') . '" src="' . CB_RATINGSYSTEM_PLUGIN_DIR_URL . 'images/ajax-loader.gif" /></span>';
                    $output .= '<input type="hidden" id="cb_ratingForm_front_review_nonce_field" value="' . wp_create_nonce('cb_ratingForm_front_review_nonce_field') . '" />';
                    $output .= '</a>';
                    $output .= "</p>";
                    $output .= '<div  class="ratingFormReviewStatus ratingFormReviewStatus_' . $theme_key . '_theme  ratingFormReviewStatus-review-form-' . $form_id . '"></div>';
                }
                //$output .= '</div>';//this is the error
            }
            $jsSettings = self::front_end_review_js_settings($reviews, $jsArray, $postID, $ajax);
            $output .= '<script type="text/javascript">' . $jsSettings . '</script>';
            $totalpages = ceil($totalLimit / $perpage);
            //var_dump($totalpages);
            if ($ajax === true) {
                return array('html' => $mainContent . '<script type="text/javascript">' . $jsSettings . '</script>', 'page' => $page, 'perpage' => $perpage, 'isFinished' => $page >= $totalpages ? '1' : '0');
            }
            return $output;
        } else {
            return '';
        }
    }