WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
[resolved] not support chinese character in sidebar widget? (17 posts)

  1. yanc1985
    Member
    Posted 4 years ago #

    all character become "��大�(�)"....

  2. Kirijun
    Member
    Posted 4 years ago #

    I use Japanese character.
    I updated WPP to 2.1.3 from 2.1.0, and my widget is garbled, too.
    It works properly with 2.1.0.

    I replaced $instance['title'] = htmlspecialchars( stripslashes(strip_tags( $new_instance['title'] )), ENT_QUOTES ); with $instance['title'] = htmlspecialchars( stripslashes(strip_tags( $new_instance['title'] )), ENT_QUOTES, 'UTF-8', FALSE );, but a problem was not settled.

  3. letmein
    Member
    Posted 4 years ago #

    Same here for Russian language, instead of the post titles in Russian i get the same thing as yanc1985. The last proper working version was 2.1.0. I know for sure that the problem is somewhere in wordpress-popular-posts.php, but i can't find it. Great plugin though, thanks

  4. sokai
    Member
    Posted 4 years ago #

    Thanks Kirijun!

    After I read the Changelog for that Plugin I found the following comment in version 2.1.1: "Added htmlentities to post titles".

    So the solution for correct implementation of htmlentities in WP is to give it the used charset, too (like Kirijun wrote).

    htmlentities is used two times in wordpress-popular-posts.php (v2.1.3): line 624 and line 630.
    The best way would be:

    1. Define the blog charset in wordpress-popular-posts.php
      Maybe before the first htmlentities occures.
      $bcharset = get_bloginfo('charset');
    2. Change line 624 to
      $title_attr = htmlentities($tit, ENT_QUOTES, $bcharset, FALSE);
    3. Change line 630 to
      $tit = htmlentities($tit, ENT_QUOTES, $bcharset, FALSE);

    @Héctor Cabrera (the Plugin Author):
    Please fix that ASAP! - Thanks!

    sofar|sokai

  5. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    Hi guys,

    Please try this fix and let me know the results:

    1. Open wordpress-popular-posts.php using an editor such as Windows' Notepad or Adobe Dreamweaver.
    2. Around line 622, find and change this:
      $tit = stripslashes($tit);
      $title_attr = htmlentities($tit, ENT_QUOTES);
      
      if ( $instance['shorten_title']['active'] && (strlen($tit) > $instance['shorten_title']['length'])) {
      	$tit = mb_substr($tit, 0, $instance['shorten_title']['length'], 'UTF-8') . "...";
      }
      $tit = htmlentities($tit, ENT_QUOTES);

      ... into this:

      $tit = stripslashes($tit);
      $title_attr = htmlentities($tit, ENT_QUOTES, 'UTF-8');
      
      if ( $instance['shorten_title']['active'] && (strlen($tit) > $instance['shorten_title']['length'])) {
      	$tit = mb_substr($tit, 0, $instance['shorten_title']['length'], 'UTF-8') . "...";
      }
      
      $tit = htmlentities($tit, ENT_QUOTES, 'UTF-8');
    3. Save changes.

    P.S.: Sokai's proposal seems a bit better. Will test this and post back later with new instructions.

  6. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    OK guys, please download 2.1.4 here and let me know if it fixes the issue.

  7. Kirijun
    Member
    Posted 4 years ago #

    I downloaded 2.1.4 and it works correctly. Thank you!

  8. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    Good to know that, Kirijun! Thanks for reporting!

  9. mono-lab
    Member
    Posted 4 years ago #

    Hi Ikki24.

    Thank you for fast reply.
    But there is still a little bug.

    It shows backslash like this in source code.

    <span class=\"wpp-post-title\">

  10. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    Hi mono-lab,

    Can you please post a screenshot of your WPP widget settings?

  11. mono-lab
    Member
    Posted 4 years ago #

    Ok plese take a look in here.

  12. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    Thanks! Found the bug and fixed it, please download WPP 2.1.4 here and let me know if the issue is fixed.

  13. katzeausdemsack
    Member
    Posted 4 years ago #

    Latest 2.1.4 works fine for me with the german characters now. Thank you ikki24

  14. mono-lab
    Member
    Posted 4 years ago #

    Thank you Ikki24.
    It works fine now!

  15. yanc1985
    Member
    Posted 4 years ago #

    Thanks for the quick reply and improvement :)

  16. Héctor Cabrera
    Member
    Plugin Author

    Posted 4 years ago #

    Thank you guys for your continuous feedback and suggestions!

  17. letmein
    Member
    Posted 4 years ago #

    Yes, it's fixed. Thanks a lot

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic