Multibyte support
-
Dear author,
I want this plugin to support multibyte languages like Japanese, Chinese, and so on.
I think it’s easy. A little bit of change on top-core.php after L.402.
Set $lenFunc/$subFunc and use them as strlen/substr function like this://Shrink a tweet and accompanying URL down to 140 chars. function set_tweet_length($message, $url, $twitter_hashtags="", $hashtag_length=0) { $lenFunc = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; $subFunc = function_exists('mb_substr') ? 'mb_substr' : 'substr'; $tags = $twitter_hashtags; $message_length = $lenFunc($message); $url_length = $lenFunc($url); //$cur_length = $lenFunc($tags); if ($hashtag_length == 0) $hashtag_length = $lenFunc($tags); if ($twitter_hashtags != "") { if ($lenFunc($tags) > $hashtag_length) { $tags = $subFunc($tags, 0, $hashtag_length); $tags = $subFunc($tags, 0, strrpos($tags, ' ')); } $hashtag_length = $lenFunc($tags); } if ($message_length + $url_length + $hashtag_length > 140) { $shorten_message_to = 140 - $url_length - $hashtag_length; $shorten_message_to = $shorten_message_to - 4; //$message = $message." "; if ($lenFunc($message) > $shorten_message_to) { $message = $subFunc($message, 0, $shorten_message_to); $message = $subFunc($message, 0, strrpos($message, ' ')); } $message = $message . "..."; } return $message . " " . $url . " " . $tags; }
This is important for mutlibyte language users like me, as this problem can’t be fixed with wp filters.
Thank you for your consideration (and patience with my bad English).https://www.ads-software.com/plugins/tweetily-tweet-wordpress-posts-automatically/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Multibyte support’ is closed to new replies.