Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display "Free" instead of 0.00$ (dev) #76

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions mu-plugins/osi-events-manager-tweaks/osi-events-manager-tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
* Author URI: https://wpspecialprojects.wordpress.com/
*/

add_filter('em_event_output_placeholder', 'osi_em_event_output_placeholder', 10, 5);
/**
* Remove the event time zone if the event is all day.
*
* @param string $replace The string to replace.
* @param EM_Event $EM_Event The event object.
* @param string $full_result The full result.
* @param string $target The target.
* @param array $placeholder_atts The placeholder attributes.
*
* @return string
*/
function osi_em_event_output_placeholder( $replace, $EM_Event, $full_result, $target, $placeholder_atts ) {
if ( '#_EVENTTIMEZONE' === $full_result ) {
$event_times = $EM_Event->output('#_EVENTTIMES');
Expand All @@ -16,4 +26,23 @@ function osi_em_event_output_placeholder( $replace, $EM_Event, $full_result, $ta
}
}
return $replace;
}
}
add_filter('em_event_output_placeholder', 'osi_em_event_output_placeholder', 10, 5);

/**
* Display "Free" for events with a price of 0.00.
*
* @param string $formatted_price The formatted price.
* @param string $price The price.
* @param string $currency The currency.
* @param string $format The format.
* @return void
*/
function osi_format_event_manager_price( $formatted_price, $price, $currency, $format ) {
if( 0.00 === (float)$price ) {
$formatted_price = 'Free';
}

return $formatted_price;
}
add_filter('em_get_currency_formatted', 'osi_format_event_manager_price', 10, 4 );
Loading