function yfe_youtube_feed_shortcode($atts) { $atts = shortcode_atts(array( 'channel_id' => 'UCayHfMnEuUUgBhfjyrTRG2g', // ID del canale YouTube 'max_results' => 5, // Numero massimo di video da mostrare ), $atts, 'youtube_feed'); $channel_id = esc_attr($atts['channel_id']); $max_results = intval($atts['max_results']); if (empty($channel_id)) { return '

Inserisci un ID canale YouTube valido.

'; } // Chiave per la cache $cache_key = 'yfe_youtube_feed_' . $channel_id; $cached_data = get_transient($cache_key); // Se i dati sono in cache, usali if ($cached_data) { $data = $cached_data; } else { // URL dell'API YouTube $api_key = 'AIzaSyDUmp3PKLcofUVcaGQxKUumeiPLxNKblqM'; // Sostituisci con la tua API Key di YouTube $url = "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={$channel_id}&maxResults={$max_results}&order=date&type=video&key={$api_key}"; // Ottieni i dati dall'API $response = wp_remote_get($url); if (is_wp_error($response)) { return '

Errore durante il recupero dei dati dal feed YouTube.

'; } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); // Salva i dati in cache per 12 ore set_transient($cache_key, $data, 12 * HOUR_IN_SECONDS); } // Verifica se ci sono video if (isset($data['items']) && !empty($data['items'])) { $output = '
'; foreach ($data['items'] as $item) { $video_id = $item['id']['videoId']; $title = $item['snippet']['title']; $thumbnail = $item['snippet']['thumbnails']['medium']['url']; $output .= '
'; $output .= ''; $output .= '' . esc_attr($title) . ''; $output .= ''; $output .= '

' . esc_html($title) . '

'; $output .= '
'; } $output .= '
'; return $output; } else { // Mostra eventuali errori API if (isset($data['error'])) { return '

Errore API: ' . esc_html($data['error']['message']) . '

'; } return '

Nessun video trovato per questo canale.

'; } } add_shortcode('youtube_feed', 'yfe_youtube_feed_shortcode'); Villarreal, ufficiale: preso Lo Celso dal Tottenham | CIP
Villarreal, ufficiale: preso Lo Celso dal Tottenham

(Photo by Marcelo Endelli/Getty Images)

[embed_video]

Colpaccio del Villarreal in questi ultimi minuti della sessione invernale di calciomercato. Il club spagnolo, pochi istanti fa, ha annunciato ufficialmente di aver acquistato il centrocampista Giovanni Lo Celso.

Lo Celso al Villarreal

Giovanni Lo Celso arriva al Villarreal dal Tottenham in prestito secco sino al prossimo mese di giugno. Gli Spurs dopo l’arrivo di Bentancur dalla Juventus avevano necessità di liberare spazio all’interno della propria rosa. Il classe 1996 dunque sfiderà proprio i bianconeri negli ottavi di finale di Champions League. Lo Celso in carriera, oltre a quella degli inglesi, ha vestito le maglie di Rosario Central, Paris Saint Germain e Betis Siviglia. Per lui ora una nuova avventura agli ordini del tecnico Unai Emery.