@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function geodir_comment_meta_row_action($a) |
| 33 | 33 | {
|
| 34 | - global $comment; |
|
| 34 | + global $comment; |
|
| 35 | 35 | |
| 36 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 37 | - if ($rating != 0) {
|
|
| 38 | - echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
| 39 | - } |
|
| 40 | - return $a; |
|
| 36 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 37 | + if ($rating != 0) {
|
|
| 38 | + echo geodir_get_rating_stars($rating, $comment->comment_ID); |
|
| 39 | + } |
|
| 40 | + return $a; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | add_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
|
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function geodir_comment_add_meta_box($comment) |
| 54 | 54 | {
|
| 55 | - add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
|
|
| 55 | + add_meta_box('gd-comment-rating', __('Comment Rating', 'geodirectory'), 'geodir_comment_rating_meta', 'comment', 'normal', 'high');
|
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param object $comment The comment object. |
| 67 | 67 | */ |
| 68 | 68 | function geodir_comment_rating_meta($comment) {
|
| 69 | - $post_type = get_post_type($comment->comment_post_ID); |
|
| 69 | + $post_type = get_post_type($comment->comment_post_ID); |
|
| 70 | 70 | if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0 && !(!empty($post_type) && geodir_cpt_has_rating_disabled($post_type))) {
|
| 71 | 71 | $rating = geodir_get_commentoverall($comment->comment_ID); |
| 72 | 72 | |
@@ -106,24 +106,24 @@ discard block |
||
| 106 | 106 | * @global object $post The post object. |
| 107 | 107 | */ |
| 108 | 108 | function geodir_comment_rating_fields() {
|
| 109 | - global $post; |
|
| 109 | + global $post; |
|
| 110 | 110 | |
| 111 | - $post_types = geodir_get_posttypes(); |
|
| 111 | + $post_types = geodir_get_posttypes(); |
|
| 112 | 112 | |
| 113 | - if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
|
|
| 114 | - $star_texts = array(); |
|
| 115 | - $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 116 | - $star_texts[] = __('Poor', 'geodirectory');
|
|
| 117 | - $star_texts[] = __('Average', 'geodirectory');
|
|
| 118 | - $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 119 | - $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 113 | + if (!empty($post->post_type) && in_array($post->post_type, $post_types) && !(!empty($post->post_type) && geodir_cpt_has_rating_disabled($post->post_type))) {
|
|
| 114 | + $star_texts = array(); |
|
| 115 | + $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 116 | + $star_texts[] = __('Poor', 'geodirectory');
|
|
| 117 | + $star_texts[] = __('Average', 'geodirectory');
|
|
| 118 | + $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 119 | + $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 120 | 120 | |
| 121 | - $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 122 | - echo $gd_rating_html; |
|
| 123 | - ?> |
|
| 121 | + $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 122 | + echo $gd_rating_html; |
|
| 123 | + ?> |
|
| 124 | 124 | <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/> |
| 125 | 125 | <?php |
| 126 | - } |
|
| 126 | + } |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | add_filter('comment_reply_link', 'geodir_comment_replaylink');
|
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | function geodir_comment_replaylink($link) |
| 139 | 139 | {
|
| 140 | 140 | |
| 141 | - $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
| 141 | + $link = '<div class="gd_comment_replaylink">' . $link . '</div>'; |
|
| 142 | 142 | |
| 143 | - return $link; |
|
| 143 | + return $link; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | add_filter('cancel_comment_reply_link', 'geodir_cancle_replaylink');
|
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | function geodir_cancle_replaylink($link) |
| 156 | 156 | {
|
| 157 | 157 | |
| 158 | - $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
| 158 | + $link = '<span class="gd-cancel-replaylink">' . $link . '</span>'; |
|
| 159 | 159 | |
| 160 | - return $link; |
|
| 160 | + return $link; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | add_action('comment_post', 'geodir_save_rating');
|
@@ -173,32 +173,32 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function geodir_save_rating($comment = 0) |
| 175 | 175 | {
|
| 176 | - global $wpdb, $user_ID, $plugin_prefix; |
|
| 176 | + global $wpdb, $user_ID, $plugin_prefix; |
|
| 177 | 177 | |
| 178 | - $comment_info = get_comment($comment); |
|
| 178 | + $comment_info = get_comment($comment); |
|
| 179 | 179 | |
| 180 | - $post_id = $comment_info->comment_post_ID; |
|
| 181 | - $status = $comment_info->comment_approved; |
|
| 182 | - $rating_ip = getenv("REMOTE_ADDR");
|
|
| 180 | + $post_id = $comment_info->comment_post_ID; |
|
| 181 | + $status = $comment_info->comment_approved; |
|
| 182 | + $rating_ip = getenv("REMOTE_ADDR");
|
|
| 183 | 183 | |
| 184 | - $post = geodir_get_post_info($post_id); |
|
| 185 | - if (empty($post)) {
|
|
| 186 | - return; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - if ($post->post_status == 'publish') {
|
|
| 190 | - $post_status = '1'; |
|
| 191 | - } else {
|
|
| 192 | - $post_status = '0'; |
|
| 193 | - } |
|
| 184 | + $post = geodir_get_post_info($post_id); |
|
| 185 | + if (empty($post)) {
|
|
| 186 | + return; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + if ($post->post_status == 'publish') {
|
|
| 190 | + $post_status = '1'; |
|
| 191 | + } else {
|
|
| 192 | + $post_status = '0'; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 196 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 195 | + if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 196 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 197 | 197 | |
| 198 | 198 | if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
| 199 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 199 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 200 | 200 | |
| 201 | - $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
|
| 201 | + $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
|
| 202 | 202 | post_id = %d, |
| 203 | 203 | post_type = %s, |
| 204 | 204 | post_title = %s, |
@@ -216,35 +216,35 @@ discard block |
||
| 216 | 216 | post_latitude = %s, |
| 217 | 217 | comment_content = %s |
| 218 | 218 | ", |
| 219 | - array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
|
|
| 220 | - ); |
|
| 221 | - |
|
| 222 | - $wpdb->query($sqlqry); |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Called after saving the comment. |
|
| 226 | - * |
|
| 227 | - * @since 1.0.0 |
|
| 228 | - * @package GeoDirectory |
|
| 229 | - * @param array $_REQUEST {
|
|
| 230 | - * Attributes of the $_REQUEST variable. |
|
| 231 | - * |
|
| 232 | - * @type string $geodir_overallrating Overall rating. |
|
| 233 | - * @type string $comment Comment text. |
|
| 234 | - * @type string $submit Submit button text. |
|
| 235 | - * @type string $comment_post_ID Comment post ID. |
|
| 236 | - * @type string $comment_parent Comment Parent ID. |
|
| 237 | - * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
| 238 | - * |
|
| 239 | - * } |
|
| 240 | - */ |
|
| 241 | - do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
|
|
| 242 | - |
|
| 243 | - if ($status) {
|
|
| 244 | - geodir_update_postrating($post_id); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 219 | + array($post_id, $post->post_type, $post->post_title, $user_ID, $comment, $rating_ip, $overall_rating, $status, $post_status, date_i18n('Y-m-d H:i:s', current_time('timestamp')), $post->post_city, $post->post_region, $post->post_country, $post->post_latitude, $post->post_longitude, $comment_info->comment_content)
|
|
| 220 | + ); |
|
| 221 | + |
|
| 222 | + $wpdb->query($sqlqry); |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Called after saving the comment. |
|
| 226 | + * |
|
| 227 | + * @since 1.0.0 |
|
| 228 | + * @package GeoDirectory |
|
| 229 | + * @param array $_REQUEST {
|
|
| 230 | + * Attributes of the $_REQUEST variable. |
|
| 231 | + * |
|
| 232 | + * @type string $geodir_overallrating Overall rating. |
|
| 233 | + * @type string $comment Comment text. |
|
| 234 | + * @type string $submit Submit button text. |
|
| 235 | + * @type string $comment_post_ID Comment post ID. |
|
| 236 | + * @type string $comment_parent Comment Parent ID. |
|
| 237 | + * @type string $_wp_unfiltered_html_comment Unfiltered html comment string. |
|
| 238 | + * |
|
| 239 | + * } |
|
| 240 | + */ |
|
| 241 | + do_action('geodir_after_save_comment', $_REQUEST, 'Comment Your Post');
|
|
| 242 | + |
|
| 243 | + if ($status) {
|
|
| 244 | + geodir_update_postrating($post_id); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -262,51 +262,51 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function geodir_update_rating_status_change($comment_id, $status) |
| 264 | 264 | {
|
| 265 | - if ($status == 'delete') {
|
|
| 266 | - return; |
|
| 267 | - } |
|
| 268 | - global $wpdb, $plugin_prefix, $user_ID; |
|
| 265 | + if ($status == 'delete') {
|
|
| 266 | + return; |
|
| 267 | + } |
|
| 268 | + global $wpdb, $plugin_prefix, $user_ID; |
|
| 269 | 269 | |
| 270 | - $comment_info = get_comment($comment_id); |
|
| 270 | + $comment_info = get_comment($comment_id); |
|
| 271 | 271 | |
| 272 | - $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
| 272 | + $post_id = isset($comment_info->comment_post_ID) ? $comment_info->comment_post_ID : ''; |
|
| 273 | 273 | |
| 274 | - if (!empty($comment_info)) |
|
| 275 | - $status = $comment_info->comment_approved; |
|
| 274 | + if (!empty($comment_info)) |
|
| 275 | + $status = $comment_info->comment_approved; |
|
| 276 | 276 | |
| 277 | - if ($status == 'approve' || $status == 1) {
|
|
| 278 | - $status = 1; |
|
| 279 | - } else {
|
|
| 280 | - $status = 0; |
|
| 281 | - } |
|
| 277 | + if ($status == 'approve' || $status == 1) {
|
|
| 278 | + $status = 1; |
|
| 279 | + } else {
|
|
| 280 | + $status = 0; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
| 284 | - $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
| 283 | + $comment_info_ID = isset($comment_info->comment_ID) ? $comment_info->comment_ID : ''; |
|
| 284 | + $old_rating = geodir_get_commentoverall($comment_info_ID); |
|
| 285 | 285 | |
| 286 | - $post_type = get_post_type($post_id); |
|
| 286 | + $post_type = get_post_type($post_id); |
|
| 287 | 287 | |
| 288 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 288 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 289 | 289 | |
| 290 | - if ($comment_id) {
|
|
| 290 | + if ($comment_id) {
|
|
| 291 | 291 | |
| 292 | - $overall_rating = $old_rating; |
|
| 292 | + $overall_rating = $old_rating; |
|
| 293 | 293 | |
| 294 | - if (isset($old_rating)) {
|
|
| 294 | + if (isset($old_rating)) {
|
|
| 295 | 295 | |
| 296 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 296 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 297 | 297 | overall_rating = %f, |
| 298 | 298 | status = %s, |
| 299 | 299 | comment_content = %s |
| 300 | 300 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
| 301 | 301 | |
| 302 | - $wpdb->query($sqlqry); |
|
| 302 | + $wpdb->query($sqlqry); |
|
| 303 | 303 | |
| 304 | - //update rating |
|
| 305 | - geodir_update_postrating($post_id, $post_type); |
|
| 304 | + //update rating |
|
| 305 | + geodir_update_postrating($post_id, $post_type); |
|
| 306 | 306 | |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - } |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | 311 | } |
| 312 | 312 | |
@@ -325,41 +325,41 @@ discard block |
||
| 325 | 325 | function geodir_update_rating($comment_id = 0) |
| 326 | 326 | {
|
| 327 | 327 | |
| 328 | - global $wpdb, $plugin_prefix, $user_ID; |
|
| 328 | + global $wpdb, $plugin_prefix, $user_ID; |
|
| 329 | 329 | |
| 330 | - $comment_info = get_comment($comment_id); |
|
| 330 | + $comment_info = get_comment($comment_id); |
|
| 331 | 331 | |
| 332 | - $post_id = $comment_info->comment_post_ID; |
|
| 333 | - $status = $comment_info->comment_approved; |
|
| 334 | - $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
| 332 | + $post_id = $comment_info->comment_post_ID; |
|
| 333 | + $status = $comment_info->comment_approved; |
|
| 334 | + $old_rating = geodir_get_commentoverall($comment_info->comment_ID); |
|
| 335 | 335 | |
| 336 | - $post_type = get_post_type($post_id); |
|
| 336 | + $post_type = get_post_type($post_id); |
|
| 337 | 337 | |
| 338 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 338 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 339 | 339 | |
| 340 | - if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 340 | + if (isset($_REQUEST['geodir_overallrating'])) {
|
|
| 341 | 341 | |
| 342 | - $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 342 | + $overall_rating = $_REQUEST['geodir_overallrating']; |
|
| 343 | 343 | |
| 344 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 345 | - $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 344 | + if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 345 | + $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
|
| 346 | 346 | |
| 347 | - if (isset($old_rating)) {
|
|
| 347 | + if (isset($old_rating)) {
|
|
| 348 | 348 | |
| 349 | - $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 349 | + $sqlqry = $wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET
|
|
| 350 | 350 | overall_rating = %f, |
| 351 | 351 | status = %s, |
| 352 | 352 | comment_content = %s |
| 353 | 353 | WHERE comment_id = %d ", array($overall_rating, $status, $comment_info->comment_content, $comment_id)); |
| 354 | 354 | |
| 355 | - $wpdb->query($sqlqry); |
|
| 355 | + $wpdb->query($sqlqry); |
|
| 356 | 356 | |
| 357 | - //update rating |
|
| 358 | - geodir_update_postrating($post_id, $post_type); |
|
| 357 | + //update rating |
|
| 358 | + geodir_update_postrating($post_id, $post_type); |
|
| 359 | 359 | |
| 360 | - } |
|
| 361 | - } |
|
| 362 | - } |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | } |
@@ -375,19 +375,19 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function geodir_comment_delete_comment($comment_id) |
| 377 | 377 | {
|
| 378 | - global $wpdb; |
|
| 378 | + global $wpdb; |
|
| 379 | 379 | |
| 380 | - $review_info = geodir_get_review($comment_id); |
|
| 381 | - if ($review_info) {
|
|
| 382 | - geodir_update_postrating($review_info->post_id); |
|
| 383 | - } |
|
| 380 | + $review_info = geodir_get_review($comment_id); |
|
| 381 | + if ($review_info) {
|
|
| 382 | + geodir_update_postrating($review_info->post_id); |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - $wpdb->query( |
|
| 386 | - $wpdb->prepare( |
|
| 387 | - "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
| 388 | - array($comment_id) |
|
| 389 | - ) |
|
| 390 | - ); |
|
| 385 | + $wpdb->query( |
|
| 386 | + $wpdb->prepare( |
|
| 387 | + "DELETE FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d", |
|
| 388 | + array($comment_id) |
|
| 389 | + ) |
|
| 390 | + ); |
|
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
@@ -403,21 +403,21 @@ discard block |
||
| 403 | 403 | * @return string The comment content. |
| 404 | 404 | */ |
| 405 | 405 | function geodir_wrap_comment_text($content, $comment = '') {
|
| 406 | - if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
|
|
| 407 | - if (!is_admin()) {
|
|
| 408 | - return '<div class="description">' . $content . '</div>'; |
|
| 409 | - } else {
|
|
| 410 | - return $content; |
|
| 411 | - } |
|
| 412 | - } else {
|
|
| 413 | - $rating = 0; |
|
| 414 | - if (!empty($comment)) |
|
| 415 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 416 | - if ($rating != 0 && !is_admin()) {
|
|
| 417 | - return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
|
|
| 418 | - } else |
|
| 419 | - return $content; |
|
| 420 | - } |
|
| 406 | + if (!empty($comment->comment_post_ID) && geodir_cpt_has_rating_disabled((int)$comment->comment_post_ID)) {
|
|
| 407 | + if (!is_admin()) {
|
|
| 408 | + return '<div class="description">' . $content . '</div>'; |
|
| 409 | + } else {
|
|
| 410 | + return $content; |
|
| 411 | + } |
|
| 412 | + } else {
|
|
| 413 | + $rating = 0; |
|
| 414 | + if (!empty($comment)) |
|
| 415 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 416 | + if ($rating != 0 && !is_admin()) {
|
|
| 417 | + return '<div><div class="gd-rating-text">' . __('Overall Rating', 'geodirectory') . ': <div class="rating">' . $rating . '</div></div>' . geodir_get_rating_stars($rating, $comment->comment_ID) . '</div><div class="description">' . $content . '</div>';
|
|
| 418 | + } else |
|
| 419 | + return $content; |
|
| 420 | + } |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | |
@@ -434,41 +434,41 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | function geodir_update_postrating($post_id = 0, $post_type = '', $delete = false) |
| 436 | 436 | {
|
| 437 | - global $wpdb, $plugin_prefix, $comment; |
|
| 438 | - if (!$post_type) {
|
|
| 439 | - $post_type = get_post_type($post_id); |
|
| 440 | - } |
|
| 441 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 442 | - $post_newrating = geodir_get_post_rating($post_id, 1); |
|
| 443 | - $post_newrating_count = geodir_get_review_count_total($post_id); |
|
| 437 | + global $wpdb, $plugin_prefix, $comment; |
|
| 438 | + if (!$post_type) {
|
|
| 439 | + $post_type = get_post_type($post_id); |
|
| 440 | + } |
|
| 441 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 442 | + $post_newrating = geodir_get_post_rating($post_id, 1); |
|
| 443 | + $post_newrating_count = geodir_get_review_count_total($post_id); |
|
| 444 | 444 | |
| 445 | 445 | |
| 446 | - //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
| 446 | + //$post_newrating = ( (float)$post_oldrating - (float)$old_rating ) + (float)$overall_rating ; |
|
| 447 | 447 | |
| 448 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 448 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 449 | 449 | |
| 450 | - $wpdb->query( |
|
| 451 | - $wpdb->prepare( |
|
| 452 | - "UPDATE " . $detail_table . " SET |
|
| 450 | + $wpdb->query( |
|
| 451 | + $wpdb->prepare( |
|
| 452 | + "UPDATE " . $detail_table . " SET |
|
| 453 | 453 | overall_rating = %f, |
| 454 | 454 | rating_count = %f |
| 455 | 455 | where post_id = %d", |
| 456 | - array($post_newrating, $post_newrating_count, $post_id) |
|
| 457 | - ) |
|
| 458 | - ); |
|
| 459 | - |
|
| 460 | - update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
| 461 | - update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
| 462 | - } |
|
| 463 | - /** |
|
| 464 | - * Called after Updating post overall rating and rating count. |
|
| 465 | - * |
|
| 466 | - * @since 1.0.0 |
|
| 467 | - * @since 1.4.3 Added `$post_id` param. |
|
| 468 | - * @package GeoDirectory |
|
| 469 | - * @param int $post_id The post ID. |
|
| 470 | - */ |
|
| 471 | - do_action('geodir_update_postrating',$post_id);
|
|
| 456 | + array($post_newrating, $post_newrating_count, $post_id) |
|
| 457 | + ) |
|
| 458 | + ); |
|
| 459 | + |
|
| 460 | + update_post_meta($post_id, 'overall_rating', $post_newrating); |
|
| 461 | + update_post_meta($post_id, 'rating_count', $post_newrating_count); |
|
| 462 | + } |
|
| 463 | + /** |
|
| 464 | + * Called after Updating post overall rating and rating count. |
|
| 465 | + * |
|
| 466 | + * @since 1.0.0 |
|
| 467 | + * @since 1.4.3 Added `$post_id` param. |
|
| 468 | + * @package GeoDirectory |
|
| 469 | + * @param int $post_id The post ID. |
|
| 470 | + */ |
|
| 471 | + do_action('geodir_update_postrating',$post_id);
|
|
| 472 | 472 | |
| 473 | 473 | } |
| 474 | 474 | |
@@ -486,29 +486,29 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | function geodir_get_postoverall($post_id = 0) |
| 488 | 488 | {
|
| 489 | - global $wpdb, $plugin_prefix; |
|
| 489 | + global $wpdb, $plugin_prefix; |
|
| 490 | 490 | |
| 491 | - $post_type = get_post_type($post_id); |
|
| 492 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 491 | + $post_type = get_post_type($post_id); |
|
| 492 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 493 | 493 | |
| 494 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 494 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $detail_table . "'") == $detail_table) {
|
|
| 495 | 495 | |
| 496 | - $post_ratings = $wpdb->get_var( |
|
| 497 | - $wpdb->prepare( |
|
| 498 | - "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
| 499 | - array($post_id) |
|
| 500 | - ) |
|
| 501 | - ); |
|
| 496 | + $post_ratings = $wpdb->get_var( |
|
| 497 | + $wpdb->prepare( |
|
| 498 | + "SELECT overall_rating FROM " . $detail_table . " WHERE post_id = %d", |
|
| 499 | + array($post_id) |
|
| 500 | + ) |
|
| 501 | + ); |
|
| 502 | 502 | |
| 503 | 503 | |
| 504 | - } else {
|
|
| 505 | - $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
| 506 | - } |
|
| 504 | + } else {
|
|
| 505 | + $post_ratings = get_post_meta($post_id, 'overall_rating'); |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - if ($post_ratings) |
|
| 509 | - return $post_ratings; |
|
| 510 | - else |
|
| 511 | - return false; |
|
| 508 | + if ($post_ratings) |
|
| 509 | + return $post_ratings; |
|
| 510 | + else |
|
| 511 | + return false; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | |
@@ -525,19 +525,19 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | function geodir_get_review($comment_id = 0) |
| 527 | 527 | {
|
| 528 | - global $wpdb; |
|
| 529 | - |
|
| 530 | - $reatings = $wpdb->get_row( |
|
| 531 | - $wpdb->prepare( |
|
| 532 | - "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 533 | - array($comment_id) |
|
| 534 | - ) |
|
| 535 | - ); |
|
| 536 | - |
|
| 537 | - if (!empty($reatings)) |
|
| 538 | - return $reatings; |
|
| 539 | - else |
|
| 540 | - return false; |
|
| 528 | + global $wpdb; |
|
| 529 | + |
|
| 530 | + $reatings = $wpdb->get_row( |
|
| 531 | + $wpdb->prepare( |
|
| 532 | + "SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 533 | + array($comment_id) |
|
| 534 | + ) |
|
| 535 | + ); |
|
| 536 | + |
|
| 537 | + if (!empty($reatings)) |
|
| 538 | + return $reatings; |
|
| 539 | + else |
|
| 540 | + return false; |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -553,19 +553,19 @@ discard block |
||
| 553 | 553 | */ |
| 554 | 554 | function geodir_get_review_total($post_id = 0) |
| 555 | 555 | {
|
| 556 | - global $wpdb; |
|
| 557 | - |
|
| 558 | - $results = $wpdb->get_var( |
|
| 559 | - $wpdb->prepare( |
|
| 560 | - "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 561 | - array($post_id) |
|
| 562 | - ) |
|
| 563 | - ); |
|
| 564 | - |
|
| 565 | - if (!empty($results)) |
|
| 566 | - return $results; |
|
| 567 | - else |
|
| 568 | - return false; |
|
| 556 | + global $wpdb; |
|
| 557 | + |
|
| 558 | + $results = $wpdb->get_var( |
|
| 559 | + $wpdb->prepare( |
|
| 560 | + "SELECT SUM(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 561 | + array($post_id) |
|
| 562 | + ) |
|
| 563 | + ); |
|
| 564 | + |
|
| 565 | + if (!empty($results)) |
|
| 566 | + return $results; |
|
| 567 | + else |
|
| 568 | + return false; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -581,18 +581,18 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | function geodir_get_review_count_by_user_id($user_id = 0) |
| 583 | 583 | {
|
| 584 | - global $wpdb; |
|
| 585 | - $results = $wpdb->get_var( |
|
| 586 | - $wpdb->prepare( |
|
| 587 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 588 | - array($user_id) |
|
| 589 | - ) |
|
| 590 | - ); |
|
| 591 | - |
|
| 592 | - if (!empty($results)) |
|
| 593 | - return $results; |
|
| 594 | - else |
|
| 595 | - return false; |
|
| 584 | + global $wpdb; |
|
| 585 | + $results = $wpdb->get_var( |
|
| 586 | + $wpdb->prepare( |
|
| 587 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE user_id = %d AND status=1 AND overall_rating>0", |
|
| 588 | + array($user_id) |
|
| 589 | + ) |
|
| 590 | + ); |
|
| 591 | + |
|
| 592 | + if (!empty($results)) |
|
| 593 | + return $results; |
|
| 594 | + else |
|
| 595 | + return false; |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -610,27 +610,27 @@ discard block |
||
| 610 | 610 | */ |
| 611 | 611 | function geodir_get_post_rating($post_id = 0, $force_query = 0) |
| 612 | 612 | {
|
| 613 | - global $wpdb, $post; |
|
| 614 | - |
|
| 615 | - if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
|
|
| 616 | - if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
|
|
| 617 | - return $post->overall_rating; |
|
| 618 | - } else {
|
|
| 619 | - return 0; |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - $results = $wpdb->get_var( |
|
| 624 | - $wpdb->prepare( |
|
| 625 | - "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 626 | - array($post_id) |
|
| 627 | - ) |
|
| 628 | - ); |
|
| 629 | - |
|
| 630 | - if (!empty($results)) |
|
| 631 | - return $results; |
|
| 632 | - else |
|
| 633 | - return false; |
|
| 613 | + global $wpdb, $post; |
|
| 614 | + |
|
| 615 | + if (isset($post->ID) && $post->ID == $post_id && !$force_query) {
|
|
| 616 | + if (isset($post->rating_count) && $post->rating_count > 0 && isset($post->overall_rating) && $post->overall_rating > 0) {
|
|
| 617 | + return $post->overall_rating; |
|
| 618 | + } else {
|
|
| 619 | + return 0; |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + $results = $wpdb->get_var( |
|
| 624 | + $wpdb->prepare( |
|
| 625 | + "SELECT COALESCE(avg(overall_rating),0) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 626 | + array($post_id) |
|
| 627 | + ) |
|
| 628 | + ); |
|
| 629 | + |
|
| 630 | + if (!empty($results)) |
|
| 631 | + return $results; |
|
| 632 | + else |
|
| 633 | + return false; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -646,19 +646,19 @@ discard block |
||
| 646 | 646 | */ |
| 647 | 647 | function geodir_get_review_count_total($post_id = 0) |
| 648 | 648 | {
|
| 649 | - global $wpdb; |
|
| 650 | - |
|
| 651 | - $results = $wpdb->get_var( |
|
| 652 | - $wpdb->prepare( |
|
| 653 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 654 | - array($post_id) |
|
| 655 | - ) |
|
| 656 | - ); |
|
| 657 | - |
|
| 658 | - if (!empty($results)) |
|
| 659 | - return $results; |
|
| 660 | - else |
|
| 661 | - return false; |
|
| 649 | + global $wpdb; |
|
| 650 | + |
|
| 651 | + $results = $wpdb->get_var( |
|
| 652 | + $wpdb->prepare( |
|
| 653 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 654 | + array($post_id) |
|
| 655 | + ) |
|
| 656 | + ); |
|
| 657 | + |
|
| 658 | + if (!empty($results)) |
|
| 659 | + return $results; |
|
| 660 | + else |
|
| 661 | + return false; |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -675,20 +675,20 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | function geodir_get_comments_number($post_id = 0) |
| 677 | 677 | {
|
| 678 | - global $wpdb; |
|
| 678 | + global $wpdb; |
|
| 679 | 679 | |
| 680 | - $results = $wpdb->get_var( |
|
| 681 | - $wpdb->prepare( |
|
| 682 | - "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 683 | - array($post_id) |
|
| 684 | - ) |
|
| 685 | - ); |
|
| 680 | + $results = $wpdb->get_var( |
|
| 681 | + $wpdb->prepare( |
|
| 682 | + "SELECT COUNT(overall_rating) FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id = %d AND status=1 AND overall_rating>0", |
|
| 683 | + array($post_id) |
|
| 684 | + ) |
|
| 685 | + ); |
|
| 686 | 686 | |
| 687 | 687 | |
| 688 | - if (!empty($results)) |
|
| 689 | - return $results; |
|
| 690 | - else |
|
| 691 | - return false; |
|
| 688 | + if (!empty($results)) |
|
| 689 | + return $results; |
|
| 690 | + else |
|
| 691 | + return false; |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | /** |
@@ -704,19 +704,19 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | function geodir_get_commentoverall($comment_id = 0) |
| 706 | 706 | {
|
| 707 | - global $wpdb; |
|
| 708 | - |
|
| 709 | - $reatings = $wpdb->get_var( |
|
| 710 | - $wpdb->prepare( |
|
| 711 | - "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 712 | - array($comment_id) |
|
| 713 | - ) |
|
| 714 | - ); |
|
| 715 | - |
|
| 716 | - if ($reatings) |
|
| 717 | - return $reatings; |
|
| 718 | - else |
|
| 719 | - return false; |
|
| 707 | + global $wpdb; |
|
| 708 | + |
|
| 709 | + $reatings = $wpdb->get_var( |
|
| 710 | + $wpdb->prepare( |
|
| 711 | + "SELECT overall_rating FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id = %d", |
|
| 712 | + array($comment_id) |
|
| 713 | + ) |
|
| 714 | + ); |
|
| 715 | + |
|
| 716 | + if ($reatings) |
|
| 717 | + return $reatings; |
|
| 718 | + else |
|
| 719 | + return false; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | */ |
| 731 | 731 | function geodir_get_commentoverall_number($post_id = 0) |
| 732 | 732 | {
|
| 733 | - return geodir_get_post_rating($post_id); |
|
| 733 | + return geodir_get_post_rating($post_id); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | |
@@ -748,102 +748,102 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | function geodir_comment_template($comment_template) |
| 750 | 750 | {
|
| 751 | - global $post; |
|
| 751 | + global $post; |
|
| 752 | 752 | |
| 753 | - $post_types = geodir_get_posttypes(); |
|
| 753 | + $post_types = geodir_get_posttypes(); |
|
| 754 | 754 | |
| 755 | - if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
|
|
| 756 | - return; |
|
| 757 | - } |
|
| 758 | - if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
|
|
| 759 | - if (geodir_cpt_has_rating_disabled($post->post_type)) {
|
|
| 760 | - return $comment_template; |
|
| 761 | - } |
|
| 755 | + if (!(is_singular() && (have_comments() || (isset($post->comment_status) && 'open' == $post->comment_status)))) {
|
|
| 756 | + return; |
|
| 757 | + } |
|
| 758 | + if (in_array($post->post_type, $post_types)) { // assuming there is a post type called business
|
|
| 759 | + if (geodir_cpt_has_rating_disabled($post->post_type)) {
|
|
| 760 | + return $comment_template; |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
|
|
| 764 | - if (!$template) {
|
|
| 765 | - $template = dirname(__FILE__) . '/reviews.php'; |
|
| 766 | - } |
|
| 767 | - return $template; |
|
| 768 | - } |
|
| 763 | + $template = locate_template(array("geodirectory/reviews.php")); // Use theme template if available
|
|
| 764 | + if (!$template) {
|
|
| 765 | + $template = dirname(__FILE__) . '/reviews.php'; |
|
| 766 | + } |
|
| 767 | + return $template; |
|
| 768 | + } |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | add_filter("comments_template", "geodir_comment_template");
|
| 772 | 772 | |
| 773 | 773 | |
| 774 | 774 | if (!function_exists('geodir_comment')) {
|
| 775 | - /** |
|
| 776 | - * Comment HTML markup. |
|
| 777 | - * |
|
| 778 | - * @since 1.0.0 |
|
| 779 | - * @package GeoDirectory |
|
| 780 | - * @global object $post The current post object. |
|
| 781 | - * @param object $comment The comment object. |
|
| 782 | - * @param string|array $args {
|
|
| 783 | - * Optional. Formatting options. |
|
| 784 | - * |
|
| 785 | - * @type object $walker Instance of a Walker class to list comments. Default null. |
|
| 786 | - * @type int $max_depth The maximum comments depth. Default empty. |
|
| 787 | - * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
| 788 | - * @type string $callback Callback function to use. Default null. |
|
| 789 | - * @type string $end-callback Callback function to use at the end. Default null. |
|
| 790 | - * @type string $type Type of comments to list. |
|
| 791 | - * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
| 792 | - * @type int $page Page ID to list comments for. Default empty. |
|
| 793 | - * @type int $per_page Number of comments to list per page. Default empty. |
|
| 794 | - * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
| 795 | - * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
| 796 | - * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
| 797 | - * @type string $format How to format the comments list. |
|
| 798 | - * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
| 799 | - * @type bool $short_ping Whether to output short pings. Default false. |
|
| 800 | - * @type bool $echo Whether to echo the output or return it. Default true. |
|
| 801 | - * } |
|
| 802 | - * @param int $depth Depth of comment. |
|
| 803 | - */ |
|
| 804 | - function geodir_comment($comment, $args, $depth) |
|
| 805 | - {
|
|
| 806 | - $GLOBALS['comment'] = $comment; |
|
| 807 | - switch ($comment->comment_type) : |
|
| 808 | - case 'pingback' : |
|
| 809 | - case 'trackback' : |
|
| 810 | - // Display trackbacks differently than normal comments. |
|
| 811 | - ?> |
|
| 775 | + /** |
|
| 776 | + * Comment HTML markup. |
|
| 777 | + * |
|
| 778 | + * @since 1.0.0 |
|
| 779 | + * @package GeoDirectory |
|
| 780 | + * @global object $post The current post object. |
|
| 781 | + * @param object $comment The comment object. |
|
| 782 | + * @param string|array $args {
|
|
| 783 | + * Optional. Formatting options. |
|
| 784 | + * |
|
| 785 | + * @type object $walker Instance of a Walker class to list comments. Default null. |
|
| 786 | + * @type int $max_depth The maximum comments depth. Default empty. |
|
| 787 | + * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'. |
|
| 788 | + * @type string $callback Callback function to use. Default null. |
|
| 789 | + * @type string $end-callback Callback function to use at the end. Default null. |
|
| 790 | + * @type string $type Type of comments to list. |
|
| 791 | + * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'. |
|
| 792 | + * @type int $page Page ID to list comments for. Default empty. |
|
| 793 | + * @type int $per_page Number of comments to list per page. Default empty. |
|
| 794 | + * @type int $avatar_size Height and width dimensions of the avatar size. Default 32. |
|
| 795 | + * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'. |
|
| 796 | + * @type bool $reverse_children Whether to reverse child comments in the list. Default null. |
|
| 797 | + * @type string $format How to format the comments list. |
|
| 798 | + * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'. |
|
| 799 | + * @type bool $short_ping Whether to output short pings. Default false. |
|
| 800 | + * @type bool $echo Whether to echo the output or return it. Default true. |
|
| 801 | + * } |
|
| 802 | + * @param int $depth Depth of comment. |
|
| 803 | + */ |
|
| 804 | + function geodir_comment($comment, $args, $depth) |
|
| 805 | + {
|
|
| 806 | + $GLOBALS['comment'] = $comment; |
|
| 807 | + switch ($comment->comment_type) : |
|
| 808 | + case 'pingback' : |
|
| 809 | + case 'trackback' : |
|
| 810 | + // Display trackbacks differently than normal comments. |
|
| 811 | + ?> |
|
| 812 | 812 | <li <?php comment_class('geodir-comment'); ?> id="comment-<?php comment_ID(); ?>">
|
| 813 | 813 | <p><?php _e('Pingback:', 'geodirectory'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('(Edit)', 'geodirectory'), '<span class="edit-link">', '</span>'); ?></p>
|
| 814 | 814 | <?php |
| 815 | - break; |
|
| 816 | - default : |
|
| 817 | - // Proceed with normal comments. |
|
| 818 | - global $post; |
|
| 819 | - ?> |
|
| 815 | + break; |
|
| 816 | + default : |
|
| 817 | + // Proceed with normal comments. |
|
| 818 | + global $post; |
|
| 819 | + ?> |
|
| 820 | 820 | <li <?php comment_class('geodir-comment'); ?> id="li-comment-<?php comment_ID(); ?>">
|
| 821 | 821 | <article id="comment-<?php comment_ID(); ?>" class="comment"> |
| 822 | 822 | <header class="comment-meta comment-author vcard"> |
| 823 | 823 | <?php |
| 824 | - /** |
|
| 825 | - * Filter to modify comment avatar size |
|
| 826 | - * |
|
| 827 | - * You can use this filter to change comment avatar size. |
|
| 828 | - * |
|
| 829 | - * @since 1.0.0 |
|
| 830 | - * @package GeoDirectory |
|
| 831 | - */ |
|
| 832 | - $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
|
|
| 833 | - echo get_avatar($comment, $avatar_size); |
|
| 834 | - printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
|
|
| 835 | - get_comment_author_link(), |
|
| 836 | - // If current post author is also comment author, make it known visually. |
|
| 837 | - ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
|
|
| 838 | - ); |
|
| 839 | - echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
| 840 | - printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
|
|
| 841 | - esc_url(get_comment_link($comment->comment_ID)), |
|
| 842 | - get_comment_time('c'),
|
|
| 843 | - /* translators: 1: date, 2: time */ |
|
| 844 | - sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
|
|
| 845 | - ); |
|
| 846 | - ?> |
|
| 824 | + /** |
|
| 825 | + * Filter to modify comment avatar size |
|
| 826 | + * |
|
| 827 | + * You can use this filter to change comment avatar size. |
|
| 828 | + * |
|
| 829 | + * @since 1.0.0 |
|
| 830 | + * @package GeoDirectory |
|
| 831 | + */ |
|
| 832 | + $avatar_size = apply_filters('geodir_comment_avatar_size', 44);
|
|
| 833 | + echo get_avatar($comment, $avatar_size); |
|
| 834 | + printf('<cite><b class="reviewer">%1$s</b> %2$s</cite>',
|
|
| 835 | + get_comment_author_link(), |
|
| 836 | + // If current post author is also comment author, make it known visually. |
|
| 837 | + ($comment->user_id === $post->post_author) ? '<span>' . __('Post author', 'geodirectory') . '</span>' : ''
|
|
| 838 | + ); |
|
| 839 | + echo "<span class='item'><small><span class='fn'>$post->post_title</span></small></span>"; |
|
| 840 | + printf('<a href="%1$s"><time datetime="%2$s" class="dtreviewed">%3$s<span class="value-title" title="%2$s"></span></time></a>',
|
|
| 841 | + esc_url(get_comment_link($comment->comment_ID)), |
|
| 842 | + get_comment_time('c'),
|
|
| 843 | + /* translators: 1: date, 2: time */ |
|
| 844 | + sprintf(__('%1$s at %2$s', 'geodirectory'), get_comment_date(), get_comment_time())
|
|
| 845 | + ); |
|
| 846 | + ?> |
|
| 847 | 847 | </header> |
| 848 | 848 | <!-- .comment-meta --> |
| 849 | 849 | |
@@ -867,47 +867,47 @@ discard block |
||
| 867 | 867 | </article> |
| 868 | 868 | <!-- #comment-## --> |
| 869 | 869 | <?php |
| 870 | - break; |
|
| 871 | - endswitch; // end comment_type check |
|
| 872 | - } |
|
| 870 | + break; |
|
| 871 | + endswitch; // end comment_type check |
|
| 872 | + } |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | |
| 876 | 876 | add_filter('get_comments_number', 'geodir_fix_comment_count', 10, 2);
|
| 877 | 877 | if (!function_exists('geodir_fix_comment_count')) {
|
| 878 | - /** |
|
| 879 | - * Fix comment count by not listing replies as reviews |
|
| 880 | - * |
|
| 881 | - * @since 1.0.0 |
|
| 882 | - * @package GeoDirectory |
|
| 883 | - * @global object $post The current post object. |
|
| 884 | - * @param int $count The comment count. |
|
| 885 | - * @param int $post_id The post ID. |
|
| 886 | - * @todo $post is unreachable since the function return the count before that variable. |
|
| 887 | - * @return bool|null|string The comment count. |
|
| 888 | - */ |
|
| 889 | - function geodir_fix_comment_count($count, $post_id) |
|
| 890 | - {
|
|
| 891 | - if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
|
|
| 892 | - global $post; |
|
| 893 | - $post_types = geodir_get_posttypes(); |
|
| 894 | - |
|
| 895 | - if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 896 | - $review_count = geodir_get_review_count_total($post_id); |
|
| 897 | - return $review_count; |
|
| 898 | - |
|
| 899 | - if ($post && isset($post->rating_count)) {
|
|
| 900 | - return $post->rating_count; |
|
| 901 | - } else {
|
|
| 902 | - return geodir_get_comments_number($post_id); |
|
| 903 | - } |
|
| 904 | - } else {
|
|
| 905 | - return $count; |
|
| 906 | - } |
|
| 907 | - } else {
|
|
| 908 | - return $count; |
|
| 909 | - } |
|
| 910 | - } |
|
| 878 | + /** |
|
| 879 | + * Fix comment count by not listing replies as reviews |
|
| 880 | + * |
|
| 881 | + * @since 1.0.0 |
|
| 882 | + * @package GeoDirectory |
|
| 883 | + * @global object $post The current post object. |
|
| 884 | + * @param int $count The comment count. |
|
| 885 | + * @param int $post_id The post ID. |
|
| 886 | + * @todo $post is unreachable since the function return the count before that variable. |
|
| 887 | + * @return bool|null|string The comment count. |
|
| 888 | + */ |
|
| 889 | + function geodir_fix_comment_count($count, $post_id) |
|
| 890 | + {
|
|
| 891 | + if (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) {
|
|
| 892 | + global $post; |
|
| 893 | + $post_types = geodir_get_posttypes(); |
|
| 894 | + |
|
| 895 | + if (in_array(get_post_type($post_id), $post_types) && !geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 896 | + $review_count = geodir_get_review_count_total($post_id); |
|
| 897 | + return $review_count; |
|
| 898 | + |
|
| 899 | + if ($post && isset($post->rating_count)) {
|
|
| 900 | + return $post->rating_count; |
|
| 901 | + } else {
|
|
| 902 | + return geodir_get_comments_number($post_id); |
|
| 903 | + } |
|
| 904 | + } else {
|
|
| 905 | + return $count; |
|
| 906 | + } |
|
| 907 | + } else {
|
|
| 908 | + return $count; |
|
| 909 | + } |
|
| 910 | + } |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -925,14 +925,14 @@ discard block |
||
| 925 | 925 | */ |
| 926 | 926 | function geodir_get_rating_stars($rating, $post_id, $small = false) |
| 927 | 927 | {
|
| 928 | - if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 929 | - return NULL; |
|
| 930 | - } |
|
| 931 | - $a_rating = $rating / 5 * 100; |
|
| 932 | - |
|
| 933 | - if ($small) {
|
|
| 934 | - $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 935 | - } else {
|
|
| 928 | + if (!empty($post_id) && geodir_cpt_has_rating_disabled((int)$post_id)) {
|
|
| 929 | + return NULL; |
|
| 930 | + } |
|
| 931 | + $a_rating = $rating / 5 * 100; |
|
| 932 | + |
|
| 933 | + if ($small) {
|
|
| 934 | + $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
|
| 935 | + } else {
|
|
| 936 | 936 | if (function_exists('geodir_reviewrating_draw_overall_rating')) {
|
| 937 | 937 | // Show rating stars from review rating manager |
| 938 | 938 | $r_html = geodir_reviewrating_draw_overall_rating($rating); |
@@ -949,8 +949,8 @@ discard block |
||
| 949 | 949 | } |
| 950 | 950 | $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
| 951 | 951 | } |
| 952 | - } |
|
| 953 | - return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
|
| 952 | + } |
|
| 953 | + return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | /** |
@@ -964,23 +964,23 @@ discard block |
||
| 964 | 964 | function geodir_is_reviews_show($pageview = '') |
| 965 | 965 | {
|
| 966 | 966 | |
| 967 | - $active_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 968 | - |
|
| 969 | - $is_display = true; |
|
| 970 | - if (!empty($active_tabs) && in_array('reviews', $active_tabs))
|
|
| 971 | - $is_display = false; |
|
| 972 | - |
|
| 973 | - /** |
|
| 974 | - * Filter to change display value. |
|
| 975 | - * |
|
| 976 | - * You can use this filter to change the is_display value. |
|
| 977 | - * |
|
| 978 | - * @since 1.0.0 |
|
| 979 | - * @package GeoDirectory |
|
| 980 | - * @param bool $is_display Display ratings when set to true. |
|
| 981 | - * @param string $pageview The view template. Ex: listview, gridview etc. |
|
| 982 | - */ |
|
| 983 | - return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
|
|
| 967 | + $active_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 968 | + |
|
| 969 | + $is_display = true; |
|
| 970 | + if (!empty($active_tabs) && in_array('reviews', $active_tabs))
|
|
| 971 | + $is_display = false; |
|
| 972 | + |
|
| 973 | + /** |
|
| 974 | + * Filter to change display value. |
|
| 975 | + * |
|
| 976 | + * You can use this filter to change the is_display value. |
|
| 977 | + * |
|
| 978 | + * @since 1.0.0 |
|
| 979 | + * @package GeoDirectory |
|
| 980 | + * @param bool $is_display Display ratings when set to true. |
|
| 981 | + * @param string $pageview The view template. Ex: listview, gridview etc. |
|
| 982 | + */ |
|
| 983 | + return apply_filters('geodir_is_reviews_show', $is_display, $pageview);
|
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | |
@@ -988,9 +988,9 @@ discard block |
||
| 988 | 988 | * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types |
| 989 | 989 | */ |
| 990 | 990 | if(function_exists('dsq_can_replace')) {
|
| 991 | - remove_filter('comments_template', 'dsq_comments_template');
|
|
| 992 | - add_filter('comments_template', 'dsq_comments_template', 100);
|
|
| 993 | - add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 991 | + remove_filter('comments_template', 'dsq_comments_template');
|
|
| 992 | + add_filter('comments_template', 'dsq_comments_template', 100);
|
|
| 993 | + add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | |
@@ -1004,14 +1004,14 @@ discard block |
||
| 1004 | 1004 | * @return string `1` if active `0` if disabled. |
| 1005 | 1005 | */ |
| 1006 | 1006 | function geodir_option_disqus_active($disqus_active){
|
| 1007 | - global $post; |
|
| 1008 | - $all_postypes = geodir_get_posttypes(); |
|
| 1007 | + global $post; |
|
| 1008 | + $all_postypes = geodir_get_posttypes(); |
|
| 1009 | 1009 | |
| 1010 | - if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 1011 | - $disqus_active = '0'; |
|
| 1012 | - } |
|
| 1010 | + if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 1011 | + $disqus_active = '0'; |
|
| 1012 | + } |
|
| 1013 | 1013 | |
| 1014 | - return $disqus_active; |
|
| 1014 | + return $disqus_active; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | /** |
@@ -1025,22 +1025,22 @@ discard block |
||
| 1025 | 1025 | * @return array Modified tabs array. |
| 1026 | 1026 | */ |
| 1027 | 1027 | function geodir_detail_reviews_tab_title($tabs_arr) {
|
| 1028 | - $post_type = geodir_get_current_posttype(); |
|
| 1028 | + $post_type = geodir_get_current_posttype(); |
|
| 1029 | 1029 | |
| 1030 | - if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1031 | - $label_reviews = __('Comments', 'geodirectory');
|
|
| 1030 | + if (!empty($tabs_arr) && !empty($tabs_arr['reviews']) && isset($tabs_arr['reviews']['heading_text']) && $post_type != '' && geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1031 | + $label_reviews = __('Comments', 'geodirectory');
|
|
| 1032 | 1032 | |
| 1033 | - if (defined('GEODIR_CP_VERSION')) {
|
|
| 1034 | - $post_types = geodir_get_posttypes('array');
|
|
| 1033 | + if (defined('GEODIR_CP_VERSION')) {
|
|
| 1034 | + $post_types = geodir_get_posttypes('array');
|
|
| 1035 | 1035 | |
| 1036 | - if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
|
|
| 1037 | - $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory')); |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1036 | + if (!empty($post_types[$post_type]['labels']['label_reviews'])) {
|
|
| 1037 | + $label_reviews = stripslashes(__($post_types[$post_type]['labels']['label_reviews'], 'geodirectory')); |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | 1040 | |
| 1041 | - $tabs_arr['reviews']['heading_text'] = $label_reviews; |
|
| 1042 | - } |
|
| 1041 | + $tabs_arr['reviews']['heading_text'] = $label_reviews; |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | - return $tabs_arr; |
|
| 1044 | + return $tabs_arr; |
|
| 1045 | 1045 | } |
| 1046 | 1046 | add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_reviews_tab_title', 1000, 1); |
| 1047 | 1047 | \ No newline at end of file |