[ "apiKey" => "RoyansiaStaysAPIAvailabilityPrices1233402155" ] ]; if (!empty($additional_data)) { $body = array_merge($body, $additional_data); } $args = [ 'method' => 'POST', 'headers' => ['Content-Type' => 'application/json'], 'body' => json_encode($body), 'timeout' => 30 ]; $response = wp_remote_post($url, $args); if (is_wp_error($response)) return []; return json_decode(wp_remote_retrieve_body($response), true); } /** * Shortcode to display properties in a clean layout * Usage: [beds24_apartments] */ add_shortcode('beds24_apartments', function() { $data = beds24_api_request('getProperties'); if (empty($data['getProperties'])) { return "No apartments found. Check your Beds24 dashboard."; } // Modern CSS Grid for the UI $output = '
'; foreach ($data['getProperties'] as $property) { $name = $property['name']; $city = $property['city']; $propId = $property['propId']; // HTML Structure for each property card $output .= '
🏠

' . esc_html($name) . '

📍 ' . esc_html($city) . ', Morocco

● Available Book Now
'; } $output .= '
'; return $output; } );