WPCF7_Submission::spam()privateCF7 1.0

Executes spam protections.

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

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

Возвращает

true|false. True if spam captured.

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

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

Код WPCF7_Submission::spam() CF7 5.9.3

private function spam() {
	$spam = false;

	$skip_spam_check = apply_filters( 'wpcf7_skip_spam_check',
		$this->skip_spam_check,
		$this
	);

	if ( $skip_spam_check ) {
		return $spam;
	}

	if ( $this->contact_form->is_true( 'subscribers_only' )
	and current_user_can( 'wpcf7_submit', $this->contact_form->id() ) ) {
		return $spam;
	}

	$user_agent = (string) $this->get_meta( 'user_agent' );

	if ( strlen( $user_agent ) < 2 ) {
		$spam = true;

		$this->add_spam_log( array(
			'agent' => 'wpcf7',
			'reason' => __( "User-Agent string is unnaturally short.", 'contact-form-7' ),
		) );
	}

	if ( ! $this->verify_nonce() ) {
		$spam = true;

		$this->add_spam_log( array(
			'agent' => 'wpcf7',
			'reason' => __( "Submitted nonce is invalid.", 'contact-form-7' ),
		) );
	}

	return apply_filters( 'wpcf7_spam', $spam, $this );
}