-
-
Save cliffordp/9f68ab6a4753c91ff42c5ba1f0a00b81 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
/** | |
* @link https://theeventscalendar.com/support/forums/topic/event-aggregator-event-country-imported-from-facebook-in-wrong-language-2/ | |
*/ | |
add_action( 'tribe_aggregator_before_insert_posts', 'test_listen_for_event_creation' ); | |
add_action( 'tribe_aggregator_after_insert_posts', 'test_stop_listening_for_event_creation' ); | |
function test_listen_for_event_creation() { | |
add_action( 'tribe_events_venue_created', 'test_translate_venue_country', 10, 2 ); | |
add_action( 'tribe_events_venue_updated', 'test_translate_venue_country', 10, 2 ); | |
} | |
function test_translate_venue_country( $venue_id, $venue_data ) { | |
$country_map = array( | |
'Germany' => 'Deutschland', | |
'Switzerland' => 'Schweiz', | |
); | |
if ( isset( $venue_data['Country'] ) && array_key_exists( $venue_data['Country'], $country_map ) ) { | |
update_post_meta( $venue_id, '_VenueCountry', $country_map[ $venue_data['Country'] ] ); | |
} | |
} | |
function test_stop_listening_for_event_creation() { | |
remove_action( 'tribe_events_venue_created', 'test_listen_for_event_creation' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment