*/ public static function options(): array { return VerticalRegistry::options(); } /** * @return string[] */ public static function types(): array { return array_keys(self::options()); } public static function normalize(string $type): string { $type = sanitize_key($type); return in_array($type, self::types(), true) ? $type : self::DEFAULT; } /** * @param string|null $type * @return array */ public static function labels(?string $type = null): array { $type = self::normalize((string) ($type ?: self::DEFAULT)); return (array) apply_filters( 'DayTidy/F__DayTidy/Data/OfferingTypes__labels/labels', VerticalRegistry::labels($type), $type ); } public static function label(?string $type, string $key): string { $labels = self::labels($type); return $labels[$key] ?? $labels['main'] ?? esc_html__('Offering', 'daytidy'); } /** * @return string[] */ public static function resourceManagedTypes(): array { return (array) apply_filters( 'DayTidy/F__DayTidy/Data/OfferingTypes__resourceManagedTypes/types', [ self::APPOINTMENT, self::SERVICE, self::DINING, ] ); } public static function resourceManagedTypesAttribute(): string { $types = []; foreach (self::resourceManagedTypes() as $type) { $type = sanitize_key((string) $type); if (in_array($type, self::types(), true)) $types[] = $type; } return implode(',', array_values(array_unique($types))); } public static function isResourceManaged(?string $type): bool { $resource_managed_types = array_filter(explode(',', self::resourceManagedTypesAttribute())); return in_array(self::normalize((string) $type), $resource_managed_types, true); } /** * @return array> */ public static function allLabels(): array { $labels = []; foreach (self::types() as $type) $labels[$type] = self::labels($type); return (array) apply_filters('DayTidy/F__DayTidy/Data/OfferingTypes__allLabels/labels', $labels); } }