| 740 | // Restore the original HTML |
| 741 | $_caption = html_entity_decode($caption); |
| 742 | |
| 743 | // Only allow a subset of tags |
| 744 | $allowed_tags = array('strong', 'em', 'a'); |
| 745 | |
| 746 | // Set those tags aside |
| 747 | if ( preg_match_all('/<\/?([a-zA-Z]+).*?>/x', $_caption, $matches) ) { |
| 748 | $i = 0; |
| 749 | $searches = array(); |
| 750 | $replacements = array(); |
| 751 | foreach ( $matches[0] as $k => $v ) { |
| 752 | if (in_array($matches[1][$k], $allowed_tags) ) { |
| 753 | $_caption = str_replace($v, 'tag-' . $i, $_caption); |
| 754 | $searches[] = 'tag-' . $i++; |
| 755 | $replacements[] = $v; |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | // Re-encode the caption |
| 760 | $_caption = htmlentities($_caption); |
| 761 | |
| 762 | // Restore the allowed HTML |
| 763 | $caption = str_replace($searches, $replacements, $_caption); |
| 764 | } |
| 765 | |