BlockStrap is a lightweight and minimalist WordPress theme that was built specifically to work seamlessly with the BlockStrap page builder plugin.
function fetch_google_places_nearby_data($location, $radius, $keyword) { $api_key = 'AIzaSyA6-rRQ2Hmph_SVzxsIaHUypsBZfOFBS1Q'; $url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=$location&radius=$radius&keyword=" . urlencode($keyword) . "&key=$api_key"; $response = wp_remote_get($url); if (is_wp_error($response)) { return 'Error fetching data'; } $data = wp_remote_retrieve_body($response); $decoded_data = json_decode($data, true); if (isset($decoded_data['results']) && !empty($decoded_data['results'])) { return $decoded_data['results']; } else { return 'No data found'; } } function display_google_places_nearby_data_shortcode($atts) { $atts = shortcode_atts(array( 'location' => '47.6062,-122.3321', // Latitude and longitude for Seattle, WA 'radius' => '5000', // Radius in meters (5km) 'keyword' => 'business', // Keyword to search ), $atts); $places_data = fetch_google_places_nearby_data($atts['location'], $atts['radius'], $atts['keyword']); if (is_string($places_data)) { return $places_data; } // Format output $output = '
Address: ' . esc_html($place['vicinity']) . '
'; $output .= 'Rating: ' . (isset($place['rating']) ? esc_html($place['rating']) : 'N/A') . '
'; if (isset($place['photos'][0]['photo_reference'])) { $photo_url = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=" . $place['photos'][0]['photo_reference'] . "&key=$api_key"; $output .= ''; } $output .= 'BlockStrap is a lightweight and minimalist WordPress theme that was built specifically to work seamlessly with the BlockStrap page builder plugin.