WPCF7_SWV_MaxFileSizeRule::validate()publicCF7 1.0

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

Хуков нет.

Возвращает

null. Ничего.

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

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

Код WPCF7_SWV_MaxFileSizeRule::validate() CF7 5.7.5.1

public function validate( $context ) {
	$field = $this->get_property( 'field' );
	$input = isset( $_FILES[$field]['size'] ) ? $_FILES[$field]['size'] : '';
	$input = wpcf7_array_flatten( $input );
	$input = wpcf7_exclude_blank( $input );

	if ( empty( $input ) ) {
		return true;
	}

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

	if ( $threshold < array_sum( $input ) ) {
		return new WP_Error( 'wpcf7_invalid_maxfilesize',
			$this->get_property( 'error' )
		);
	}

	return true;
}