I’ll try to get this problem resolved as soon as possible. However I’m not familiar with the cyrillic language. Could you please post an excerpt here along with the expected word count?
Thread Starter
pehog
(@pehog)
Yes, ok, this is one example: “Да, ок, ето един пример. Всъщност преведох първото изречение.” Here we have 9 words.
I have figured out the problem. The php function str_word_count returns zero when the language is not English. Unfortunately, the plugin uses this function extensively. I wasn’t able to find an equivalent function that worked reliably with all languages. Maybe you could disable the checks and go through the content manually.
Thread Starter
pehog
(@pehog)
This script is working good with cyrillic language. http://www.mediacollege.com/internet/javascript/text/count-words.html
May be you can have some idea from it.
I also was thinking about some checking of the symbols that can be the reason for this problem. Is there in your script something like this, or in wordpress?
In our case, the javascript functions are working perfectly. It’s the php functions that are causing problems. The link you have given me is for a javascript function 🙁
Thread Starter
pehog
(@pehog)
Done. In ajax.php I made some changes. Here how:
$chars = 'абвгдежзийклмнопрстуфхцчшщъьюяАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯ';
$tags_array = explode(',', $content['post_tags']);
$stripped_bio = strip_tags($content['about_the_author']);
$stripped_content = strip_tags($content['post_content']);
if ( !empty($content['post_title']) && str_word_count( $content['post_title'], 0, $chars ) < $min_words_title )
$error_string .= 'The title is too short<br/>';
if ( !empty($content['post_title']) && str_word_count( $content['post_title'], 0, $chars ) > $max_words_title )
$error_string .= 'The title is too long<br/>';
if ( !empty($content['post_content']) && str_word_count( $stripped_content, 0, $chars ) < $min_words_content )
$error_string .= 'The article is too short<br/>';
if ( str_word_count( $stripped_content, 0, $chars ) > $max_words_content )
$error_string .= 'The article is too long<br/>';
if ( !empty($content['about_the_author']) && $stripped_bio != -1 && str_word_count( $stripped_bio, 0, $chars ) < $min_words_bio )
$error_string .= 'The bio is too short<br/>';
if ( $stripped_bio != -1 && str_word_count( $stripped_bio, 0, $chars ) > $max_words_bio )
$error_string .= 'The bio is too long<br/>';
if ( substr_count( $content['post_content'], '</a>' ) > $max_links )
$error_string .= 'There are too many links in the article body<br/>';
if ( substr_count( $content['about_the_author'], '</a>' ) > $max_links_bio )
$error_string .= 'There are too many links in the bio<br/>';
if ( !empty( $content['post_tags'] ) && count($tags_array) < $min_tags )
$error_string .= 'You haven\'t added the required number of tags<br/>';
if ( count($tags_array) > $max_tags )
$error_string .= 'There are too many tags<br/>';
if ( $thumb_required == 'true' && $content['featured_img'] == -1 )
$error_string .= 'You need to choose a featured image<br/>';
Hope this can be implemented in next release.
That’s great. Such a simple solution. I’ll try to find a way to make this a part of the next release. Thanks.
Thread Starter
pehog
(@pehog)
One small addition to The charset. Now will be suitable for all cyrillic languages.
$chars = 'абвгдежзийклмнопрстуфхцчшщъьюяыёэАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЮЯЫЁЭ';