Extracting "label" value from custom field list "key" value

I created a custom field called “Location” which is a list of different building sites assigned to different events. I can see in the wp_options table that scheduled_php has all the list values I entered in column option_value. I also see that there is a “key” and “label” associated with each list value. Is there a function available that will extract extract the “label” value of a specific list “key”? In dhtmlxSchedulerConfigurator.php, the entire delimited list is parsed into an array but it’s not global. Is this my only option?

The next will work for scheduler 2.3 ( you need to wait week or two until release of updated plugin, or try to update js file from latest file )

In client side code you can use

scheduler.getLabel(“location”, ev.location);

first parameter - name of property
second - id, which need to be converted, to a label

As for server side code - it is problematic, info stored only in configuration and there is no any public helpers.

After modifying sidebar.php to include {LOCATION} and including ‘location’ in all query result sets, I attempted to use this code in the scheduler.php, function scheduler_sidebar but there is no such method “getLabel” in class scheduler. Is this method included in the WordPress version?

$event = str_replace("{*LOCATION*}", scheduler.getLabel("location", $events[$i]['location']), $event);

Above code will work only in templates of scheduler. ( client side code )
It will not work ( and there is no any other simple way ) to fetch such info in the sidebar widget.

Since there was no ‘server’ function for extracting option labels, I wrote the following code plus included a snapshot of the web page.
:arrow_right: A new sidebar widget was created called “Today’s Events”
:arrow_right: sidebar.php was modified to include {LOCATION} as a new replacement variable.
:arrow_right: scheduler.php was modified to include the location description in function scheduler_sidebar.

$event = str_replace("{*LOCATION*}"," (".$scheduler_cfg->get_label_value('location', $events[$i]['location']).") ", $event);

:arrow_right: dhtmlxSchedulerConfigurator.php already loads an array called “Settings” with all of the option keys/values so it was only logical to add a new function shown below.

public function get_label_value($config_option, $config_key) { if (isset($this->settings['optionsList_'.$config_option])) { $optlabel = explode(',', $this->settings['optionsList_'.$config_option]); for ($i = 0; $i < count($optlabel); $i++) { $optlabel_key = explode(':', $optlabel[$i]); if (strpos($optlabel_key[0], $config_key) !== false) { return trim($optlabel_key[1]); } } } else { return null; } }