Tribe__Tickets__Tickets::get_active_providers_for_post( int $post_id, bool $return_instances = false )
Given a post ID, get the active providers used for RSVP(s)/ticket(s).
Contents
See also
Parameters
- $post_id
-
(int) (Required) The post ID of the post/event to which RSVP(s)/ticket(s) are attached.
- $return_instances
-
(bool) (Optional) Whether to return instances, otherwise it will return class name strings.
Default value: false
Return
(string[]|self[]) Instances or names of provider classes for RSVP(s)/ticket(s) attached to the post/event.
Source
File: src/Tribe/Tickets.php
public static function get_active_providers_for_post( $post_id, $return_instances = false ) {
$all_active_modules = array_keys( self::modules() );
$active_providers = [];
// Determine which providers have tickets for this event.
foreach ( $all_active_modules as $module ) {
$provider = self::get_ticket_provider_instance( $module );
// Skip this provider if the instance couldn't be set up.
if ( ! $provider ) {
continue;
}
// Get the tickets for this event on this provider, if any.
$tickets_orm = tribe_tickets( $provider->orm_provider );
$tickets_orm->by( 'event', $post_id );
if ( 0 < $tickets_orm->found() ) {
$provider_class = $provider->class_name;
// Check whether to return the provider class names.
if ( ! $return_instances ) {
$provider = $provider_class;
}
$active_providers[ $provider_class ] = $provider;
}
}
return $active_providers;
}
Changelog
| Version | Description |
|---|---|
| 5.1.1 | Introduced. |