/**
  * When users hit the submit button this function handles the request and redirects them back to the page.
  **/
 public function save_settings()
 {
     if (!$this->form_manager->is_page()) {
         return;
     }
     $result = 0;
     if ($_GET['action'] == 'edit' && isset($_POST['update-form-settings']) && isset($_POST['form_settings']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'wpfepp-update-form-settings')) {
         $form_settings = $this->validator->validate($_POST['form_settings']);
         $result = $this->db->update_form_settings($_GET['form'], $form_settings);
         $sendback = esc_url_raw(add_query_arg(array('updated' => $result)));
         wp_redirect($sendback);
     }
 }
 /**
  * Main initialization function. Creates the database tables and initializes the options on first run.
  **/
 public function initialize()
 {
     // If this is not a new version, do nothing
     $old_version = get_option('wpfepp_version');
     if ($this->version == $old_version) {
         return;
     }
     // Update/Create the forms table
     $this->db->create_table();
     // Update plugin settings
     $this->plugin_settings->update_settings();
     //Update all the existing forms to include the new fields and settings
     $this->form_manager->upgrade_forms();
     // Change the database flag to reflect that all the changes of this version have been completed
     update_option('wpfepp_version', $this->version);
 }