Grunion_Contact_Form_Plugin::prepare_for_akismet PHP Method

prepare_for_akismet() public method

Note that this includes the current user_ip etc, so this should only be called when accepting a new item via $_POST
public prepare_for_akismet ( array $form ) : array
$form array Contact form feedback array
return array feedback array with additional data ready for submission to Akismet
    function prepare_for_akismet($form)
    {
        $form['comment_type'] = 'contact_form';
        $form['user_ip'] = $_SERVER['REMOTE_ADDR'];
        $form['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
        $form['referrer'] = $_SERVER['HTTP_REFERER'];
        $form['blog'] = get_option('home');
        foreach ($_SERVER as $key => $value) {
            if (!is_string($value)) {
                continue;
            }
            if (in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'HTTP_USER_AGENT', 'HTTP_REFERER'))) {
                // We don't care about cookies, and the UA and Referrer were caught above.
                continue;
            } elseif (in_array($key, array('REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI'))) {
                // All three of these are relevant indicators and should be passed along.
                $form[$key] = $value;
            } elseif (wp_startswith($key, 'HTTP_')) {
                // Any other HTTP header indicators.
                // `wp_startswith()` is a wpcom helper function and is included in Jetpack via `functions.compat.php`
                $form[$key] = $value;
            }
        }
        return $form;
    }