Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. function wpmldp_update_tribe_wooticket_for_event_meta( $post_id, $post, $update ) {
  2. // Only set for post_type = product
  3. if ( 'product' !== $post->post_type ) {
  4. return;
  5. }
  6. //Check if WPML and THe Events Calendar are enabled
  7. if (class_exists('SitePress')) {
  8. //Get the current ID on "_tribe_wooticket_for_event" meta
  9. $current_wooticket_id = get_post_meta($post_id, '_tribe_wooticket_for_event');
  10. if ( $current_wooticket_id ) {
  11. //Get Post Language
  12. $wpml_post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post_id ) ;
  13. $wpml_current_language = $wpml_post_language_details['language_code'];
  14. //Check if there is a translation for the $current_wooticket_id. If not, returns the original ID
  15. $translated_wooticket_id = apply_filters( 'wpml_object_id', $current_wooticket_id[0], 'page', FALSE, $wpml_current_language);
  16. //Update post meta with the translated ID
  17. if ($translated_wooticket_id) {
  18. update_post_meta( $post_id, '_tribe_wooticket_for_event', $translated_wooticket_id );
  19. }
  20. }
  21. }
  22. return;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement