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