• Resolved X-Raym

    (@x-raym)


    Hi !

    When I write a apostrophe ' on the congratulations text of a badges, it becomes #039; (i put random spaces because it was interpreted as entity and not as code even with the code markup)

    and If i save again, it becomes & amp ; #039;

    and again &am p;a mp;# 039;

    the fact is that it is also display in plain text on the badge page.

    A fix will be welcome 😀

    Thanks for listening 🙂

    https://wordpress.org/plugins/badgeos/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    What version are you on?

    Thread Starter X-Raym

    (@x-raym)

    Always the Last 😀

    WordPress 3.9.1, BadgeOS 1.4.2.

    I make a screencapture of what happend, here is the link.

    I also tested on english wordpress and same problem.

    Cheers ! 🙂

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Ah, whoops, i thought this was for one of the premium extensions when you said “congratulations” etc.

    I’ll double check/confirm.

    I wager it’s not technically a bug but instead an unintended consequence from sanitization etc before saving to database.

    Is there a resolution to this issue? I’m experiencing it as well. Additionally, each time the achievement post is saved, any ampersands in the special character codes get rewritten and you start to get things like this:

    '

    Separate but related, does your “Congratulations” add-on offer a workaround for this or is the text sanitized the same way?

    Thread Starter X-Raym

    (@x-raym)

    Try this :

    //FIX CONGRATS BADGEOS TEXT ERROR
    function oncevision_badgeos_entities_fix( $fields ) {
    
    	foreach( $fields as $key => $field ) {
    		if ( '_badgeos_congratulations_text' == $field['id'] ) {
    			$fields[ $key ]['escape_cb'] = 'wp_kses_post';
    			break;
    		}
    	}
    
    	return $fields;
    }
    add_filter( 'badgeos_achievement_data_meta_box_fields', 'oncevision_badgeos_entities_fix' );
    
    //FIX CONGRATS BADGEOS TEXT ERROR
    function oncevision_badgeos_entities_output( $text ) {
    	return html_entity_decode( $text );
    }
    add_filter( 'badgeos_earned_achievement_message', 'oncevision_badgeos_entities_output' );

    Excellent, that works. Many thanks!

    Thread Starter X-Raym

    (@x-raym)

    You are welcome ! Oncevision wrote this code snippet.

    I hope this bug-fix will be integrated in future badgeos updates ! (that’s why I haven’t mark the topic as resolved).

    Cheers !

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    If either of you wants to file a GitHub issue over it, it could get in to the next release 🙂 Bonus points if you want to clean up the function names and issue a pull request.

    Thread Starter X-Raym

    (@x-raym)

    Gamification on the Badgeos support forum ! 😀

    I wonder if for an official release it wouldn’t be better to integrate this code snippet direclty on the native badgeos functions rather that just add a filter.
    Sure, it works like this, but less filter = better performance and cleaner code ! 🙂

    The github issue associated to this is already closed, do you want me to open a new one ?

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Yeah, open a new one please with the appropriate code.

    Thread Starter X-Raym

    (@x-raym)

    Pull request proposed !

    Was this fixed? I am on WordPress 4.1 and BadgeOS 1.4.4, but the same issue. Where do I put the code that X-Raym provided? Thanks!

    Thread Starter X-Raym

    (@x-raym)

    If thk is not fixed (you can try), you can put this quote in a site specific plugin for your website (it is better than the function.php file of your theme or child theme because the code will be active even if your change your theme). You can create one manually or use a wordpress plugin called Functionnality.
    Cheers 🙂

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    No nothing for this is in the official release at the moment. Hotfixing will still be required.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Congratulations Text – Apostrophe – Bug Report’ is closed to new replies.