The easiest thing that you can do is to make sure your title won’t be cut, because the strange char appear when we trim the title.
So use shorted titles/ less hashtags / use shortners.
Thanks for the answer. This is not a solution but a compromise. All your updates after 4.0.10 versions contain a bunch of bugs. I’m staying at version 4.0.10.
Hi Sergey,
The actual solution is to use some set of php functions that can cause issues to other users, so I am a bit afraid to push an update without more testing.
Unless I’m missing something, the solution is simply to use mb_substr() function instead of substr() in your CWP_TOP_Core::generateTweetFromPost() method.
That’s what WordPress core uses in wp_html_excerpt() function (which you also could use instead of substr()
), so it should not cause any issues.
WordPress also has a compat version of mb_substr()
in case mbstring
PHP extension is not installed.
Hi Sergey,
I was worried that an issue might happen in case that mbstring is not installed, I didn’t know that wordpress also have a compact version of mb_substr ().
Also I suppose that I need to update strlen to mb_strlen also right ?
Also I suppose that I need to update strlen to mb_strlen also right ?
Yes. You can add a wrapper method with a function_exists()
check to your class:
function my_strlen( $string ) {
if ( function_exists( 'mb_strlen' ) ) {
$length = mb_strlen( $string );
} else {
$length = strlen( $string );
}
return $length;
}
And then use $this->my_strlen()
instead of strlen()
.