public function yop_poll_do_vote() { $error = ''; $success = ''; $message = ''; if (!isset($_POST) || empty($_POST)) { $error = __('Bad Request! Try later!', 'yop_poll'); print '[ajax-response]' . json_encode(array('error' => $error, 'success' => $success)) . '[/ajax-response]'; die; } if (is_admin()) { $poll_id = isset($_REQUEST['poll_id']) ? $_REQUEST['poll_id'] : null; $unique_id = isset($_REQUEST['unique_id']) ? $_REQUEST['unique_id'] : null; $location = isset($_REQUEST['location']) ? $_REQUEST['location'] : null; $unique_id = strip_tags(xss_clean($unique_id)); $location = strip_tags(xss_clean($location)); if ($poll_id) { require_once YOP_POLL_MODELS . 'poll_model.php'; $yop_poll_model = new YOP_POLL_Poll_Model($poll_id); $yop_poll_model->unique_id = $unique_id; $poll_html = $yop_poll_model->register_vote($_REQUEST); if ($poll_html) { $message = $poll_html; $success = $yop_poll_model->success; } else { $error = $yop_poll_model->error; } unset($yop_poll_model); } else { $error = __('Invalid Request! Try later!', 'yop_poll'); } } print '[ajax-response]' . json_encode(array('error' => $error, 'success' => $success, 'message' => $message)) . '[/ajax-response]'; die; }