Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active February 18, 2021 13:24
Show Gist options
  • Select an option

  • Save alanef/75ad34c2609da4a5bbc5a189af6df1eb to your computer and use it in GitHub Desktop.

Select an option

Save alanef/75ad34c2609da4a5bbc5a189af6df1eb to your computer and use it in GitHub Desktop.
add_filter(
'wfea_availability_display', // filter hook name
function ( $msg, $total_sold, $event_capacity ) { // annonyous function that takes 3 parameters - paramters are defined by the hook
if ( $total_sold >= $event_capacity ) {
$msg = __( 'Sold Out', 'widget-for-eventbrite-api' );
} else if ( ( $event_capacity - $total_sold ) > 10 ) { // set this number to what you like if you don't want a count
$msg = 'Places Available';
} else {
$msg = sprintf( '%1$s Places Left', ( $event_capacity - $total_sold ) );
}
return $msg; // the result return to the filter
},
10, // the priority, so if multiple filters are called you can sequence
3 // the number of paramaters passed to the function
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment