Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpmldp_update_tribe_wooticket_for_event_meta( $post_id, $post, $update ) {
- // Only set for post_type = product
- if ( 'product' !== $post->post_type ) {
- return;
- }
- //Check if WPML and THe Events Calendar are enabled
- if (class_exists('SitePress')) {
- //Get the current ID on "_tribe_wooticket_for_event" meta
- $current_wooticket_id = get_post_meta($post_id, '_tribe_wooticket_for_event');
- if ( $current_wooticket_id ) {
- //Get Post Language
- $wpml_post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post_id ) ;
- $wpml_current_language = $wpml_post_language_details['language_code'];
- //Check if there is a translation for the $current_wooticket_id. If not, returns the original ID
- $translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'page', FALSE, $wpml_current_language);
- //Update post meta with the translated ID
- if ($translated_wooticket_id) {
- update_post_meta( $post_id, '_tribe_wooticket_for_event', $translated_wooticket_id );
- }
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement