Finales felices (con revisión) y apadrinamiento, preparados y ocultos

- 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>
This commit is contained in:
2026-09-25 10:30:53 +02:00
parent fac5e6035c
commit 1ad21c1b08
12 changed files with 293 additions and 23 deletions

View File

@@ -409,11 +409,26 @@ function ga_customizer_registry() {
'eyebrow' => $t( 'Antetítulo', 'Ya están en casa', 'Etxean daude jada' ),
'title' => $t( 'Título', 'Finales felices', 'Amaiera zoriontsuak' ),
'text' => $t( 'Texto', 'Gracias por formar parte de sus segundas oportunidades.', 'Eskerrik asko haien bigarren aukeren parte izateagatik.', 'textarea' ),
'count' => array( 'type' => 'number', 'label' => 'Número de animales', 'default' => 8, 'min' => 1, 'max' => 24 ),
'count' => array( 'type' => 'number', 'label' => 'Número de historias o animales', 'default' => 8, 'min' => 1, 'max' => 24 ),
'view' => array( 'type' => 'select', 'label' => 'Presentación', 'default' => 'carrusel', 'choices' => array(
'carrusel' => 'Carrusel (se desliza)',
'rejilla' => 'Rejilla',
) ),
'button' => $t( 'Botón para enviar historias (vacío = ocultar)', 'Cuéntanos vuestra historia', 'Kontaiguzu zuen istorioa' ),
),
),
'sponsor' => array(
'panel' => 'ga_home',
'title' => 'Apadrina',
'section' => true,
'hidden' => true,
'description' => 'Muestra los animales marcados como «Busca padrino o madrina».',
'fields' => array(
'eyebrow' => $t( 'Antetítulo', 'Apadrina', 'Apadrinatu' ),
'title' => $t( 'Título', 'Acompáñales *mientras esperan*', 'Lagun egiozu *itxaroten duten bitartean*' ),
'text' => $t( 'Texto', 'Algunos llevan mucho tiempo con nosotras. Si no puedes adoptar, puedes apadrinar a uno de ellos. Escríbenos y te contamos cómo.', 'Batzuk denbora luzea daramate gurekin. Ezin baduzu adoptatu, haietako bat apadrinatu dezakezu. Idatzi iezaguzu eta nola kontatuko dizugu.', 'textarea' ),
'button' => $t( 'Botón', 'Quiero apadrinar', 'Apadrinatu nahi dut' ),
'count' => array( 'type' => 'number', 'label' => 'Número de animales', 'default' => 4, 'min' => 1, 'max' => 12 ),
),
),
'intake' => array(

View File

@@ -550,6 +550,15 @@ body { overflow-x: clip; }
.ga-animal__photo { position: static; }
}
/* Finales felices */
.ga-story { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--ga-line); border-radius: var(--ga-radius); overflow: hidden; }
.ga-story__img { aspect-ratio: 4/3; background: var(--ga-green-soft); }
.ga-story__img img { width: 100%; height: 100%; object-fit: cover; }
.ga-story__body { margin: 0; padding: 18px 20px 20px; font-size: .98rem; flex: 1; display: flex; flex-direction: column; }
.ga-story__body p::before { content: "“"; font: 800 2rem/0 var(--ga-serif); color: var(--ga-red); vertical-align: -.35em; margin-right: 2px; }
.ga-story__body footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--ga-line); color: var(--ga-muted); font-size: .9rem; }
.ga-story__body footer strong { font-family: var(--ga-serif); color: var(--ga-green-dark); }
/* Pestañas Perros / Gatos */
.ga-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.ga-tab { padding: 11px 26px; border-radius: 999px; border: 2px solid var(--ga-green); color: var(--ga-green); font-weight: 700; text-decoration: none; font-size: 1.05rem; }

View File

@@ -0,0 +1,15 @@
<?php
$html = do_shortcode( sprintf( '[ga_animales numero="%d" apadrinables="1"]', max( 1, (int) ga_opt( 'sponsor', 'count' ) ) ) );
if ( false !== strpos( $html, 'ga-empty' ) ) {
return; // Nadie marcado como «Busca padrino o madrina».
}
$button = ga_opt( 'sponsor', 'button' )
? sprintf( '<a class="ga-btn ga-btn--primary" href="%s">%s</a>', esc_url( add_query_arg( 'motivo', 'apadrinar', ga_page_url( 'contacto' ) ) . '#formulario' ), esc_html( ga_opt( 'sponsor', 'button' ) ) )
: '';
?>
<section class="ga-section ga-section--sand" id="apadrina">
<div class="ga-wrap">
<?php ga_section_head( 'sponsor', array( 'extra' => $button ) ); ?>
<?php echo $html; // Generado por el shortcode (escapado). ?>
</div>
</section>

View File

@@ -1,25 +1,40 @@
<?php
/* Últimos animales adoptados: se oculta si todavía no hay ninguno. */
$adopted = ga_query_animals( array(
'numero' => max( 1, (int) ga_opt( 'stories', 'count' ) ),
'estado' => 'adoptado',
) );
if ( ! $adopted->have_posts() ) {
/*
* 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( 'center' => true ) ); ?>
<?php
$carousel = 'carrusel' === ga_opt( 'stories', 'view' );
$carousel ? ga_carousel_open( ga_opt( 'stories', 'title' ) ) : print( '<div class="ga-grid">' );
while ( $adopted->have_posts() ) :
$adopted->the_post();
get_template_part( 'template-parts/animal-card' );
endwhile;
wp_reset_postdata();
$carousel ? ga_carousel_close() : print( '</div>' );
?>
<?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>