WordPress.org

Support

Support » Plugins and Hacks » Feature A Page Widget » [Resolved] Possible to include html code in experpt?

[Resolved] Possible to include html code in experpt?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mark Root-Wiley

    @mrwweb

    Hi @umchal,

    I should make this clearer on the plugin page. Because the excerpt may be used in other places, I didn’t want to just enable HTML in the widget text and risk having it not work elsewhere.

    Hence, I’ve added support in version 1.1.0 for the Rich Text Excerpts plugin. If you install that, my plugin will automatically support HTML and you’ll get the WYSIWYG editor in all your excerpts. (Of course, if you don’t like that, you can always flip over to “text” mode of the editor.)

    Make sure to mark this thread as resolved if this answers your question.

    Thanks for the reply, Mark.

    I just tried the plugin and indeed the rich text editor appeared in the excerpt field but the result was the same. The widget shows the literal HTML code. I’m using WordPress 3.5.

    And for the first time when I tried to save the options of Rich Text Excerpts via the admin page, it threw these errors if that is relevant. It does not throw the errors after that any more.

    Warning: trim() expects parameter 1 to be string, array given in .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php on line 339
    
    Warning: trim() expects parameter 1 to be string, array given in .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php on line 344
    
    Warning: Cannot modify header information - headers already sent by (output started at .../wp-content/plugins/rich-text-excerpts/rich-text-excerpts.php:339) in .../wp-includes/pluggable.php on line 876

    Plugin Author Mark Root-Wiley

    @mrwweb

    Well bummer. Sorry to hear that. I had tested this combination just before the 3.5 release on one of the release candidates, but it looks like I missed something. I’ll try to figure out what’s going on and push out an update soon if I figure out what’s going on.

    It also sounds like that plugin is conflicting with something in your site. I’m not seeing that error. If you want to resolve that issue, you’d probably need to open a thread on that plugin’s forum. I’ve emailed the plugin dev in the past, so I’ll try to bump him too.

    In the mean time, if the icon you want is at the beginning or end of the text and is purely decorative, you could do a straight CSS implementation with something like this (the values are off but that should get you started):

    .fpw-excerpt:before {
        width: 1em;
        height: 1em;
        display: inline-block;
        content: ' ';
        background: url(path/to/an/imagefile.gif) left center no-repeat;
    }

    Alternately, if you know how, you could filter the excerpt yourself to replace some string with an icon. There are three filters in the plugin, one of which is fpw_excerpt.

    Thanks for the great response. I’m looking forward to the update.

    [Edit]
    I just briefly looked into the code in fpw_widget.class.php and changed the lines around #162,

    if( class_exists( 'RichTextExcerpts' ) )
    	$excerpt = wp_kses_decode_entities( $excerpt );

    to

    $excerpt = wp_kses_decode_entities( $excerpt );
    $excerpt = htmlspecialchars_decode($excerpt);

    and it worked.

    So I’d like to suggest a feature to implement an option which allows to enforce HTML code (perform htmlspecialchars_decode() internally). Maybe a check box in the widget would be sufficient I guess.

    Plugin Author Mark Root-Wiley

    @mrwweb

    Hi @umchal.

    Sorry I missed your edit here. I just pushed the 1.2.0 release of the plugin out and it includes a fix for this issue.

    It still requires the Rich Text Excerpts plugin to be activated to work, though. If you want to hack it so that it’s always turned on, you’d just need to remove the conditional around the lines you referenced above.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Possible to include html code in experpt?’ is closed to new replies.
Skip to toolbar