function handleAdminPostRequests() { $out = array('success' => true); if ($_POST['object_create']) { if ($_POST['object_type'] == 'form') { if (parent::insertForm($_POST['object']) != false) { $this->action_complete = __('A new form was successfully created!', 'custom-contact-forms'); } } elseif ($_POST['object_type'] == 'field') { if (parent::insertField($_POST['object']) != false) { $this->action_complete = __('A new field was successful created!', 'custom-contact-forms'); } } elseif ($_POST['object_type'] == 'field_option') { if (parent::insertFieldOption($_POST['object']) != false) { $this->action_complete = __('A new field option was successful created!', 'custom-contact-forms'); } } elseif ($_POST['object_type'] == 'style') { if (parent::insertStyle($_POST['object']) != false) { $this->action_complete = __('A new style was successful created!', 'custom-contact-forms'); } } return $out; } if ($_POST['object_attach']) { if ($_POST['object_type'] == 'form') { if (parent::addFieldToForm($_POST['attach_object_id'], $_POST['object_id']) != false) { $this->action_complete = __('A field was successful attached!', 'custom-contact-forms'); } } elseif ($_POST['object_type'] == 'field') { if (parent::addFieldOptionToField($_POST['attach_object_id'], $_POST['object_id']) != false) { $this->action_complete = __('A field option was successful attached!', 'custom-contact-forms'); } } return $out; } if ($_POST['object_detach']) { if ($_POST['object_type'] == 'form') { if (parent::detachField($_POST['detach_object_id'], $_POST['object_id']) != false) { $this->action_complete = __('A field was successful detached!', 'custom-contact-forms'); } } elseif ($_POST['object_type'] == 'field') { if (parent::detachFieldOption($_POST['detach_object_id'], $_POST['object_id']) != false) { $this->action_complete = __('A field option was successful detached!', 'custom-contact-forms'); } } return $out; } if (isset($_POST['object_bulk_apply'])) { $out['object_bulk_action'] = $_POST['object_bulk_action']; if ($_POST['object_bulk_action'] == 'edit') { foreach ($_POST['objects'] as $obj) { if ($obj['object_do'] == 1) { if ($obj['object_type'] == 'form') { parent::updateForm($obj['values'], $obj['object_id']); if ($obj['detach_confirm'] == 1 && $obj['detach'] > 0) { parent::detachField($obj['detach'], $obj['object_id']); } if ($obj['attach_confirm'] == 1 && $obj['attach'] > 0) { parent::addFieldToForm($obj['attach'], $obj['object_id']); } } elseif ($obj['object_type'] == 'field') { parent::updateField($obj['values'], $obj['object_id']); if ($obj['detach_confirm'] == 1 && $obj['detach'] > 0) { parent::detachFieldOption($obj['detach'], $obj['object_id']); } if ($obj['attach_confirm'] == 1 && $obj['attach'] > 0) { parent::addFieldOptionToField($obj['attach'], $obj['object_id']); } } elseif ($obj['object_type'] == 'field_option') { parent::updateFieldOption($obj['values'], $obj['object_id']); } elseif ($obj['object_type'] == 'style') { parent::updateStyle($obj['values'], $obj['object_id']); } $out['objects'][] = $obj; } } $this->action_complete = __('Your bulk action has been completed!', 'custom-contact-forms'); } elseif ($_POST['object_bulk_action'] == 'delete') { foreach ($_POST['objects'] as $obj) { if ($obj['object_do'] == 1) { if ($obj['object_type'] == 'form') { parent::deleteForm($obj['object_id']); } elseif ($obj['object_type'] == 'field') { parent::deleteField($obj['object_id']); } elseif ($obj['object_type'] == 'field_option') { parent::deleteFieldOption($obj['object_id']); } elseif ($obj['object_type'] == 'style') { parent::deleteStyle($obj['object_id']); } elseif ($obj['object_type'] == 'form_submission') { parent::deleteUserData($obj['object_id']); } $out['objects'][] = $obj; } } $this->action_complete = __('Your bulk action has been completed!', 'custom-contact-forms'); } } return $out; }