Empty element when '&' in element with tooltip inserted
-
Hi,
I had an issue where paragraphs with the ‘&’ character in them where being lost if the WP Glossary Hover plugin was trying to insert the tooltip.
Tracked it down to the ‘$newNode->appendXML($nodeValue)’ failing in class-tooltip-parser.php.
This is the solution I came up with:
line 217: if ($updateNode)
{
$newNode = $dom->createDocumentFragment();
//error_log(“before append: “.$nodeValue);
$convertedNodeValue = str_replace(‘&’, ‘&’, $nodeValue); //13.12.2014 Duncan M Added otherwise ‘appendXML’ below was consistently failing
//error_log(“after conversion: “.$convertedNodeValue);
//if (FALSE == $newNode->appendXML($nodeValue))
if (FALSE == $newNode->appendXML($convertedNodeValue))
{
error_log(“WP Glossary Hover: appendXML failed, line 227 class-tooltip-parser.php”);
}
$node->parentNode->replaceChild($newNode, $node);
}but could be more elegant, and str_replace probably needs to account for more characters than just ‘&’… didn’t have time for further investigation sorry!
Otherwise, awesome plugin ??
- The topic ‘Empty element when '&' in element with tooltip inserted’ is closed to new replies.