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

Preset - want some ideas!

Open mharis opened this issue 12 years ago • 7 comments

So, we have 5 type of header layouts in our theme, we have a primary color field in our theme options and it has to change with each type of header.

So for e.g, for header 1, we need primary color to be used for header background color field and for header 2, we want to use #fff for the header background color.

Now one way of doing this is to hook into it with javascript but I was wondering if there are some other ideas to achieve this so that I can use data from other fields for presets?

mharis avatar Feb 17 '14 10:02 mharis

hey @mharis there is already a feature builtin for this exact type of situation.

take a look at the demo config. inside there is a preset image select field.

This allows you "reset" any number of setting based on the image chosen, would work great for your multiple headers.

leemason avatar Feb 17 '14 11:02 leemason

Hi @leemason,

That is correct but I am looking for a way to set a field value equal to the value of another field.

For e.g, set header background color field = primary color field

mharis avatar Feb 17 '14 11:02 mharis

ahh ok, i get it. this may need to be a custom js solution i fear, at least in the short term.

Are you aware of how to enqueue custom js onto your panel page?

leemason avatar Feb 17 '14 11:02 leemason

Oh yes, looks like a custom solution, I will have to hook into the click event for the image_select and change the data-presets value. Maybe @dovy has another idea?

mharis avatar Feb 17 '14 11:02 mharis

do_action_ref_array( "redux/options/{$this->args['opt_name']}/import", array(&$plugin_options, $imported_options));

Made a new hook you can use. $plugin_options = $options. $imported_options = the preset values. ;)

Pushed.

dovy avatar Feb 17 '14 17:02 dovy

Example of how to use do_action_ref_array. There are 2 values. Make sure to add the 2 number.

http://codex.wordpress.org/Function_Reference/do_action_ref_array

dovy avatar Feb 17 '14 17:02 dovy

Pending: Push the selected preset to the hook

mharis avatar Feb 18 '14 20:02 mharis