WordPress Dashboard and tell WPML if your site has been moved or copied."; const SITE_MOVED_OR_COPIED_DOCS_URL = 'https://wpml.org/documentation/translating-your-contents/advanced-translation-editor/using-advanced-translation-editor-when-you-move-or-use-a-copy-of-your-site/?utm_source=plugin&utm_medium=gui&utm_campaign=wpmltm'; /** * @var Lock */ private $lock; /** * @param Lock $lock */ public function __construct( Lock $lock ) { $this->lock = $lock; } public function handleClonedSiteError( $response ) { if ( self::SITE_CLONED_ERROR === $response['response']['code'] ) { $parsedResponse = json_decode( $response['body'], true ); if ( isset( $parsedResponse['errors'] ) ) { $this->handleClonedDetection( $parsedResponse['errors'] ); } return new \WP_Error( self::SITE_CLONED_ERROR, 'Site Moved or Copied - Action Required' ); } return $response; } public function checkCloneSiteLock() { if ( Lock::isLocked() ) { $errorMessage = sprintf( __( self::SITE_MOVED_OR_COPIED_MESSAGE, 'sitepress-multilingual-cms' ), UIPage::getTMDashboard(), self::SITE_MOVED_OR_COPIED_DOCS_URL ); return new \WP_Error( self::SITE_CLONED_ERROR, $errorMessage ); } return null; } public function unlockClonedSite() { return $this->lock->unlock(); } private function handleClonedDetection( $error_data ) { $error = array_pop( $error_data ); $this->lock->lock( $error ); } }