|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Plugin Name: OSI Events Manager Tweaks |
| 4 | + * Description: Customizations for the Events Manager plugin. |
| 5 | + * Version: 1.0.0 |
| 6 | + * Author: WordPress.com Special Projects |
| 7 | + * Author URI: https://wpspecialprojects.wordpress.com/ |
| 8 | + */ |
| 9 | + |
| 10 | + /** |
| 11 | + * Remove the event time zone if the event is all day. |
| 12 | + * |
| 13 | + * @param string $replace The string to replace. |
| 14 | + * @param EM_Event $EM_Event The event object. |
| 15 | + * @param string $full_result The full result. |
| 16 | + * @param string $target The target. |
| 17 | + * @param array $placeholder_atts The placeholder attributes. |
| 18 | + * |
| 19 | + * @return string |
| 20 | +*/ |
| 21 | +function osi_em_event_output_placeholder( $replace, $EM_Event, $full_result, $target, $placeholder_atts ) { |
| 22 | + if ( '#_EVENTTIMEZONE' === $full_result ) { |
| 23 | + $event_times = $EM_Event->output('#_EVENTTIMES'); |
| 24 | + if ( 'All Day' === $event_times ) { |
| 25 | + $replace = ''; |
| 26 | + } |
| 27 | + } |
| 28 | + return $replace; |
| 29 | +} |
| 30 | +add_filter('em_event_output_placeholder', 'osi_em_event_output_placeholder', 10, 5); |
| 31 | + |
| 32 | +/** |
| 33 | + * Display "Free" for events with a price of 0.00. |
| 34 | + * |
| 35 | + * @param string $formatted_price The formatted price. |
| 36 | + * @param string $price The price. |
| 37 | + * @param string $currency The currency. |
| 38 | + * @param string $format The format. |
| 39 | + * @return void |
| 40 | + */ |
| 41 | +function osi_format_event_manager_price( $formatted_price, $price, $currency, $format ) { |
| 42 | + if( 0.00 === (float)$price ) { |
| 43 | + $formatted_price = 'Free'; |
| 44 | + } |
| 45 | + |
| 46 | + return $formatted_price; |
| 47 | +} |
| 48 | +add_filter('em_get_currency_formatted', 'osi_format_event_manager_price', 10, 4 ); |
0 commit comments