Jetpack_Tracks_Client::record_pixel PHP Method

record_pixel() static public method

Synchronously request the pixel
static public record_pixel ( $pixel )
    static function record_pixel($pixel)
    {
        // Add the Request Timestamp and URL terminator just before the HTTP request.
        $pixel .= '&_rt=' . self::build_timestamp() . '&_=_';
        $response = wp_remote_get($pixel, array('blocking' => true, 'timeout' => 1, 'redirection' => 2, 'httpversion' => '1.1', 'user-agent' => self::get_user_agent()));
        if (is_wp_error($response)) {
            return $response;
        }
        $code = isset($response['response']['code']) ? $response['response']['code'] : 0;
        if ($code !== 200) {
            return new WP_Error('request_failed', 'Tracks pixel request failed', $code);
        }
        return true;
    }