Skip to content

Instantly share code, notes, and snippets.

View mackensen's full-sized avatar

Charles Fulton mackensen

View GitHub Profile
@westonruter
westonruter / force_balance_tags2.php
Last active August 21, 2019 08:44
Use DOMDocument to do a more robust job at force_balance_tags.
<?php
/**
* Use DOMDocument to do a more robust job at force_balance_tags.
*
* "force_balance_tags() is not a really safe function. It doesn’t use an HTML parser
* but a bunch of potentially expensive regular expressions. You should use it only if
* you control the length of the excerpt too. Otherwise you could run into memory issues
* or some obscure bugs." <http://wordpress.stackexchange.com/a/89169/8521>
*