Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
function flight_details_shortcode( $atts ) { $atts = shortcode_atts( array( 'flight_number' => '', 'departure_date' => '' ), $atts, 'flight_details' ); $flight_number = strtoupper( $atts['flight_number'] ); $departure_date = $atts['departure_date']; $api_key = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiZGM3ZjI2ZDI4N2I2ZTU5ODI1NzU3YWVlYjNhOGYwYjc2ZjMxYTk1ODg1ZDFkMDY4ODU4NDEwMDNkMDhhMTFiYzY5MGI1N2MzYTJlOWE2MDEiLCJpYXQiOjE2ODAwMDgzMzgsIm5iZiI6MTY4MDAwODMzOCwiZXhwIjoxNzExNjMwNzM4LCJzdWIiOiIyMDU5OCIsInNjb3BlcyI6W119.a84bVI7mb_y8y4JlWVG-Lg72xChiWaADBLvjRo3TvRdD4lxaDaFXKjrBxMNOXp0PFiV5rmZp4fD9CmDP4iawHQ'; $api_url = "https://app.goflightlabs.com/flight?access_key=$api_key&flight_number=$flight_number&departure_date=$departure_date"; $response = wp_remote_get( $api_url ); if ( is_wp_error( $response ) ) { return 'There was an error retrieving flight details.'; } $body = wp_remote_retrieve_body( $response ); $data = json_decode( $body ); if ( empty( $data->data[0]->STATUS ) ) { return 'No flight details found for the provided flight number and date.'; } $flight_data = $data->data[0]; // Retrieve necessary details $flight_number = $flight_data->FLIGHT_NUMBER; $departing_from = $flight_data->FROM; $departing_country = substr($flight_data->FROM, -4, 3); $arriving_in = $flight_data->TO; $arriving_country = substr($flight_data->TO, -4, 3); // Format details into table $output = '
FLIGHT #: | ' . $flight_number . ' |
---|---|
DEPARTING FROM: | ' . $departing_from . ', ' . $departing_country . ' |
ARRIVING IN: | ' . $arriving_in . ', ' . $arriving_country . ' |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ut labore et dolore magna aliqua.
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.