BuddyDev

Search

Buddyblog text change on edit

  • Participant
    Level: Guru
    Posts: 812
    Tosin on #48836

    Hello,

    I recently noticed that if I edit a post and revert to draft certain words display weird characters. I am using the medium editor.

    Examples are word like (it’s) is being changed to (it’s) only words with (’) are being affected.

    Kindly see screenshot below.

    https://ibb.co/cxh7SSS

  • Participant
    Level: Guru
    Posts: 812
    Tosin on #48837

    I just found out its an encoding problem that can occur on old post when database has been migrated,

    I tried this code but it did not work

    function fix_weird_characters() {
        global $wpdb;
        $replacements = array(
            '“' => '“',
            '”' => '”',
            '’' => '’',
            '‘' => '‘',
            '—' => '–',
            '–' => '—',
            '•' => '-',
            '…' => '…'
        );
        foreach ($replacements as $key => $value) {
            $query = $wpdb->prepare(
                "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)",
                $key,
                $value
            );
            $wpdb->query($query);
        }
    }
    add_action('wp_loaded', 'fix_weird_characters'); 
  • Keymaster
    (BuddyDev Team)
    Posts: 23284
    Brajesh Singh on #48841

    Hi Tosin,
    That’s an encoding issue.

    Can you create a demo video showing the content and the steps that is causing it.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 812
    Tosin on #48850

    Hi Brajesh

    After further testing I noticed that the encoding issue only occurs when publishing or editing with the buddyblog medium editor.

    After deactivating the buddyblog medium editor, everything works fine and there are no more encoding issues.

  • Keymaster
    (BuddyDev Team)
    Posts: 23284
    Brajesh Singh on #48853

    Hi Tosin,
    Thank you.
    I have the hunch that using DomDocument parser is causing it.
    The problem is MediumEditor(js library) has been abandoned and we are looking for a suitable substitution for future.

    At the moment, I will recommend keeping it diabled.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 812
    Tosin on #48865

    ok thanks Brajesh,

    I have disabled it, please kindly let me know if there will ever be a replacement or update for the medium editor.

  • Keymaster
    (BuddyDev Team)
    Posts: 23284
    Brajesh Singh on #48870

    Thank you Tosin.
    We will do when we find a suitable alternative.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved