• Resolved aseverirene

    (@aseverirene)


    Hi there,

    Thanks for this marvelous plugin.
    I’m using the Hueman theme, with NimblePageBuilder. I would to show the Widget Recent Reviews, however the widget shows book review content without HTML (stripped all tags)-code and without a Read More button… As shown here:

    <?php echo '<p>' . mb_substr( wp_strip_all_tags( strip_shortcodes( $review->get_the_rcno_book_review_content( $review_id ) ), true ), 0, $char_count ) . '</p>'; ?>

    I would to see the review title, some content and a read more button. Would that be possible with this widget?

    Looking forward to hearing from you.

    Kind regards,
    Irene

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 20 total)
  • Plugin Author Kemory Grubb

    (@w33zy)

    Hello @aseverirene

    The widget was designed to not show HTML elements because in the earlier versions of the plugin, user would complain that the widget was not displaying properly because HTML elements such as buttons and images would stretch it beyond it content area.

    The small size of most theme’s sidebar area means the space to display information is limited within widgets. It is one of the reasons I made the title and author information clickable.

    Thread Starter aseverirene

    (@aseverirene)

    Hi @Kemory,

    Thanks for your early reply. ??

    Since most people can now work with page builders, it will be possible to drag widgets into the content area (other than in sidebars).

    So with a little CSS-customization I would be doing, I can make reviews look like a grid. And specify exactly within an ‘excerpt’ (hopefully with all HTML tags included), how my review grid would look.

    I would really appreciate your adjustments here as mentioned above, since my clients want to show this particular widget in that fashion.

    Thanks again for your great plugin.:-)

    Kind regards,
    Irene

    Plugin Author Kemory Grubb

    (@w33zy)

    Hello @aseverirene

    I will look into re-writing this feature to provide an option where you can short-circuit the output and skip the sanitization via a filter.

    Thread Starter aseverirene

    (@aseverirene)

    @Kemory:

    That would be just great! Thanks in advance for all your efforts… ??

    Plugin Author Kemory Grubb

    (@w33zy)

    Hello @aseverirene,

    I just did the rewrite of this widget to fit your use-case and I immediately noticed a major issue.

    I am truncating the content of reviews using mb_substr() so when I do this with HTML tags present, it is leaving un-closed HTML tags. So because of the browser making an attempt to correct malformed HTML, I end up with a very broken layout for the widget’s content.

    This how it looks in my dev build https://imgur.com/a/z4oRcEw

    Thread Starter aseverirene

    (@aseverirene)

    @Kemory: I see, and indeed it would be nice if author was included in this widget.

    For now I have changed your Recent Review widget a little bit:

    <?php echo '<p>' . $review->get_the_rcno_book_review_excerpt( $review_id ) . '</p>'; ?>

    Although, I would like to add more HTML-tags to the excerpt…

    Kind regards,
    Irene

    Plugin Author Kemory Grubb

    (@w33zy)

    You almost beat me to that piece of code… another user had asked me to add a feature to use the book synopsis and I had expanded that feature request to this…

    https://gitlab.com/w33zy/rcno-reviews/-/blob/master/public/widgets/class-rcno-reviews-recent-reviews.php#L119

    The rcno_recent_reviews_skip_sanitization filter was to be for your use case but seeing the direction your code, give you a general filter to change the output of that section might be better. I’ll work on that.

    Thread Starter aseverirene

    (@aseverirene)

    @Kemory: Brilliant, and did I tell you, I appreciate this collaboration very much? Because I do. ??

    Plugin Author Kemory Grubb

    (@w33zy)

    You’re welcome. Your feedback helps me improve the plugin.

    Plugin Author Kemory Grubb

    (@w33zy)

    Hey @aseverirene

    The update with new filter is up, below is an example of its usage.

    /**
     * Change the "Recent Reviews" widget area
     *
     * @param string $content The widget item content area
     * @param int    $post_id The widget item post ID
     *
     * @return string
     */
    function rcno_change_recent_reviews_widget_content( $content, $post_id ) {
    	$content = get_post( $post_id )->post_excerpt;
    	return $content;
    }
    add_filter( 'rcno_recent_reviews_content', 'rcno_change_recent_reviews_widget_content', 10, 2 );
    Thread Starter aseverirene

    (@aseverirene)

    Splendid. Thank you so much for this…

    ??

    Plugin Author Kemory Grubb

    (@w33zy)

    You’re welcome

    Please be sure to leave a review if you’ve found the plugin helpful

    Thread Starter aseverirene

    (@aseverirene)

    Yeah, will do.

    One more question: would it be possible to replace character count by word count?

    Plugin Author Kemory Grubb

    (@w33zy)

    It could be done using the new filter.

    However, accurately splitting by word count is a bit tricky especially when leaving in the HTML tags. It is one of the reasons why I stripped HTML tags in the first place.

    function rcno_change_recent_reviews_widget_content( $content, $post_id ) {
        $length = 10; // word count
        $output = get_post( $post_id )->post_content; // get_post( $post_id )->post_excerpt;
        $output = strip_shortcodes( strip_tags( $output ) );
        $output = preg_split( '/\b/', $output, $length * 2 + 1 );
        $waste  = array_pop( $output );
    
        return implode( $output );
    }
    add_filter( 'rcno_recent_reviews_content', 'rcno_change_recent_reviews_widget_content', 10, 2 );

    If you try commenting out the strip tags line, you’ll see that it breaks the widget

    Thread Starter aseverirene

    (@aseverirene)

    Would it be possible to add a read-more button to your widget.

    Like within above functions?

    Thanks in advance.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Widget Recent Reviews’ is closed to new replies.