• Resolved kloud

    (@kloud)


    Hello, J.D.
    I’ve recently started using your plugin on my test site. Thank you for your great work so far.
    I’m now trying to make things look a bit jazzy with styles. The object is to add an icon, or a font icon (like bs glyphicons, or fontawesome) before or after the points value in frontend. Prefix and suffix do not parse the html.
    The use of css selectors and font-face in this case is looking to me something terrible.
    Maybe you can make some advice how to resolve this issue.
    Thanx:)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author J.D. Grimes

    (@jdgrimes)

    Hi @kloud,

    Other users have also suggested the option to use an icon as the prefix or suffix. Until that feature is added, you can hook into the wordpoints_format_points filter.

    Your function would look something like this:

    
    function my_wordpoints_format_points_filter( $formatted, $points, $points_type, $context ) {
    
    	// Only add the icon for the "Credits" points type.
    	if ( 'credits' === $points_type ) {
    		$formatted = $formatted . '<img src="icon.png" />';
    	}
    
    	return $formatted;
    }
    add_filter( 'wordpoints_format_points', 'my_wordpoints_format_points_filter', 10, 4 );
    

    Of course, you could add conditions so that the icon is only displayed in particular contexts, or for specific points types. You could also change the HTML there to use a font icon instead of an image.

    I hope that solves your problem. Let me know if you have more questions.

    Thread Starter kloud

    (@kloud)

    Thank you very much -)
    The function made it.
    There’s only one problem with displaying img/icon in widget “Wordpoints”.
    As i can see, it parses html as a text.
    The first line.
    the link
    Maybe we can do something with this too?-)

    • This reply was modified 7 years, 8 months ago by kloud.
    • This reply was modified 7 years, 8 months ago by kloud.
    • This reply was modified 7 years, 8 months ago by kloud.
    Thread Starter kloud

    (@kloud)

    the link

    • This reply was modified 7 years, 8 months ago by kloud.
    • This reply was modified 7 years, 8 months ago by kloud.
    Plugin Author J.D. Grimes

    (@jdgrimes)

    There is a filter that you can use to disable HTML escaping in the WordPoints widget:

    
    remove_filter( 'wordpoints_points_widget_text', 'esc_html', 20 );
    

    I think maybe I will change this in a future version of WordPoints, so that some HTML is allowed by default.

    Thread Starter kloud

    (@kloud)

    I’ve added the code in my functions.php. It didn’t help unfortunately.

    Plugin Author J.D. Grimes

    (@jdgrimes)

    Ah, I looked at the code and it looks like it actually needs to be this instead:

    
    function my_wordpoints_allow_html_in_wordpoints_widget() {
    	remove_filter( 'wordpoints_points_widget_text', 'esc_html', 20 );
    }
    add_action( 'widgets_init', 'my_wordpoints_allow_html_in_wordpoints_widget', 20 );
    
    Thread Starter kloud

    (@kloud)

    Yeah, that’s it.!
    Thank you so much.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘to add an icon before/after “points”’ is closed to new replies.