Это форум технической поддержки WPML – плагина для многоязычной WordPress.
Доступно для чтения всем, но только клиенты, купившие WPML, могут оставлять сообщения. Сотрудники WPML отвечают на сообщения форума 6 дней в неделю, 22 часов в сутки.
Sun
Mon
Tue
Wed
Thu
Fri
Sat
-
9:00 – 13:00
9:00 – 13:00
9:00 – 13:00
9:00 – 13:00
9:00 – 13:00
-
-
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
-
Часовой пояс службы поддержки: Europe/Kyiv (GMT+02:00)
Предыстория вопроса:
I installed the WPML plugin, activated the languages, and translated everything. Everything works, but when I log in as an administrator, I get an error. The error message is: Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in /home/qrcodemenu/public_html/wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/StringHtml/Repository/HtmlStringsRepository.php:31.
Симптомы:
Fatal error: Uncaught ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty.
Вопросы:
How can I resolve the fatal error when logging in as an administrator?
Is there a specific configuration needed for WPML to avoid this error?
We are already aware of this issue. There are two ways to work around it:
1. Disable automatic string registration
Go to WPML → String Translation and disable the option “Auto register untranslated strings”.
2. Apply a manual fix in the plugin
Navigate to: wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/StringHtml/Repository/HtmlStringsRepository.php
Then update the function readAllRawGettextStringsFromHtmlScriptTags as follows:
private function readAllRawGettextStringsFromHtmlScriptTags( \DOMDocument $dom, string $html ): array {
// We cannot read here with xpath - script tags contain code from the JS template engines and some html will be broken.
// (For example some elements will miss closing tags).
$pattern = '/<script.*?type="text\/(?:html|template)".*?>([\s\S]*?)<\/script>/i';
preg_match_all( $pattern, $html, $matches );
$scriptHtmls = [];
foreach ( $matches[1] as $match ) {
if ( !empty($match) ) {
$scriptHtmls[] = $match;
}
}