Bug report with restricted message
-
Hi guys,
I am using your free version of Restrict Content, and I believe I found a bug. When restricting a post to certain members, and showing the excerpt, sometimes the post will be cut before an HTML tag is closed. For example, see here the
strong
tag: https://i.imgur.com/I5b3JIj.pngThat causes all sorts of styling issues, so what I did is the following.
1) Edited the file /wp-content/plugins/restrict-content/core/includes/content-filters.php
2) Added this function, taken from here:
function fix_html($html) { $dom = new DOMDocument(); $dom->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ); $return = ''; foreach ( $dom->getElementsByTagName( 'body' )->item(0)->childNodes as $v ) { $return .= $dom->saveHTML( $v ); } return $return; }
3) Added this line…
$excerpt = fix_html($excerpt);
…after this other line:
$excerpt = rcp_excerpt_by_id( $post, $excerpt_length );
I know just the basics of PHP, so I’m not sure if this is the best solution to this problem, but at least you have something it works.
Anyway, could you please fix the bug in next versions?
Thank you!
- The topic ‘Bug report with restricted message’ is closed to new replies.