change redux default values on child theme

23 views Asked by At

I have a Wordpress install with Redux Framework plugin v.4.4.10. Redux sections and options are set on a redux config file on parent theme.

I also use a child theme, and i would like this child theme sets new defaults for redux options field values. This default values should be set when "Reset All" button from redux panel is clicked.

I'm setting redux with sections and options in parent theme. Each option has a defined "default" value according to the redux sintax:

Redux::set_section( $opt_name, array(
    'title'  => esc_html__( 'Layout', 'text-domain' ),
    'id'     => 'global-layout',
    'fields' => array(
        array(
            'id'       => 'global-container',
            'type'     => 'select',
            'title'    => esc_html__( 'Container', 'text-domain' ),
            'subtitle' => esc_html__( 'Choose the container width', 'text-domain' ),
            'options'  => array(
                'container' => esc_html__( 'Boxed', 'text-domain' ),
                'container-fluid' => esc_html__( 'Full Width', 'text-domain' ),
            ),
            'default'  => 'container',
            ),
        )       
    )
);

The child theme should have defined different default values. According to Redux documentation, this can be done using Redux API: Updating an Option Manually

In addition, if I want the child theme redux default values get set after clicking on "Reset All" button of Redux theme options panel, I can use the redux hook redux/options/{opt_name}/reset as described in Redux Action Hooks

So, my final code in the functions.php file of my child theme will be:

function child_update_redux_option_manually() {
    $opt_name = 'redux_mytheme';
    Redux::set_option($opt_name, 'global-container', 'container-fluid');
}
add_action('redux/options/' . $opt_name . '/reset', 'child_update_redux_option_manually');

It is not working. After clicking on "Reset All" button, default values defined in redux config file of parent theme are setted instead of the one defined in the child theme function.

I really appreciate any kind of help on this topic. I couldn't find any updated solution for this on stackoverflow or redux github

0

There are 0 answers