<textarea class="hw_widopt_desc" name="<?php echo $this->get_field_name('hw_widopt_desc'); ?> " id="<?php echo $this->get_field_id('hw_widopt_desc'); ?> "></textarea> </p> <input type="hidden" class="hw_widopt_setting" name="<?php echo $this->get_field_name('hw_widopt_setting'); ?> " id="<?php echo $this->get_field_id('hw_widopt_setting'); ?> " value="<?php echo AWC_WidgetFeature_saveconfig::encode_config($saveconfig); ?> "/> <p> <input type="button" class="button" name="saveconfig_btn" value="<?php _e('Lưu'); ?> " onclick="hwawc_widfea_saveconfig(this,'#<?php echo $this->get_field_id('result'); ?> ')"/> <div id="<?php echo $this->get_field_id('result'); ?> "></div> </p>
/** * ajax callback */ public function _ajax_hwawc_widfea_saveconfig() { if (!wp_verify_nonce($_REQUEST['nonce'], "hwawc_widfea_saveconfig_nonce")) { exit("No naughty business please"); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { //$result = json_encode($result); $setting = isset($_POST['setting']) ? $_POST['setting'] : ''; if (!empty($setting)) { //remove setting from this widget feature $setting = AWC_WidgetFeature_saveconfig::decode_config($setting); $setting = $this->remove_settings($setting); //encode widget settings $setting = AWC_WidgetFeature_saveconfig::encode_config($setting); } $data = array('name' => isset($_POST['name']) ? $_POST['name'] : '', '_group' => isset($_POST['group']) ? $_POST['group'] : '', 'setting' => $setting, 'description' => isset($_POST['description']) ? $_POST['description'] : '', 'widget' => isset($_POST['widget']) ? $_POST['widget'] : ''); $insert_id = $this->add_widget_setting($data); echo $insert_id; //return new id inserted to database } else { header("Location: " . $_SERVER["HTTP_REFERER"]); } die; }