Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * THIS IS UNSUPPORTED!
- *
- * Translating reviews with WPML will create reviews in the wp_posts table
- * that are NOT linked to review details in the custom Site Reviews tables.
- * This may break functionality of Site Reviews and it is NOT supported!
- */
- add_action('site-reviews/review/build/before', function ($review) {
- // get the current language
- $lang = apply_filters('wpml_current_language', null);
- // get the Post ID of the translated review
- $postId = apply_filters('wpml_object_id', $review->ID, glsr()->post_type, true, $lang);
- // only proceed if the review has been translated
- if ($postId === $review->ID) {
- return;
- }
- $post = get_post($postId);
- if (!empty($post->post_title)) {
- $review->set('title', $post->post_title);
- }
- if (!empty($post->post_content)) {
- $review->set('content', $post->post_content);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement