+/**
+ * Perform a deep string replace operation to ensure the values in $search are no longer present
+ *
+ * Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values
+ * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
+ * str_replace would return
+ *
+ * @since 2.8.1
+ * @access private
+ *
+ * @param string|array $search
+ * @param string $subject
+ * @return string The processed string
+ */
+function _deep_replace($search, $subject){
+ $found = true;
+ while($found) {
+ $found = false;
+ foreach( (array) $search as $val ) {
+ while(strpos($subject, $val) !== false) {
+ $found = true;
+ $subject = str_replace($val, '', $subject);
+ }
+ }
+ }
+
+ return $subject;
+}
+