/** * Create a new designnation * * @return void */ function designation_create() { $this->verify_nonce('erp-new-desig'); $title = isset($_POST['title']) ? trim(strip_tags($_POST['title'])) : ''; $desc = isset($_POST['desig-desc']) ? trim(strip_tags($_POST['desig-desc'])) : ''; $desig_id = isset($_POST['desig_id']) ? intval($_POST['desig_id']) : 0; $desig_id = erp_hr_create_designation(array('id' => $desig_id, 'title' => $title, 'description' => $desc)); if (is_wp_error($desig_id)) { $this->send_error($desig_id->get_error_message()); } $this->send_success(array('id' => $desig_id, 'title' => $title, 'employee' => 0)); }
public function setup_step_designation_save() { check_admin_referer('erp-setup'); $designations = array_map('sanitize_text_field', $_POST['designations']); if ($designations) { foreach ($designations as $designation) { if (!empty($designation)) { erp_hr_create_designation(['title' => $designation]); } } } wp_redirect(esc_url_raw($this->get_next_step_link())); exit; }