• Resolved aryanrajseo

    (@aryanrajseo)


    Hi,

    This plugin is really useful. I wonder if it is possible to add HTML tags like <span class=”i”>I</span>

    Currently it wipes out the HTMLs and keep the text only.

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @aryanrajseo,

    This plugin doesn’t allow HTML tags because WordPress doesn’t allow them in regular widget titles.

    There are methods to add HTML in widget titles, example:
    https://www.isitwp.com/simple-html-in-widget-title/

    You can use the same method for this plugin if you change the filter to: widget_subtitle.

    Hope this helps!

    Regards, Jory

    Thread Starter aryanrajseo

    (@aryanrajseo)

    Hi,

    Thank you for such a quick reply. I already thought the same but the spacing in class not work.

    // Allow HTML tags in Widget title 
    function html_widget_title( $var) {
    	$var = (str_replace( '[', '<', $var ));
    	$var = (str_replace( ']', '>', $var ));
    	$var = (str_replace( '|', ' ', $var ));
    	return $var ;
    	
    }
    add_filter( 'widget_subtitle', 'html_widget_title' );

    with code
    [span class=dashicons|dashicons-wordpress] [/span]

    output
    <span class="dashicons" dashicons-wordpress=""> </span>

    Do you think if there is any alternative way?

    Thank you.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @aryanrajseo,

    Please try this:
    [span class="dashicons dashicons-wordpress"] [/span]

    It should work!
    Regards, Jory

    PS: please consider leaving a nice review, it will help the plugin grow ??

    Thread Starter aryanrajseo

    (@aryanrajseo)

    I already tried that. It not working. The spacing is causing problem in class name.
    here is the result.
    <span class="&quot;dashicons" dashicons-wordpress&quot;=""> </span>

    I think the best way is to use shortcode. I enabled support for shortcode in widget title.

    add_filter('the_title', 'do_shortcode');
    add_filter('widget_title', 'do_shortcode');

    but this code

    add_filter('the_subtitle', 'do_shortcode');
    add_filter('widget_subtitle', 'do_shortcode');

    outputs the shortcode name only. It works with default widget title.

    I will surely write a review. ??

    Thread Starter aryanrajseo

    (@aryanrajseo)

    add_shortcode( 'icon', 'shortcode_fa' );
    function shortcode_fa( $atts = [], $content = null) {
    return '<i class="fa fa-'. $content . '"></i>';
    }
    <section id="custom_html-6" class="widget_text widget widget_custom_html">
        <div class="widget_text widget-wrap"><span
                class="widgetsubtitle widget-subtitle subtitle-before-outside subtitle-before subtitle-outside">my icon
                <icon>apple</icon></span>
            <h3 class="widgettitle widget-title">my icon <i class="fa fa-apple"></i></h3>
            <div class="textwidget custom-html-widget">Content:</div>
        </div>
    </section>
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @aryanrajseo,

    I’ve enhanced the update code in this plugin a bit:
    https://github.com/JoryHogeveen/widget-subtitles/pull/12

    Could you apply these changes and test if this fixes your issue?

    EDIT: You might need to re-save/type your subtitle!

    Regards, Jory

    • This reply was modified 5 years, 3 months ago by Jory Hogeveen.
    Thread Starter aryanrajseo

    (@aryanrajseo)

    No, It output text but not classes. It uses [icon] shortcode to wrap the $content.

    <div class="widget_text widget-wrap"><span
            class="widgetsubtitle widget-subtitle subtitle-before-outside subtitle-before subtitle-outside">my icon <icon>
                subtitle</icon></span>
        <h3 class="widgettitle widget-title">my icon <i class="fa fa-title"></i></h3>
        <div class="textwidget custom-html-widget"></div>
    </div>
    • This reply was modified 5 years, 3 months ago by aryanrajseo.
    Plugin Author Jory Hogeveen

    (@keraweb)

    It looks like you might have your custom filter html_widget_title active, correct?

    Thread Starter aryanrajseo

    (@aryanrajseo)

    Hi, I am really sorry.

    You are correct. It is working now. Thank you so much.

    Plugin Author Jory Hogeveen

    (@keraweb)

    No problem, I’ll release the changes mentioned earlier a.s.a.p.
    Good luck with your project!

    Cheers, Jory

    Thread Starter aryanrajseo

    (@aryanrajseo)

    Thank you.

    I really appreciate your help and giving me the time to solve this. I hope you keep it updated as i will regularly use it now.

    This will surely save me some free time. ??

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Allow HTML tags in Widget Subtitles’ is closed to new replies.