Hi Joost, I’ve been using your SEO plugin for quite a while with pleasure, but just noticed something wrong.
It adds “description” automatically to all the posts, but, I don’t know since which version, doesn’t seem support Chinese characters, so many of my new posts are becoming ???????? in search engines, like this one:
I can’t disable the plugin, that would change a lot of settings; however, I’m also unable to find any way of disabling this feature so it won’t generate “description” automatically. I have to manually change that in my new posts.
Would you please help, or let me know how to fix this, so it either stops generating description automatically, or supports Chinese characters?
The problem was introduced in trac-revision 565588, I guess this would translate to WP SEO v 22.214.171.124 ?.
The problem is in file wordpress-seo/inc/wpseo-functions.php, line 156:
'%%excerpt%%' => ( !empty( $r->post_excerpt ) ) ? strip_tags( $r->post_excerpt ) : utf8_encode( substr( strip_shortcodes( strip_tags( utf8_decode( $r->post_content ) ) ), 0, 155 ) ),
Here the utf8_encode and utf8_decode functions are used, however these functions will only work as expected if applied to a string in a latin characterset.
In my opinion, the best fix to avoid breaking nearly all non-latin sites would be:
'%%excerpt%%' => ( !empty( $r->post_excerpt ) ) ? strip_tags( $r->post_excerpt ) : ( (extension_loaded ( 'mbstring' ) === true ) ? mb_substr( strip_shortcodes( strip_tags( $r->post_content ) ), 0, 155, 'UTF-8' ) : substr( strip_shortcodes( strip_tags( utf8_decode( $r->post_content ) ) ), 0, 155 ) ),
Hope this helps!
You’re very welcome.
Could you please change the status of the topic back to unresolved though until the fix has been picked up by Yoast and included in the plugin for the next version ?
Otherwise we’ll have to keep changing the files manually which isn’t really a solution.
@ jrf Good point, changed back! Hope Y will see this soon!
I think it’s much better solution
'%%excerpt%%' => (!empty($r->post_excerpt)) ? strip_tags($r->post_excerpt) : wp_html_excerpt(strip_shortcodes($r->post_content),155),
wp_html_excerpt provide mb_functions fallback and remove part of html entity at the end of string
- The topic ‘[Plugin: WordPress SEO by Yoast] Chinese characters corrupted in description’ is closed to new replies.