public static function import(array $import, $id = '', $is_conversion) { $import = apply_filters('ninja_forms_before_import_form', $import); /* * Create Form */ $form = Ninja_Forms()->form($id)->get(); $form->update_settings($import['settings']); $form->save(); $form_id = $form->get_id(); foreach ($import['fields'] as $settings) { if ($is_conversion) { $field_id = $settings['id']; $field = Ninja_Forms()->form($form_id)->field($field_id)->get(); } else { $field = Ninja_Forms()->form($form_id)->field()->get(); } $settings['parent_id'] = $form_id; $field->update_settings($settings)->save(); } foreach ($import['actions'] as $settings) { $action = Ninja_Forms()->form($form_id)->action()->get(); $action->update_settings($settings)->save(); } add_action('admin_notices', array('NF_Database_Models_Form', 'import_admin_notice')); self::$imported_form_id = $form_id; return $form_id; }
/** * Save Submission * * @return $this|NF_Database_Models_Submission|void */ public function save() { if (!$this->_id) { $sub = array('post_type' => 'nf_sub', 'post_status' => 'publish'); $this->_id = wp_insert_post($sub); // Log Error if (!$this->_id) { return; } } if (!$this->_seq_num && $this->_form_id) { $this->_seq_num = NF_Database_Models_Form::get_next_sub_seq($this->_form_id); } return $this->_save_field_values(); }
/** * Import Form * * A wrapper for the Form Model import method. * * @param $import */ public function import_form($import) { $import = maybe_unserialize($import); NF_Database_Models_Form::import($import); }
public static function process_bulk_action() { if (!isset($_GET['page']) || 'ninja-forms' != $_GET['page']) { return; } if (isset($_REQUEST['action']) && 'duplicate' === $_REQUEST['action']) { // In our file that handles the request, verify the nonce. $nonce = esc_attr($_REQUEST['_wpnonce']); if (!wp_verify_nonce($nonce, 'nf_duplicate_form')) { die(__('Go get a life, script kiddies', 'ninja-forms')); } else { NF_Database_Models_Form::duplicate(absint($_GET['id'])); } wp_redirect(admin_url('admin.php?page=ninja-forms')); exit; } if (isset($_REQUEST['action']) && 'delete' === $_REQUEST['action']) { // In our file that handles the request, verify the nonce. $nonce = esc_attr($_REQUEST['_wpnonce']); if (!wp_verify_nonce($nonce, 'nf_delete_form')) { die(__('Go get a life, script kiddies', 'ninja-forms')); } else { self::delete_item(absint($_GET['id'])); } wp_redirect(admin_url('admin.php?page=ninja-forms')); exit; } // If the delete bulk action is triggered if (isset($_POST['action']) && $_POST['action'] == 'bulk-delete' || isset($_POST['action2']) && $_POST['action2'] == 'bulk-delete') { // In our file that handles the request, verify the nonce. $nonce = esc_attr($_REQUEST['_wpnonce']); if (!wp_verify_nonce($nonce, 'bulk-forms')) { die(__('Go get a life, script kiddies', 'ninja-forms')); } if (isset($_POST['bulk-delete'])) { $delete_ids = esc_sql($_POST['bulk-delete']); // loop over the array of record IDs and delete them foreach ($delete_ids as $id) { self::delete_item(absint($id)); } } wp_redirect(admin_url('admin.php?page=ninja-forms')); exit; } }
/** * Import Form * * A wrapper for the Form Model import method. * * @param $import */ public function import_form($import, $id = FALSE, $is_conversion = FALSE) { $import = maybe_unserialize($import); NF_Database_Models_Form::import($import, $id, $is_conversion); }
/** * Import Form * * A wrapper for the Form Model import method. * * @param $import */ public function import_form($import, $id = FALSE, $is_conversion = FALSE) { if (!is_array($import)) { $data = json_decode(html_entity_decode($import), true); if (!is_array($data)) { $data = json_decode($import, true); } if (!is_array($data)) { $data = maybe_unserialize($import); if (!is_array($data)) { return false; } } $import = $data; } return NF_Database_Models_Form::import($import, $id, $is_conversion); }