WPCF7_SWV_MaxDateRule::validate()publicCF7 1.0

Метод класса: WPCF7_SWV_MaxDateRule{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WPCF7_SWV_MaxDateRule = new WPCF7_SWV_MaxDateRule();
$WPCF7_SWV_MaxDateRule->validate( $context );
$context (обязательный)
-

Код WPCF7_SWV_MaxDateRule::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 );

	$threshold = $this->get_property( 'threshold' );

	if ( ! wpcf7_is_date( $threshold ) ) {
		return true;
	}

	foreach ( $input as $i ) {
		if ( wpcf7_is_date( $i ) and $threshold < $i ) {
			return new WP_Error( 'wpcf7_invalid_maxdate',
				$this->get_property( 'error' )
			);
		}
	}

	return true;
}