diff --git a/includes/CMB2_Field.php b/includes/CMB2_Field.php index ea6617820..73e792a1e 100644 --- a/includes/CMB2_Field.php +++ b/includes/CMB2_Field.php @@ -1517,6 +1517,7 @@ protected function get_default_field_args( $args ) { 'char_counter' => false, 'char_max' => false, 'char_max_msg' => __( 'Your text may be truncated.', 'cmb2' ), + 'char_max_enforce' => false ); } diff --git a/includes/types/CMB2_Type_Textarea.php b/includes/types/CMB2_Type_Textarea.php index 1e0e8d865..d6df00945 100644 --- a/includes/types/CMB2_Type_Textarea.php +++ b/includes/types/CMB2_Type_Textarea.php @@ -39,6 +39,11 @@ public function render( $args = array() ) { $a['class'] .= ' cmb2-count-chars'; endif; + // Enforce max chars? + if ( ! empty( $this->field->args['char_max_enforce'] ) && ! empty( $this->field->args['char_max'] ) ) : + $a['maxlength'] = (int) $this->field->args['char_max']; + endif; + return $this->rendered( sprintf( '%s%s%s', $this->concat_attrs( $a, array( 'desc', 'value' ) ), $a['value'], $char_counter_markup, $a['desc'] ) ); diff --git a/languages/cmb2.pot b/languages/cmb2.pot index a089bd2f2..c597ef52c 100644 --- a/languages/cmb2.pot +++ b/languages/cmb2.pot @@ -4,11 +4,11 @@ msgid "" msgstr "" "Project-Id-Version: CMB2 2.6.0\n" "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/cmb2\n" -"POT-Creation-Date: 2019-04-17 07:10:30+00:00\n" +"POT-Creation-Date: 2019-04-17 09:50:14+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2019-4-17 7:10+-60\n" +"PO-Revision-Date: 2019-4-17 9:50+-60\n" "Last-Translator: CMB2 Team hello@cmb2.io\n" "Language-Team: CMB2 Team hello@cmb2.io\n" "X-Generator: grunt-wp-i18n 0.4.9\n" @@ -411,7 +411,7 @@ msgstr "" msgid "Your text may be truncated." msgstr "" -#: includes/CMB2_Field.php:1566 +#: includes/CMB2_Field.php:1567 msgid "Sorry, this field does not have a cmb_id specified." msgstr ""