Last active
February 18, 2021 13:24
-
-
Save alanef/75ad34c2609da4a5bbc5a189af6df1eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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