#VERITA' PER ANGELO VASSALLO
ULTIMO AGGIORNAMENTO : 27 Agosto 2025 - 18:01
30.1 C
Napoli
HomeTagsSiena

Siena

Ingerisce una pila: muore bimba di 18 mesi

Siena. Sarà l'inchiesta della magistratura a stabilire eventuali responsabilità mediche per la morte di una bambina di un anno e mezzo, vittima di un incidente domestico dalle conseguenze devastanti. La piccola, di origine straniera ma da tempo residente nel senese, ha ingerito accidentalmente una pila. La vicenda ha inizio martedì...
PUBBLICITA
PUBBLICITA
PUBBLICITA
PUBBLICITA
PUBBLICITA
PUBBLICITA
Ultime Notizie

Articolo pubblicato da Web Master il giorno 3 Giugno 2022 - 15:32
'boolean', 'sanitize_callback' => [__CLASS__, 'sanitize_bool'], 'default' => false] ); add_settings_section( 'hfi_main_section', 'Home Featured Image Sync', function(){ echo '

Usa l’immagine in evidenza dell’ultimo articolo come immagine della homepage. Qui sotto puoi attivare la funzione e vedere l’anteprima.

'; }, 'hfi_settings_page' ); add_settings_field( 'hfi_enable_field', 'Attiva per Homepage', [__CLASS__, 'render_enable_field'], 'hfi_settings_page', 'hfi_main_section' ); add_settings_field( 'hfi_preview_field', 'Anteprima immagine rilevata', [__CLASS__, 'render_preview_field'], 'hfi_settings_page', 'hfi_main_section' ); } public static function add_settings_page() { add_options_page( 'Home Featured Image Sync', 'Home Featured Image Sync', 'manage_options', 'hfi-settings', [__CLASS__, 'render_settings_page'] ); } public static function render_settings_page() { if ( ! current_user_can('manage_options') ) return; ?>

Home Featured Image Sync

Nessuna immagine in evidenza trovata tra gli ultimi articoli.

'; return; } ?>
<?php echo esc_attr($data['alt']); ?>

Articolo:

ALT:

Didascalia: (nessuna)'; ?>

ID Allegato:

Dimensione:

', esc_url($src), esc_attr($alt) ); if ( $caption ) { $img_html = '
'.$img_html.'
'.esc_html($caption).'
'; } // Aggiungi una classe per styling $wrap = '
'.$img_html.'
'; return $wrap; } /* ========================= * CORE LOGIC * =======================*/ /** * Recupera dati immagine dell’ultimo post pubblicato con immagine in evidenza. * Ritorna array: attachment_id, post_id, src, alt, caption, size */ public static function get_latest_thumb_data() { $cached = get_transient(self::TRANSIENT_KEY); if ( is_array($cached) && ! empty($cached['src']) ) { return $cached; } // Cerca l’ultimo post pubblicato con thumbnail $q = new WP_Query([ 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'ignore_sticky_posts' => true, 'meta_query' => [ [ 'key' => '_thumbnail_id', 'compare' => 'EXISTS', ] ] ]); if ( ! $q->have_posts() ) return null; $q->the_post(); $post_id = get_the_ID(); $attachment_id = get_post_thumbnail_id($post_id); wp_reset_postdata(); if ( ! $attachment_id ) return null; // Scegli una size sensata per homepage; useremo 'large' come default $size = 'large'; $img = wp_get_attachment_image_src( $attachment_id, $size ); if ( ! $img ) return null; $src = $img[0]; // ALT dall’allegato $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); if ( ! $alt ) { // fallback: titolo allegato $alt = get_the_title( $attachment_id ); } // Didascalia = excerpt dell’allegato $caption = get_post_field( 'post_excerpt', $attachment_id ); $data = [ 'attachment_id' => (int) $attachment_id, 'post_id' => (int) $post_id, 'src' => $src, 'alt' => is_string($alt) ? $alt : '', 'caption' => is_string($caption) ? $caption : '', 'size' => $size, ]; // Cache 5 minuti set_transient( self::TRANSIENT_KEY, $data, 5 * MINUTE_IN_SECONDS ); return $data; } public static function flush_cache_on_change( $post_id ) { // Invalida la cache quando cambia qualcosa nei post delete_transient( self::TRANSIENT_KEY ); } public static function flush_cache_on_status_change( $new_status, $old_status, $post ) { if ( $new_status !== $old_status ) { delete_transient( self::TRANSIENT_KEY ); } } } HFI_Home_Featured_Image_Sync::init(); /* ========================= * SHORTCODE (opzionale) * =======================*/ /** * Se il tema NON richiama the_post_thumbnail() in homepage, * puoi inserire manualmente l’immagine con lo shortcode [home_featured_image]. */ add_shortcode('home_featured_image', function( $atts ){ $enabled = get_option(HFI_Home_Featured_Image_Sync::OPTION_ENABLE, false); if ( ! $enabled ) return ''; if ( ! ( is_front_page() || is_home() ) ) return ''; $data = HFI_Home_Featured_Image_Sync::get_latest_thumb_data(); if ( ! $data ) return ''; $img = sprintf( '%s', esc_url($data['src']), esc_attr($data['alt']) ); if ( $data['caption'] ) { $img = '
'.$img.'
'.esc_html($data['caption']).'
'; } return '
'.$img.'
'; });