Fix a temp issue between EDD Tickets 3.8 and EDD 2.1.9. Please place in your theme's functions.php file (or another suitable location) but be sure to remove the leading <?php tag as appropriate.
class Tribe_EDDTickets_Fix31092 { | |
/** | |
* Override EDDTickets' own print_ticket_url() callback. | |
*/ | |
public function __construct() { | |
add_filter( 'edd_download_file_url_args', array( $this, 'print_ticket_url' ), 20 ); | |
} | |
/** | |
* @param $item | |
* @return bool | |
*/ | |
protected function is_print_ticket_item( $item ) | |
{ | |
static $download_files = array(); | |
if ( empty($download_files) ) | |
$download_files = edd_get_download_files( $item['download_id'] ); | |
foreach ( $download_files as $index => $download ) { | |
if ( $item['file'] != $index ) continue; | |
if ( TribeEDDTickets::TICKET_DOWNLOAD === $download['file'] ) return true; | |
if ( TribeEDDTickets::LEGACY_TICKET_DOWNLOAD === $download['file'] ) return true; | |
} | |
return false; | |
} | |
/** | |
* Setup the print ticket URL so that a print view is rendered instead of a download file | |
* | |
* @param array $args | |
* | |
* @return array | |
*/ | |
public function print_ticket_url( $args = array() ) | |
{ | |
// Determine if this is a ticket product | |
if ( ! get_post_meta( $args['download_id'], TribeEDDTickets::$event_key, true ) ) { | |
return $args; | |
} | |
// Interfere only with the tickets link (thus allowing additional files to be downloaded | |
// as part of the purchase) | |
if ( ! $this->is_print_ticket_item( $args ) ) { | |
return $args; | |
} | |
$args = array( | |
'edd_action' => 'print_ticket', | |
'ticket' => $args['download_id'], | |
'download_key' => $args['download_key'] | |
); | |
return $args; | |
} | |
} | |
new Tribe_EDDTickets_Fix31092; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment