Skip to content

Instantly share code, notes, and snippets.

@Pebblo Pebblo/ReadMe.md Secret
Last active Apr 6, 2018

Embed
What would you like to do?
Adds the Ticket icon to the Espresso My Events output - http://take.ms/nrC38
<?php
/*
Plugin Name: Event Espresso site specific functions
Description: Add custom functions for Event Espresso to this plugin.
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
/*
function tw_add_ticket_link_to_my_events( $actions, $registration) {
if ( $registration instanceof EE_Registration ) {
if ( EEH_MSG_Template::is_mt_active( 'ticketing' ) && $registration->is_approved() ) {
//we need to get the correct template ID for the given event
$event = $registration->event();
//get the assigned ticket template for this event
$mtp = EEM_Message_Template_Group::instance()->get_one( array( array( 'Event.EVT_ID' => $event->ID(), 'MTP_message_type' => 'ticketing' ) ) );
//if no $mtp then that means an existing event that hasn't been saved yet with the templates for the global ticketing template. So let's just grab the global.
$mtp = $mtp instanceof EE_Message_Template_Group ? $mtp : EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_is_global' => 1, 'MTP_message_type' => 'ticketing' ) ) );
$query_args = array(
'ee' => 'msg_url_trigger',
'snd_msgr' => 'html',
'gen_msgr' => 'html',
'message_type' => 'ticketing',
'context' => 'registrant',
'token' => $registration->reg_url_link(),
'GRP_ID' => $mtp->ID(),
'id' => 0
);
$ticket_url = add_query_arg( $query_args, get_site_url() );
$actions['ticket'] = '<a aria-label="' . __( 'Link to view ticket', 'event_espresso' ) . '" href="' . $ticket_url . '">'
. '<span class="dashicons dashicons-tickets-alt ee-icon-size-18"></span></a>';
}
}
return $actions;
}
add_filter( 'FHEE__EES_Espresso_My_Events__actions', 'tw_add_ticket_link_to_my_events', 10, 2);
function tw_add_ticket_link_to_my_events_legend( $items ) {
$items['ticket'] = array(
'class' => 'dashicons dashicons-tickets-alt',
'desc' => esc_html__( 'View Ticket', 'event_espresso' )
);
return $items;
}
add_filter( 'FHEE__status-legend-espresso_my_events__legend_items', 'tw_add_ticket_link_to_my_events_legend');
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.