/** * Setup cache management and invalidation. */ public static function init() { /** * Controls the length of time in seconds for which meta value lists are * maintained before automatically being invalidated. * * @var int $cache_expiry */ self::$cache_expiry = (int) apply_filters('tribe_events_filterbar_additional_fields_cache_expiry', self::$cache_expiry); // We invalidate the entire cache any time an event is updated, created or deleted or when event add_action('save_post_' . Tribe__Events__Main::POSTTYPE, array(__CLASS__, 'cache_invalidate')); add_action('deleted_post', array(__CLASS__, 'cache_invalidate_on_event_deletion')); add_action('added_post_meta', array(__CLASS__, 'cache_invalidate_on_meta_change'), 10, 2); add_action('updated_post_meta', array(__CLASS__, 'cache_invalidate_on_meta_change'), 10, 2); add_action('deleted_post_meta', array(__CLASS__, 'cache_invalidate_on_meta_change'), 10, 2); }
/** * Return a list of possible values for this filter. This should be an array of arrays, * with each inner array structured as follows: * * [ 'name' => 'some_name' * 'value' => 'actual_value' ] * * @return array */ protected function get_values() { $values = Tribe__Events__Filterbar__Additional_Fields__Values::fetch($this->meta_key); // Filter out any empty/null values that have crept in $values = array_filter($values); // Convert each element into a name/value array as expected by the calling method foreach ($values as &$single_value) { $single_value = array('name' => $single_value, 'value' => $single_value); } /** * Dictate the values returned for the current additional field filter. * * @var array $values * @var string $meta_key */ return (array) apply_filters('tribe_events_filters_additional_field_values', $values, $this->meta_key); }