/** * Get the value of a settings field * * @param string $option option field name * @return mixed */ function wpuf_get_option($option) { $fields = wpuf_settings_fields(); $prepared_fields = array(); //prepare the array with the field as key //and set the section name on each field foreach ($fields as $section => $field) { foreach ($field as $fld) { $prepared_fields[$fld['name']] = $fld; $prepared_fields[$fld['name']]['section'] = $section; } } //get the value of the section where the option exists $opt = get_option($prepared_fields[$option]['section']); $opt = is_array($opt) ? $opt : array(); //return the value if found, otherwise default if (array_key_exists($option, $opt)) { return $opt[$option]; } else { $val = isset($prepared_fields[$option]['default']) ? $prepared_fields[$option]['default'] : ''; return $val; } }
/** * Returns all the settings fields * * @return array settings fields */ function get_settings_fields() { return wpuf_settings_fields(); }