add_shortcode('pagespeed_status', function() {

    // Google Sheet settings
    $sheet_id = '1yv3q6yltFck4pwnCW6s2nI1BB6_bTYoxXUreeWMEfU4';
    $sheet_name = 'Sheet1';
    $cell = 'H5';

    // Google visualization API URL
    $url = "https://docs.google.com/spreadsheets/d/$sheet_id/gviz/tq?tqx=out:csv&sheet=$sheet_name&range=$cell";

    $response = wp_remote_get($url, array('timeout' => 5));

    if (is_wp_error($response)) {
        return 'PageSpeed data unavailable';
    }

    $body = wp_remote_retrieve_body($response);

    // Clean CSV output
    $value = trim(str_replace('"', '', $body));

    return '<div class="pagespeed-box">' . esc_html($value) . '</div>';
});
