/**
  * Ajax handler for the vote action.
  */
 public function comment_vote_callback()
 {
     check_ajax_referer('hmn_vote_submit', 'hmn_vote_nonce');
     $comment_id = absint($_POST['comment_id']);
     $vote = $_POST['vote'];
     if (!in_array($vote, array('upvote', 'downvote'))) {
         $return = array('error_code' => 'invalid_action', 'error_message' => __('Invalid action', 'comment-popularity'), 'comment_id' => $comment_id);
         wp_send_json_error($return);
     }
     $result = $this->comment_vote($this->visitor->get_id(), $comment_id, $vote);
     if (array_key_exists('error_message', $result)) {
         wp_send_json_error($result);
     } else {
         wp_send_json_success($result);
     }
 }
Exemplo n.º 2
0
 /**
  * @param $visitor_id WP User ID.
  */
 public function __construct($visitor_id)
 {
     parent::__construct($visitor_id);
 }