WPML comes with a built-in function allowing you to duplicate files under the Media Library for multiple languages.
Here’s what WPML does:
- The plugin keeps the same file URL (instead of duplicating the file) but changes the file ID across different languages.
- That means one file URL could have as many as 3 different IDs stored in the database.
While that process might be optimal for them, it’s rather difficult for our plugin to protect these files properly.
Since version 3.3.0, our PDA Gold is compatible with WPML. The file protection and Access Permission now work consistently across different languages.
Requirements:
- Prevent Direct Access Gold version 3.3.0 or greater
PDA Gold & WPML: Integration Logic
- You can protect and configure the file protection, i.e. set File Access Permission, under the default language only.
- When you upload a new file under other languages, you won’t be able to protect them. You have to switch to the main language first.
- Once a file is (un)protected, all its copies under sub-languages will be (un)protected accordingly.
- In other words, the protection status and File Access Permission will follow the ones under the default language.
Please note that when WPML is deactivated, all media files under multiple languages will be moved back into one place. As a result, your file uploads will become “duplicated” under the Media Library. Protecting one file will cause “missing file” error for the others because they all share the same file URL as mentioned above.
Handle “missing file” error
If you already translated the media files before updating PDA Gold to the newest version, you might come across the “missing file” error.
To fix it, simply use the following API.
/wp-json/pda/v1/fix-wpml/1
With image files, you also need to run the API below to display their scrset correctly.
/wp-json/pda/v1/fix-wpml/2