- Formulario [ga_final_feliz]: las familias envían texto y foto (solo imágenes reales ≤5 MB, límite de envíos, consentimiento de publicación). Queda pendiente hasta que el equipo la publica; aviso por correo y contador en el menú. - Sección «Finales felices»: historias aprobadas o, si no hay, los adoptados. - Casilla «Busca padrino o madrina», sección «Apadrina» y motivo de contacto (sin pagos). - Páginas «Finales felices / Amaiera zoriontsuak» creadas como borrador. - API: profile.sponsorable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.1 KiB
PHP
41 lines
2.1 KiB
PHP
<?php
|
|
/*
|
|
* Finales felices: las historias aprobadas (enviadas por las familias); si aún no hay,
|
|
* los últimos animales adoptados. Si no hay nada, la sección no aparece.
|
|
*/
|
|
$number = max( 1, (int) ga_opt( 'stories', 'count' ) );
|
|
$stories = function_exists( 'ga_query_stories' ) ? ga_query_stories( $number ) : null;
|
|
$adopted = ( $stories && $stories->have_posts() ) ? null : ga_query_animals( array( 'numero' => $number, 'estado' => 'adoptado' ) );
|
|
if ( ! ( $stories && $stories->have_posts() ) && ! $adopted->have_posts() ) {
|
|
return;
|
|
}
|
|
$form_page = get_page_by_path( 'finales-felices' );
|
|
$form_url = $form_page && 'publish' === $form_page->post_status ? ga_page_url( 'finales-felices' ) : '';
|
|
$button = $form_url && ga_opt( 'stories', 'button' )
|
|
? sprintf( '<a class="ga-btn ga-btn--outline" href="%s">%s</a>', esc_url( $form_url ), esc_html( ga_opt( 'stories', 'button' ) ) )
|
|
: '';
|
|
$carousel = 'carrusel' === ga_opt( 'stories', 'view' );
|
|
?>
|
|
<section class="ga-section">
|
|
<div class="ga-wrap">
|
|
<?php ga_section_head( 'stories', array( 'extra' => $button ) ); ?>
|
|
<?php $carousel ? ga_carousel_open( ga_opt( 'stories', 'title' ) ) : print( '<div class="ga-grid">' ); ?>
|
|
<?php if ( $stories && $stories->have_posts() ) : ?>
|
|
<?php while ( $stories->have_posts() ) : $stories->the_post(); ?>
|
|
<article class="ga-story">
|
|
<div class="ga-story__img">
|
|
<?php echo has_post_thumbnail() ? get_the_post_thumbnail( null, 'ga-card', array( 'loading' => 'lazy' ) ) : '<div class="ga-card__placeholder">' . ga_placeholder_svg() . '</div>'; ?>
|
|
</div>
|
|
<blockquote class="ga-story__body">
|
|
<p><?php echo esc_html( wp_strip_all_tags( get_the_content() ) ); ?></p>
|
|
<footer><strong><?php the_title(); ?></strong><?php $f = get_post_meta( get_the_ID(), '_ga_familia', true ); echo $f ? ' · ' . esc_html( $f ) : ''; ?></footer>
|
|
</blockquote>
|
|
</article>
|
|
<?php endwhile; ?>
|
|
<?php else : ?>
|
|
<?php while ( $adopted->have_posts() ) : $adopted->the_post(); get_template_part( 'template-parts/animal-card' ); endwhile; ?>
|
|
<?php endif; ?>
|
|
<?php wp_reset_postdata(); $carousel ? ga_carousel_close() : print( '</div>' ); ?>
|
|
</div>
|
|
</section>
|