function ajax_save() { $result = $this->vp_verify_nonce(); if ($result['status']) { $this->init_options_set(); $this->init_options(); $option = $_POST['option']; $nonce = $_POST['nonce']; $option = VP_Util_Array::unite($option, 'name', 'value'); $option = $this->get_options_set()->normalize_values($option); // stripslashes added by WP in $_GET / $_POST $option = stripslashes_deep($option); // get old options from set $old_opt = $this->get_options_set()->get_values(); $this->get_options_set()->populate_values($option, true); // get back options from set $opt = $this->get_options_set()->get_values(); // before ajax save action hook do_action('vp_option_before_ajax_save', $opt); // save and re-init options $result = $this->save_and_reinit(); // after ajax save action hook do_action('vp_option_after_ajax_save', $opt, $old_opt, $result['status'], $this->get_option_key()); // option key specific after ajax save action hook do_action('vp_option_after_ajax_save-' . $this->get_option_key(), $opt, $old_opt, $result['status']); } if (ob_get_length()) { ob_clean(); } header('Content-type: application/json'); echo json_encode($result); die; }
/** * Setter for $_default * * @param mixed $_default default value of the field */ public function set_default($_default) { if (is_array($_default) and !VP_Util_Reflection::is_multiselectable($this)) { $_default = VP_Util_Array::first($_default); } $this->_default = $_default; return $this; }