Definitely looks like our bug. Let me take a look.
I stand corrected, it seems to work find. Here’s some example code:
Field:
array(
'id' => 'opt-select-callback',
'type' => 'select',
'data' => 'callback',
'args' => 'redux_demo_select_data_callback',
'title' => esc_html__( 'Custom callback with WordPress data', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'You can customize data using your own function here.', 'your-textdomain-here' ),
'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ),
),
Callback function
function redux_demo_select_data_callback() {
return array(
'here' => 'Here I am',
'rocking' => 'Rocking like a hurricane',
);
}
Seems to work fine for me. Here’s the docs outlining the same thing.
https://docs.redux.io/configuration/fields/data.html#using-a-custom-callback
Have a great day!
Thread Starter
sajjad
(@sajjad203)
WOW, Fast support 🙂
Thank you for the response but please check it again 🙂
In the first time there is no warning but when you select an option and save the settings and refresh the page, you can see it.
Ahh, those are details I needed! Then I’ll take a look.
This has been resolved in Redux 4.1.21. 🙂
Thread Starter
sajjad
(@sajjad203)
I updated redux to this version but i see the warnings yet 🙁
Can you try it with 4.1.22?
Thread Starter
sajjad
(@sajjad203)
I updated to 4.1.23 and it’s not resolved.
Also i reset all options and test it again but the warning appeared again.
Screen shot:
https://img.techpowerup.org/201025/opera-snapshot-2020-10-25-122127-localhost.png
So this worked for me and I think you might be experiencing a race condition. Make sure your function is defined around the same time as you define your options.
I added new code to support running a class method instead of just a function and that’s in the repo, but here’s the test code I used. It worked without an issue.
Redux::set_section(
$opt_name,
array(
'title' => esc_html__( 'Select', 'your-textdomain-here' ),
'id' => 'select-select-callback',
'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="//docs.redux.io/core/fields/select/" target="_blank">docs.redux.io/core/fields/select/</a>',
'subsection' => true,
'fields' => array(
array(
'id' => 'opt-select-elusive-callback',
'type' => 'select',
'data' => 'callback',
//'args'=> 'my_callback_function',
'args' => array('Foo', 'data'),
'title' => esc_html__( 'Select Callback', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ),
'desc' => esc_html__( 'Here\'s a list of all the elusive icons by name and icon.', 'your-textdomain-here' ),
)
),
)
);
class Foo {
function data() {
return array(
'here' => 'Here I am2',
'rocking' => 'Rocking like a hurricane2',
);
}
}
function my_callback_function() {
return array(
'here' => 'Here I am',
'rocking' => 'Rocking like a hurricane',
);
}
Best of luck!