/** * 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; }
/** * Adds rating box to admin comment edit page. * * @since 1.0.0 * @package GeoDirectory_Review_Rating_Manager * * @global object $wpdb WordPress Database object. * * @param object $comment Comment object. * @return bool */ function geodir_reviewrating_comment_rating_box($comment) { if ($overall_star = get_option('geodir_reviewrating_overall_count')) { $post_type = get_post_type($comment->comment_post_ID); $all_postypes = geodir_get_posttypes(); if (!in_array($post_type, $all_postypes)) { return false; } $overall_star_lable = get_option('geodir_reviewrating_overall_rating_texts'); $star_color = get_option('geodir_reviewrating_overall_color'); $overall_star_offimg = get_option('geodir_reviewrating_overall_off_img'); $star_width = get_option('geodir_reviewrating_overall_off_img_width'); global $comment, $wpdb, $is_geodir_loop; $comment_ratings = geodir_reviewrating_get_comment_rating_by_id($comment->comment_ID); if (!empty($comment_ratings)) { ?> <div id="gd_ratings_module"> <div id="rating_frm" style="margin-top:15px;"> <lable for="rating"><?php _e('You can rate the area', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </lable> <div class="gd-rating-box-in clearfix"> <div class="gd-rating-box-in-left"> <div class="gd-rate-area clearfix"> <span class="gd-ratehead"><?php _e('Rate this area:', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </span> <ul class="rate-area-list"> <?php for ($star = 1; $star <= $overall_star; $star++) { if ($comment_ratings->overall_rating && $star <= (int) $comment_ratings->overall_rating) { $active = 'active'; } else { $active = ''; } $overall_star_text = isset($overall_star_lable[$star - 1]) ? esc_attr($overall_star_lable[$star - 1]) : ''; $overall_star_text = stripslashes_deep(__($overall_star_text, GEODIRECTORY_TEXTDOMAIN)); ?> <li star_rating="<?php echo $star; ?> " star_lable="<?php echo $overall_star_text; ?> " class="gd-multirating-star <?php echo $active; ?> "><a><img src="<?php echo $overall_star_offimg; ?> " style="width:<?php echo $star_width; ?> px" alt="<?php esc_attr_e('rating icon', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /></a></li> <?php } ?> </ul> <?php $overall_star_text = isset($overall_star_lable[$comment_ratings->overall_rating - 1]) ? esc_attr($overall_star_lable[$comment_ratings->overall_rating - 1]) : ''; $overall_star_text = stripslashes_deep(__($overall_star_text, GEODIRECTORY_TEXTDOMAIN)); ?> <style>#rating_frm ul.rate-area-list li.active{background-color:<?php echo $star_color; ?> }</style> <span class="gd-rank"><?php echo $comment_ratings->overall_rating ? $overall_star_text : ' '; ?> </span> <input type="hidden" name="geodir_rating[overall]" value="<?php echo $comment_ratings->overall_rating ? $comment_ratings->overall_rating : '0'; ?> " /> </div> <?php $post_type = get_post_type($comment->comment_post_ID); $post_categories = wp_get_post_terms($comment->comment_post_ID, $post_type . 'category', array('fields' => 'ids')); $ratings = geodir_reviewrating_rating_categories(); $old_ratings = @unserialize($comment_ratings->ratings); if ($ratings) { ?> <div class="gd-rate-category clearfix"> <span class="gd-ratehead"><?php _e('Rate this area:', GEODIRREVIEWRATING_TEXTDOMAIN); ?> </span> <div><?php foreach ($ratings as $rating) { //$star_lable = explode(",",$rating->star_lables); $star_lable = geodir_reviewrating_star_lables_to_arr($rating->star_lables, true); $rating->title = isset($rating->title) && $rating->title != '' ? __($rating->title, GEODIRECTORY_TEXTDOMAIN) : ''; $rating_cat = explode(",", $rating->category); $showing_cat = array_intersect($rating_cat, $post_categories); if (!empty($showing_cat)) { if ($rating->check_text_rating_cond) { ?> <div class="clearfix gd-rate-cat-in"> <span class="lable"><?php echo $rating->title; ?> </span> <ul class="rate-area-list rating-<?php echo $rating->id; ?> "> <?php for ($star = 1; $star <= $rating->star_number; $star++) { if ($old_ratings[$rating->id] && $star <= (int) $old_ratings[$rating->id]) { $active = 'active'; } else { $active = ''; } $star_lable_text = isset($star_lable[$star - 1]) ? esc_attr($star_lable[$star - 1]) : ''; $star_lable_text = stripslashes_deep($star_lable_text); ?> <li star_rating="<?php echo $star; ?> " star_lable="<?php echo $star_lable_text; ?> " class="gd-multirating-star <?php echo $active; ?> "><a><img src="<?php echo $rating->s_img_off; ?> " style="width:<?php echo $rating->s_img_width; ?> px" alt="<?php esc_attr_e('rating icon', GEODIRREVIEWRATING_TEXTDOMAIN); ?> " /></a></li> <?php } ?> </ul> <?php $star_lable_text = isset($star_lable[$old_ratings[$rating->id] - 1]) ? esc_attr($star_lable[$old_ratings[$rating->id] - 1]) : ''; $star_lable_text = stripslashes_deep($star_lable_text); ?> <style>#rating_frm ul.rating-<?php echo $rating->id; ?> li.active{background-color:<?php echo $rating->star_color; ?> }</style> <span class="gd-rank"><?php echo $old_ratings[$rating->id] ? $star_lable_text : ' '; ?> </span> <input type="hidden" name="geodir_rating[<?php echo $rating->id; ?> ]" value="<?php echo $old_ratings[$rating->id] ? $old_ratings[$rating->id] : '0'; ?> " /> </div> <?php } else { ?> <div class="clearfix gd-rate-cat-in"> <span class="lable"><?php _e($rating->title, GEODIRREVIEWRATING_TEXTDOMAIN); ?> </span> <select name="geodir_rating[<?php echo $rating->id; ?> ]" > <?php for ($star = 1; $star <= $rating->star_number; $star++) { $star_lable_text = isset($star_lable[$star - 1]) ? esc_attr($star_lable[$star - 1]) : ''; $star_lable_text = stripslashes_deep($star_lable_text); ?> <option value="<?php echo $star; ?> " <?php if ($old_ratings[$rating->id]) { echo 'selected="selected"'; } ?> ><?php echo $star_lable_text; ?> </option> <?php } ?> </select> </div> <?php } } // endif } ?> </div> </div> <?php } ?> </div> </div> </div> </div> <?php } } }