function rcl_delete_rating_user_review($review) { global $rcl_options, $rcl_rating_types; if ($rcl_options['rating_user_rcl-review'] == 1) { $args = array('user_id' => $review->author_id, 'object_id' => $review->ID, 'object_author' => $review->user_id, 'rating_type' => 'rcl-review'); rcl_delete_rating($args); } }
function rcl_edit_rating_post() { global $rcl_options, $rcl_rating_types; $args = rcl_decode_data_rating(sanitize_text_field($_POST['rating'])); if ($rcl_options['rating_' . $args['rating_status'] . '_limit_' . $args['rating_type']]) { $timelimit = $rcl_options['rating_' . $args['rating_status'] . '_time_' . $args['rating_type']] ? $rcl_options['rating_' . $args['rating_status'] . '_time_' . $args['rating_type']] : 3600; $votes = rcl_count_votes_time($args, $timelimit); if ($votes >= $rcl_options['rating_' . $args['rating_status'] . '_limit_' . $args['rating_type']]) { $log['error'] = sprintf(__('exceeded the limit of votes for the period - %d seconds', 'wp-recall'), $timelimit); echo json_encode($log); exit; } } $value = rcl_get_vote_value($args); if ($value) { if ($args['rating_status'] == 'cancel') { $rating = rcl_delete_rating($args); } else { $log['result'] = 110; echo json_encode($log); exit; } } else { $args['rating_value'] = rcl_get_rating_value($args['rating_type']); $rating = rcl_insert_rating($args); } $total = rcl_get_total_rating($args['object_id'], $args['rating_type']); $log['result'] = 100; $log['object_id'] = $args['object_id']; $log['rating_type'] = $args['rating_type']; $log['rating'] = $total; echo json_encode($log); exit; }