/** * save contact form settings * @param object $contact_form: current contact form instance; */ public function _hw_wpcf7_save_contact_form($contact_form) { $properties = $contact_form->get_properties(); $additional_settings = array(); //set additional_settings //$properties = array(); //enable private skin if (isset($_POST['hw_wpcf7_use_skin'])) { $properties['hw_wpcf7_use_skin'] = trim($_POST['hw_wpcf7_use_skin']); } else { $properties['hw_wpcf7_use_skin'] = 'off'; } //get selected skin if (isset($_POST['hw_wpcf7_skin'])) { //contact form skin $properties['hw_wpcf7_skin'] = trim($_POST['hw_wpcf7_skin']); } //skin setting if (isset($_POST['hw_wpcf7skin_setting'])) { $properties['hw_wpcf7skin_setting'] = $_POST['hw_wpcf7skin_setting']; } if (isset($_POST['hw_custom_css'])) { //custom css $properties['hw_custom_css'] = trim($_POST['hw_custom_css']); } /*form attributes*/ if (isset($_POST['hw_form_class_attr'])) { $properties['hw_form_class_attr'] = trim($_POST['hw_form_class_attr']); } //form class attr if (isset($_POST['hw_form_id_attr'])) { $properties['hw_form_id_attr'] = trim($_POST['hw_form_id_attr']); } //form id attr if (isset($_POST['hw_form_name_attr'])) { $properties['hw_form_name_attr'] = trim($_POST['hw_form_name_attr']); } //form name attr if (isset($_POST['hw_form_enctype_attr'])) { $properties['hw_form_enctype_attr'] = trim($_POST['hw_form_enctype_attr']); } //form enctype //save storage hook if (isset($_POST['hwcf_data_hook'])) { $properties['hwcf_data_hook'] = trim($_POST['hwcf_data_hook']); } /** * google form hook */ if (isset($_POST['hw_gformID'])) { //save google form ID $properties['hw_gformID'] = trim($_POST['hw_gformID']); } if (isset($_POST['enable_email_by_gapp'])) { //enable send mail through google form ID $properties['enable_email_by_gapp'] = trim($_POST['enable_email_by_gapp']); } else { $properties['enable_email_by_gapp'] = 'off'; } //enable default gform from hoangweb google acc if (isset($_POST['hw_default_gform'])) { $properties['hw_gformID'] = hw_wpcf7_default_gform(); unset($_POST['hw_default_gform']); //clear this option } //populate form event if (isset($_POST['hw_sent_ok_redirect_page'])) { $properties['hw_sent_ok_redirect_page'] = trim($_POST['hw_sent_ok_redirect_page']); } //on_sent_ok js event after form success sent data if (isset($_POST['hw_on_sent_ok_js_event'])) { $properties['hw_on_sent_ok_js_event'] = trim($_POST['hw_on_sent_ok_js_event']); $additional_settings[] = 'on_sent_ok: "' . esc_attr($properties['hw_on_sent_ok_js_event']) . '"'; } //on_submit js event after form submit whatever event send error if (isset($_POST['hw_on_submit_js_event'])) { $properties['hw_on_submit_js_event'] = trim($_POST['hw_on_submit_js_event']); $additional_settings[] = 'on_submit: "' . esc_attr($properties['hw_on_submit_js_event']) . '"'; } //web hook url if (isset($_POST['hook_url'])) { $properties['hook_url'] = trim($_POST['hook_url']); } //$current = WPCF7_ContactForm::get_current(); //__save_session('properties',$properties);__save_session('temp',$this->template->get_form_template($properties['hw_form_template'])); if (isset($_POST['hw_form_template']) && $_POST['hw_form_template'] !== $properties['hw_form_template'] && isset($properties['hw_form_template']) && $this->template->get_form_template(trim($_POST['hw_form_template']))) { //form template $properties['hw_form_template'] = trim($_POST['hw_form_template']); //save form template $new_fields = $this->template->parse_form_template_fields($properties['hw_form_template']); //update exists form to new selected template $properties['form'] = $new_fields; //update mail template $properties['mail'] = $this->template->mail_template($properties['hw_form_template']); } //update additional_settings to this form if (count($additional_settings)) { $properties['additional_settings'] = join("\n", $additional_settings); } $contact_form->set_properties($properties); //update cf settings #__save_session('_POST',$_POST); //save current skin for enqueue if (!empty($properties['hw_wpcf7_skin'])) { $this->skin->save_skin_assets(array('skin' => array('hash_skin' => $properties['hw_wpcf7_skin'], 'hwskin_condition' => $properties['hw_wpcf7skin_setting']['hwskin_condition'], 'theme_options' => $properties['hw_wpcf7skin_setting']['skin_options']), 'status' => $properties['hw_wpcf7_use_skin'] == 'off' ? 0 : 1, 'object' => 'hw-wpcf7')); } }