• Resolved dunco3000

    (@dunco3000)


    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 ??

    https://www.ads-software.com/plugins/wp-glossary-hover/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dunco3000

    (@dunco3000)

    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);
    			}
    Plugin Author chorton2227

    (@chorton2227)

    This issue is now fixed in version 1.2.0. The issue relates to escaping html sepcial characters in the glossary term definition.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Empty element when '&' in element with tooltip inserted’ is closed to new replies.