redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

How to get default values?

Open paulthecoder opened this issue 12 years ago • 7 comments

Hi this is not really an issue, I was just wondering if you can access the default values of lets say the typography field from the global variable $global_redux, or any other way.

array(
    'id'             => 'main_font',
    'type'           => 'typography',
    'color'          => false,
    'font-size'      => false,
    'font-style'     => false,
    'font-weight'    => false,
    'letter-spacing' => true,
    'line-height'    => false,
    'text-align'     => false,
    'subsets'        => false,
    'default'        => array(
        'font-family'    => 'Roboto Condensed',
        'google'         => true,
        'letter-spacing' => '0.5px',
        'font-size'      => '18px',
    ),
),

Something like this:

Redux->get_default('main_font','font-size');

or

$global_redux['main_font']['default']['font-size'];

paulthecoder avatar Jul 25 '14 21:07 paulthecoder

Not yet. It would be a REALLY easy function to implement. I'm low on time right now. Feel like submitting a pull request? We have a default_values array already.

dovy avatar Jul 25 '14 21:07 dovy

Maybe you could try something like this: http://docs.reduxframework.com/redux-framework/advanced/update-an-option-outside-the-options-panel/

Only instead of ReduxFramework->get, you'd do ReduxFramework->options_defaults

kprovance avatar Jul 25 '14 21:07 kprovance

Don't forget, you can use the $redux = ReduxFramework::get_instance('OPTNAME'); to get the active object.

So now just add a function, and you could even do:

$value = ReduxFramework::get_instance('OPTNAME')->get_default('KEY', 'ARRAY_KEY');

dovy avatar Jul 25 '14 22:07 dovy

Alright, thanks for steering me into the right direction. I'll submit a pull request later tonight, possibly tomorrow.

paulthecoder avatar Jul 25 '14 22:07 paulthecoder

;) Thanks for helping out.

dovy avatar Jul 25 '14 22:07 dovy

Is there a possible way now, to get the default values of options?

mstoic avatar Jun 02 '15 11:06 mstoic

Could anyone post a feedback on this? Has it been implemented already?

monecchi avatar Feb 13 '17 02:02 monecchi