WPCF7_Mail::attachments()privateCF7 1.0

Creates an array of attachments based on uploaded files and local files.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->attachments( $template );
$template **
-
По умолчанию: null

Код WPCF7_Mail::attachments() CF7 5.9.3

private function attachments( $template = null ) {
	if ( ! $template ) {
		$template = $this->get( 'attachments' );
	}

	$attachments = array();

	if ( $submission = WPCF7_Submission::get_instance() ) {
		$uploaded_files = $submission->uploaded_files();

		foreach ( (array) $uploaded_files as $name => $paths ) {
			if ( false !== strpos( $template, "[{$name}]" ) ) {
				$attachments = array_merge( $attachments, (array) $paths );
			}
		}
	}

	foreach ( explode( "\n", $template ) as $line ) {
		$line = trim( $line );

		if ( '' === $line or '[' == substr( $line, 0, 1 ) ) {
			continue;
		}

		$attachments[] = path_join( WP_CONTENT_DIR, $line );
	}

	if ( $submission = WPCF7_Submission::get_instance() ) {
		$attachments = array_merge(
			$attachments,
			(array) $submission->extra_attachments( $this->name )
		);
	}

	return $attachments;
}