The Events Calendar: Community Events Tickets: Display a "Payment options" button on the Community Events List View.
<?php
/**
* The Events Calendar: Community Events Tickets: Display a "Payment options"
* button on the Community Events List View.
*
* @see \Tribe__Events__Community__Tickets__Route__Payment_Options::url() We are basically recreating this.
*
* @link https://gist.github.com/cliffordp/31dc2cf0e1ac087f11988f16b426520e
* @link https://cl.ly/3p0x0o2I1x47 Screenshot
*
* @return array Multidimensional array that gets sent to Tribe__Events__Query::getEvents()
*/
function cliff_output_ce_tix_payment_options_button() {
if (
! class_exists( 'Tribe__Events__Community__Main' )
|| ! class_exists( 'Tribe__Events__Community__Tickets__Main' )
) {
return;
}
$community_tickets = Tribe__Events__Community__Tickets__Main::instance();
if ( ! $community_tickets->is_enabled() ) {
return;
}
if (
! $community_tickets->is_split_payments_enabled()
&& ! current_user_can( 'edit_event_tickets' )
) {
return;
}
$url = Tribe__Events__Community__Main::instance()->getUrl( 'payment-options' );
?>
<a href="<?php echo esc_url( $url ); ?>" class="tribe-community-tickets-payment-options-link button">Payment options</a>
<?php
}
add_action( 'tribe_community_events_after_list_navigation_buttons', 'cliff_output_ce_tix_payment_options_button' );