WPCF7_Submission::unship_uploaded_files()privateCF7 1.0

Moves uploaded files to the tmp directory and validates them.

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

Хуки из метода

Возвращает

true|false. True if no invalid file is found.

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

// private - только в коде основоного (родительского) класса
$result = $this->unship_uploaded_files();

Код WPCF7_Submission::unship_uploaded_files() CF7 5.9.3

private function unship_uploaded_files() {
	$result = new WPCF7_Validation();

	$tags = $this->contact_form->scan_form_tags( array(
		'feature' => 'file-uploading',
	) );

	foreach ( $tags as $tag ) {
		if ( empty( $_FILES[$tag->name] ) ) {
			continue;
		}

		$file = $_FILES[$tag->name];

		$args = array(
			'tag' => $tag,
			'name' => $tag->name,
			'required' => $tag->is_required(),
			'filetypes' => $tag->get_option( 'filetypes' ),
			'limit' => $tag->get_limit_option(),
			'schema' => $this->contact_form->get_schema(),
		);

		$new_files = wpcf7_unship_uploaded_file( $file, $args );

		if ( is_wp_error( $new_files ) ) {
			$result->invalidate( $tag, $new_files );
		} else {
			$this->add_uploaded_file( $tag->name, $new_files );
		}

		$result = apply_filters(
			"wpcf7_validate_{$tag->type}",
			$result, $tag,
			array(
				'uploaded_files' => $new_files,
			)
		);
	}

	$this->invalid_fields = $result->get_invalid_fields();

	return $result->is_valid();
}