WPCF7_SWV_MaxLengthRule::validate()
Метод класса: WPCF7_SWV_MaxLengthRule{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$WPCF7_SWV_MaxLengthRule = new WPCF7_SWV_MaxLengthRule(); $WPCF7_SWV_MaxLengthRule->validate( $context );
- $context (обязательный)
- -
Код WPCF7_SWV_MaxLengthRule::validate() WPCF7 SWV MaxLengthRule::validate CF7 5.7.5.1
public function validate( $context ) { $field = $this->get_property( 'field' ); $input = isset( $_POST[$field] ) ? $_POST[$field] : ''; $input = wpcf7_array_flatten( $input ); $input = wpcf7_exclude_blank( $input ); if ( empty( $input ) ) { return true; } $total = 0; foreach ( $input as $i ) { $total += wpcf7_count_code_units( $i ); } $threshold = (int) $this->get_property( 'threshold' ); if ( $total <= $threshold ) { return true; } else { return new WP_Error( 'wpcf7_invalid_maxlength', $this->get_property( 'error' ) ); } }