Exemple #1
0
function stats_update_blog()
{
    Jetpack::xmlrpc_async_call('jetpack.updateBlog', stats_get_blog());
}
Exemple #2
0
function stats_get_blog_id($api_key)
{
    $options = stats_get_options();
    require_once ABSPATH . WPINC . '/class-IXR.php';
    $client = new IXR_Client(STATS_XMLRPC_SERVER);
    extract(parse_url(get_option('home')));
    $path = rtrim($path, '/');
    if (empty($path)) {
        $path = '/';
    }
    $client->query('wpStats.get_blog_id', $api_key, stats_get_blog());
    if ($client->isError()) {
        if ($client->getErrorCode() == -32300) {
            $options['error'] = __('Your blog was unable to connect to WordPress.com. Please ask your host for help. (' . $client->getErrorMessage() . ')', 'stats');
        } else {
            $options['error'] = $client->getErrorMessage();
        }
        stats_set_options($options);
        return false;
    } else {
        $options['error'] = false;
    }
    $response = $client->getResponse();
    $blog_id = isset($response['blog_id']) ? (int) $response['blog_id'] : false;
    $options['host'] = $host;
    $options['path'] = $path;
    $options['blog_id'] = $blog_id;
    stats_set_options($options);
    stats_set_api_key($api_key);
    return $blog_id;
}