how can I access the redux global variable in the redux config.php?

561 Views Asked by At

I am using Redux framework for an wordpress theme. Problem is I want to access the redux global variable (default is ... global $redux_demo; ... ) in the Redux sample-config.php because I want to load up some settings based on a radio button. the $redux_demo variable always returns NULL in the sample-config.php; however, it returns the desired array in frontend(i.e., index.php).

Any help will be appreciated.

1

There are 1 best solutions below

0
On

This is because the config file, per its name, is for configuring your options panel. That data isn't parsed into the global variable until after the init hook is run.

To get the saved option in the config file before Redux has loaded, you'd simply use get_option and get the value off the returned array.

$redux = get_option('your_opt_name');
$option = $redux['option_key];

If there is no value, you should check for an empty value or that it's set and feed a default.