private function replace_node_with_children($node, $bad_attributes, $bad_protocols)
{
// If the node has children and also has a parent node,
// clone and re-add all the children just before current node.
if ($node->hasChildNodes() && $node->parentNode) {
foreach ($node->childNodes as $child_node) {
$new_child = $child_node->cloneNode(true);
$this->strip_attributes_recursive($new_child, $bad_attributes, $bad_protocols);
$node->parentNode->insertBefore($new_child, $node);
}
}
// Remove the node from the parent, if defined.
if ($node->parentNode) {
$node->parentNode->removeChild($node);
}
}