Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elimn/f0e6b8ee3ee87df1ee1ee2937947619c to your computer and use it in GitHub Desktop.
Save elimn/f0e6b8ee3ee87df1ee1ee2937947619c to your computer and use it in GitHub Desktop.
MT | ETP | Ask users to enable JavaScript before checking out with ET+
<?php
/**
* Adds a notice to your ticket purchase forms asking users without JavaScript enabled to enable it
*/
class Tribe__Snippet__Attendee_Meta_Noscript {
protected $tickets_hook;
public function __construct() {
add_filter( 'tribe_tickets_commerce_tickets_form_hook', array( $this, 'get_hook' ), PHP_INT_MAX );
}
/**
* Dirty hack to get the return of a private method
*
* @see tribe_tickets_commerce_tickets_form_hook
*/
public function get_hook( $hook ) {
if ( $this->tickets_hook !== $hook ) {
$this->tickets_hook = $hook;
add_action( $hook, array( $this, 'output_noscript' ), 0 );
}
return $hook;
}
function output_noscript() {
$message = __( 'Please enable JavaScript to obtain tickets.' );
printf(
'<noscript><p class="tribe-link-tickets-message">%s</p></noscript>',
$message
);
}
}
new Tribe__Snippet__Attendee_Meta_Noscript();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment