public function ajax_preview_add_edit() { if (is_admin()) { if (!check_ajax_referer('yop-poll-add-edit-action', 'yop-poll-add-edit-name', false)) { wp_die(__yop_poll('You are not allowed to access this request.')); } print Yop_Poll_Model::save_poll(true); } die; }
public function do_add_edit() { if ('add' == $_POST['action_type']) { if (!current_user_can('edit_own_yop_polls') && !current_user_can('edit_yop_polls')) { wp_die(__yop_poll('You are not allowed to edit this item.')); } } else { if ('edit' == $_POST['action_type']) { $poll_details = new YOP_POLL_Poll_Model($_POST['poll_id']); if ((!current_user_can('edit_own_yop_polls') || $poll_details->poll_author != $GLOBALS['current_user']->ID) && !current_user_can('edit_yop_polls')) { wp_die(__yop_poll('You are not allowed to edit this item.')); } } else { wp_die(__yop_poll('You are not allowed to access this request.')); } } Yop_Poll_Model::save_poll(); }