コード例 #1
0
ファイル: akismet.php プロジェクト: zoran180/natashazindrou
function wpcf7_akismet_comment_check($comment)
{
    global $akismet_api_host, $akismet_api_port;
    $spam = false;
    $query_string = wpcf7_build_query($comment);
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'comment-check');
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    if ('true' == $response[1]) {
        $spam = true;
    }
    if ($submission = WPCF7_Submission::get_instance()) {
        $submission->akismet = array('comment' => $comment, 'spam' => $spam);
    }
    return apply_filters('wpcf7_akismet_comment_check', $spam, $comment);
}
コード例 #2
0
function wpcf7_build_query($args, $key = '')
{
    $sep = '&';
    $ret = array();
    foreach ((array) $args as $k => $v) {
        $k = urlencode($k);
        if (!empty($key)) {
            $k = $key . '%5B' . $k . '%5D';
        }
        if (null === $v) {
            continue;
        } elseif (false === $v) {
            $v = '0';
        }
        if (is_array($v) || is_object($v)) {
            array_push($ret, wpcf7_build_query($v, $k));
        } else {
            array_push($ret, $k . '=' . urlencode($v));
        }
    }
    return implode($sep, $ret);
}