Configurations not saving to DB
Fields are saving only as separate option (example here 'logo_default'), not into the configurated array option (example 'site_branding'). Don’t know if the configured option it is intended to get saved instead of or additionally to the option_name specified in the settings option.
Kirki::add_config( 'site_branding', array(
'option_type' => 'option',
'option_name' => 'site_branding',
) );
Kirki::add_field( 'site_branding', array(
'settings' => 'logo_default',
'label' => __('Default logo', 'my-theme'),
'section' => 'logo',
'type' => 'image',
'priority' => 10,
'default' => '',
) );
The $args passed in self::$fields[Kirki_Field::sanitize_settings( $args )] = $args; are: Array ( [settings] => logo_default [label] => Default logo' [section] => logo [type] => image [priority] => 10 [default] => [option] => [capability] => edit_theme_options [option_type] => option ) I went through all the process I think and couldn’t find the place where the $config['option_name'] is taken into account for saving it into a separate option. The probably best spot to do it is in the sanitize_settings method:
public static function sanitize_settings( $field ) {
// If the value of 'option_name' is not empty, then we're also using options instead of theme_mods.
if ( ( isset( $field['option_name'] ) ) && ! empty( $field['option_name'] ) ) {
$field['settings'] = esc_attr( $field['option_name'] ).'['.esc_attr( $field['settings'] ).']';
}
return $field['settings'];
}
Thanks for looking into it.
Hey there!
Can you please try pulling the latest changes from the master branch and test again?
This is a WIP, related to https://github.com/reduxframework/kirki/issues/263 as well
No news in this matter after me pulling latest changes. Problem must be elsewhere.
@boquiabierto can you please try pulling again and test if the latest commits fixed this one?
Looks like this has been fixed. I tried adding your code
Kirki::add_config( 'site_branding', array(
'option_type' => 'option',
'option_name' => 'site_branding',
) );
Kirki::add_field( 'site_branding', array(
'settings' => 'logo_default',
'label' => __('Default logo', 'my-theme'),
'section' => 'logo',
'type' => 'image',
'priority' => 10,
'default' => '',
) );
and the option was saved in the db properly (see screenshot below)

Can you please verify it now works for you as well?
Works! Thanks!