- fix counting words in a textarea field

This commit is contained in:
ashubawork
2023-07-24 12:31:11 +03:00
parent 3077085d30
commit 2ea7fb9e33
+3 -1
View File
@@ -573,7 +573,9 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
}
if ( isset( $array['max_words'] ) && $array['max_words'] > 0 ) {
if ( str_word_count( $submitted_data[ $key ], 0, "éèàôù" ) > $array['max_words'] ) {
// count words without html tags
$without_tags = wp_strip_all_tags( $submitted_data[ $key ] );
if ( str_word_count( $without_tags, 0, 'éèàôù' ) > $array['max_words'] ) {
// translators: %s: max words.
UM()->form()->add_error( $key, sprintf( __( 'You are only allowed to enter a maximum of %s words', 'ultimate-member' ), $array['max_words'] ) );
}