Conversation
supportHi, 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 🙂 https://wordpress.org/plugins/wp-glossary-hover/
Sorry, should have included my code correctly: 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); }
This issue is now fixed in version 1.2.0. The issue relates to escaping html sepcial characters in the glossary term definition.
Sorry, should have included my code correctly: 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); }
This issue is now fixed in version 1.2.0. The issue relates to escaping html sepcial characters in the glossary term definition.