wpcf7_akismet()
Хуки из функции
Возвращает
null. Ничего (null).
Использование
wpcf7_akismet( $spam, $submission );
- $spam(обязательный)
- .
- $submission(обязательный)
- .
Код wpcf7_akismet() wpcf7 akismet CF7 6.1.6
function wpcf7_akismet( $spam, $submission ) {
if ( $spam ) {
return $spam;
}
if ( ! wpcf7_akismet_is_available() ) {
return false;
}
if ( ! $params = wpcf7_akismet_submitted_params() ) {
return false;
}
$comment = array(
'comment_type' => 'contact-form',
'comment_author' => $params['author'],
'comment_author_email' => $params['author_email'],
'comment_author_url' => $params['author_url'],
'comment_content' => $params['content'],
'blog' => home_url(),
'blog_lang' => get_locale(),
'blog_charset' => get_option( 'blog_charset' ),
'user_ip' => $submission->get_meta( 'remote_ip' ),
'user_agent' => $submission->get_meta( 'user_agent' ),
'referrer' => wpcf7_superglobal_server( 'HTTP_REFERER' ),
);
$datetime = date_create_immutable(
'@' . $submission->get_meta( 'timestamp' )
);
if ( $datetime ) {
$comment['comment_date_gmt'] = $datetime->format( DATE_ATOM );
}
if ( $permalink = get_permalink() ) {
$comment['permalink'] = $permalink;
}
$server_vars = array_diff_key(
$_SERVER,
array_flip( array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) )
);
$comment = array_merge( $comment, $server_vars );
$comment = apply_filters( 'wpcf7_akismet_parameters', $comment );
if ( wpcf7_akismet_comment_check( $comment ) ) {
$spam = true;
$submission->add_spam_log( array(
'agent' => 'akismet',
'reason' => __( 'Akismet returns a spam response.', 'contact-form-7' ),
) );
} else {
$spam = false;
}
return $spam;
}