Event_Meta::get_current_fields( WP_Post $event )
Get the saved or default values.
Contents
Parameters
- $event
-
(WP_Post) (Required) The event post object, as decorated by the
tribe_get_eventfunction.
Return
(TribeEventsVirtualMeetingsYouTubearray<string|TribeEventsVirtualMeetingsYouTubemixed>) The array of values for switch fields.
Source
File: src/Tribe/Meetings/YouTube/Event_Meta.php
public static function get_current_fields( \WP_Post $event ) {
/** @var \Tribe\Events\Virtual\Meetings\YouTube\Settings */
$settings = tribe( Settings::class );
$setting_defaults = $settings->get_fields( true );
$fields = [];
$use_defaults = false;
// Use defaults when YouTube is not the source.
if ( 'youtube' !== $event->virtual_video_source ) {
$use_defaults = true;
}
foreach ( $setting_defaults as $setting_id => $field ) {
// Remove the settings prefix to get matching fields.
$meta_id = str_replace( 'tribe_', '', $setting_id );
$name = "tribe-events-virtual[{$meta_id}]";
// Setup the field.
$fields[ $name ] = [
'label' => $field['label'],
'tooltip' => $field['tooltip'],
'value' => $use_defaults ? $field['value'] : self::get_meta_field( $meta_id, $event ),
];
}
/**
* Filters the YouTube fields values for an event.
*
* @since 1.6.0
*
* @param array<string,array> A map of the YouTube Live fields that will be used for an event.
* @param bool $use_defaults Whether the default values are being used.
*/
return apply_filters( 'tribe_events_virtual_meetings_youtube_settings_event_fields', $fields, $use_defaults );
}
Changelog
| Version | Description |
|---|---|
| 1.6.0 | Introduced. |