Skip to content

Commit f0597a7

Browse files
VC-3305 fix double wpml translation for some specific cases with autotranslate (#2486)
1 parent 6f86bdb commit f0597a7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

visualcomposer/Modules/Vendors/Plugins/WpmlController.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ protected function initialize(Request $requestHelper)
105105
);
106106

107107
$this->addFilter('vcv:frontend:renderContent', 'applyObjectId');
108+
109+
$this->wpAddFilter(
110+
'wpml_pb_should_body_be_translated',
111+
'blockBodyTranslations',
112+
10,
113+
2
114+
);
108115
}
109116

110117
/**
@@ -593,4 +600,24 @@ protected function applyObjectId($sourceId)
593600
true
594601
);
595602
}
603+
604+
/**
605+
* Prevent body translations for vcv posts.
606+
* We use it in some specific wpml cases to prevent some duplicate translation
607+
* that take additional credits from users
608+
*
609+
* @param bool $isBodyTranslate
610+
* @param \WP_Post $post
611+
*
612+
* @return bool
613+
*/
614+
protected function blockBodyTranslations($isBodyTranslate, $post)
615+
{
616+
$frontendHelper = vchelper('Frontend');
617+
if (empty($post->ID) || ! $frontendHelper->isVcvPost($post->ID)) {
618+
return $isBodyTranslate;
619+
}
620+
621+
return false;
622+
}
596623
}

0 commit comments

Comments
 (0)