/** * Save theme options * * @return void */ function save() { check_ajax_referer('save'); $_POST['data'] = stripslashes_deep($_POST['data']); parse_str($_POST['data'], $data); foreach (Constructent_Options::$fields as $id => $field) { $value = isset($data[$id]) ? $data[$id] : ''; // Allow to change value before saving to database $value = constructent_options_filter('set_value', $value, $field); set_theme_mod($id, $value); } do_action('constructent_options_save'); die; }
/** * Get field input * * @param array $field * @param mixed $value Field value * * @return string * @since 1.0.0 */ function field_input($field, $value = '') { if (!$value && isset($field['id'])) { $default = isset($field['default']) ? $field['default'] : false; $value = get_theme_mod($field['id'], $default); // Hook to change how to get value $value = constructent_options_filter('get_value', $value, $field); } // Get field HTML and allow theme to hook to change $html = $this->{$field['type']}($field, $value); $html = constructent_options_filter('html', $html, $field); $suffix = empty($field['suffix']) ? '' : $this->html->span('class=suffix', $field['suffix']); $desc = empty($field['input_desc']) ? '' : $this->html->div('class=desc', $field['input_desc']); return $this->html->div('class=input', $html, $suffix, $desc); }