How to get control choices from $setting object passed to sanitize_callback

This is correct:

$control = $setting->manager->get_control($setting->id);
$choices = $control->choices;

However, in your example, $setting->id will be theme_oenology_options[name].

So, get_control('theme_oenology_options[name]') will return null because there’s no control with that name. You gave the control the id of oenology_name instead.

I always give the same ID to settings and their matching controls for that reason.

Leave a Comment