2020-04-03, 08:43:40
Currently "Dynpages" returns an empty string when the it can't find a component.
This happened to me because I actually need to display values that look similar to the values that "Dynpages" is looking to replace.
To deal with this I updated my copy of the plugin so that it will return the original string if it could not find a component.
I replaced ...
=====================
ob_start();
if (function_exists('get_i18n_component')) {
get_i18n_component($match[2]);
} else {
get_component($match[2]);
}
$replacement .= ob_get_contents();
ob_end_clean();
=====================
with ...
=====================
ob_start();
$foundKey = null;
if (function_exists('get_i18n_component')) {
$foundKey = get_i18n_component($match[2]);
} else {
get_component($match[2]);
}
$newContent = ob_get_contents();
ob_end_clean();
if ($foundKey or !empty($newContent)) {
$replacement .= $newContent;
} else {
// Key not found. Return original for debug or content.
// Sometimes it is just valid content.
return $match[0];
}
=====================
Any feedback welcome.
Thanks.
This happened to me because I actually need to display values that look similar to the values that "Dynpages" is looking to replace.
To deal with this I updated my copy of the plugin so that it will return the original string if it could not find a component.
I replaced ...
=====================
ob_start();
if (function_exists('get_i18n_component')) {
get_i18n_component($match[2]);
} else {
get_component($match[2]);
}
$replacement .= ob_get_contents();
ob_end_clean();
=====================
with ...
=====================
ob_start();
$foundKey = null;
if (function_exists('get_i18n_component')) {
$foundKey = get_i18n_component($match[2]);
} else {
get_component($match[2]);
}
$newContent = ob_get_contents();
ob_end_clean();
if ($foundKey or !empty($newContent)) {
$replacement .= $newContent;
} else {
// Key not found. Return original for debug or content.
// Sometimes it is just valid content.
return $match[0];
}
=====================
Any feedback welcome.
Thanks.