Cf7_Tokens::get_data_from_contact_form( WPCF7_ContactForm $contact_form )


Parameters Parameters

$contact_form

(WPCF7_ContactForm) (Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/contact-form7/tokens/cf7-tokens.php

	public function get_data_from_contact_form( WPCF7_ContactForm $contact_form ) {
		$data = array();
		if ( $contact_form instanceof WPCF7_ContactForm ) {
			$tags = $contact_form->scan_form_tags();

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

				$pipes = $tag->pipes;

				$value = ( ! empty( $_POST[ $tag->name ] ) ) ? Automator()->utilities->automator_sanitize( $_POST[ $tag->name ], 'mixed' ) : '';
				if ( WPCF7_USE_PIPE && $pipes instanceof WPCF7_Pipes && ! $pipes->zero() ) {
					if ( is_array( $value ) ) {
						$new_value = array();

						foreach ( $value as $v ) {
							$new_value[] = $pipes->do_pipe( wp_unslash( $v ) );
						}

						$value = $new_value;
					} else {
						$value = $pipes->do_pipe( wp_unslash( $value ) );
					}
				}

				$data[ $tag->name ] = $value;
			}

			return $data;
		}
	}