Skip to content

Instantly share code, notes, and snippets.

@alanef
Created July 8, 2022 13:51
Show Gist options
  • Select an option

  • Save alanef/7cd706b746d45844f5e0e3d5da3adea2 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/7cd706b746d45844f5e0e3d5da3adea2 to your computer and use it in GitHub Desktop.
Not show button for private events
<?php
/**
* @var mixed $data Custom data for the template.
*/
if ( $data->utilities->get_element( 'booknow', $data->args ) ) {
// dont show button fpor private events
if( get_post()->public === false ) {
return;
}
switch ( $data->template ) {
case 'divi':
$button_markup = '<a class="submit et_pb_button %6$s" id="wfea-popup-booknow-%5$s" %1$s %3$s aria-label="%4$s">%2$s</a>';
break;
case 'enfold':
$button_markup = '<a class="button" %6$s" id="wfea-popup-booknow-%5$s" %1$s %3$s aria-label="%4$s">%2$s</a>';
break;
default:
$button_markup = '<a id="wfea-popup-booknow-%5$s" %1$s %3$s aria-label="%4$s" class="%6$s"><button>%2$s</button></a>';
}
?>
<div class="<?php echo esc_attr($data->event->layout_class); ?>__booknow booknow eaw-booknow <?php echo $data->event->popup; ?>">
<?php
printf( $button_markup,
$data->event->booknow,
$data->event->cta->text,
( $data->utilities->get_element( 'newtab', $data->args ) ) ? 'target="_blank"' : '',
( empty( $data->utilities->get_element( 'aria_label_booknow', $data->args ) ) ) ? $data->event->cta->text . ' ' . __( 'on Eventbrite for', 'widget-for-eventbrite-api' ) . ' ' . esc_attr( get_the_title() ) : $data->utilities->get_element( 'aria_label_booknow', $data->args ),
$data->unique_id . '-' . $data->events->post->ID,
$data->event->cta->class
);
?>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment