ga__( 'Adopción', 'Adopzioa' ), 'acogida' => ga__( 'Casa de acogida', 'Harrera-etxea' ), 'voluntario' => ga__( 'Voluntariado', 'Boluntariotza' ), 'material' => ga__( 'Ayuda material', 'Laguntza materiala' ), 'otro' => ga__( 'Otro', 'Beste bat' ), ); } /** Texto de confirmación tras enviar. */ function ga_confirmation_text( $is_animal ) { return $is_animal ? ga_setting( 'adopcion', 'confirm', ga__( 'Hemos recibido tu solicitud. Nos pondremos en contacto contigo para enviarte nuestro cuestionario y conoceros un poquito mejor.', 'Zure eskaera jaso dugu. Zurekin harremanetan jarriko gara gure galdetegia bidaltzeko eta elkar hobeto ezagutzeko.' ) ) : ga_setting( 'adopcion', 'confirm_contact', ga__( '¡Gracias! Hemos recibido tu mensaje y te responderemos lo antes posible.', 'Eskerrik asko! Zure mezua jaso dugu eta ahalik eta lasterren erantzungo dizugu.' ) ); } /** * [ga_contacto] formulario general. * [ga_contacto animal="123"] formulario breve «Quiero conocerlo/la» (el animal va incluido). */ add_shortcode( 'ga_contacto', function ( $atts ) { $atts = shortcode_atts( array( 'animal' => 0 ), $atts, 'ga_contacto' ); $animal_id = absint( $atts['animal'] ) ?: absint( $_GET['adoptar'] ?? 0 ); $animal_id = $animal_id && 'animal' === get_post_type( $animal_id ) ? $animal_id : 0; $is_animal = absint( $atts['animal'] ) > 0; // Formulario breve dentro de la ficha. $status = sanitize_key( $_GET['enviado'] ?? '' ); $preselect = $animal_id ? 'adopcion' : sanitize_key( $_GET['motivo'] ?? '' ); $privacy = ga_page_url( 'politica-de-privacidad' ); $anchor = $is_animal ? 'conocer' : 'formulario'; ob_start(); if ( 'ok' === $status ) { echo '
' . esc_html( ga_confirmation_text( (bool) $animal_id ) ) . '
'; if ( $is_animal ) { return ob_get_clean(); } } elseif ( 'error' === $status ) { echo ''; } ?>

sanitize_text_field( wp_unslash( $_POST['nombre'] ?? '' ) ), 'email' => sanitize_email( wp_unslash( $_POST['email'] ?? '' ) ), 'telefono' => sanitize_text_field( wp_unslash( $_POST['telefono'] ?? '' ) ), 'motivo' => $reasons[ $reason ] ?? $reasons['otro'], 'mensaje' => sanitize_textarea_field( wp_unslash( $_POST['mensaje'] ?? '' ) ), 'idioma' => 'eu' === ( $_POST['idioma'] ?? '' ) ? 'Euskera' : 'Castellano', ); $message_required = ! $animal; if ( ! $data['nombre'] || ! is_email( $data['email'] ) || ( $message_required && ! $data['mensaje'] ) || empty( $_POST['privacidad'] ) ) { $go( 'error' ); } $subject = $animal ? sprintf( '[Web] Quiero conocer a %s – %s', $animal, $data['nombre'] ) : sprintf( '[Web] %s – %s', $data['motivo'], $data['nombre'] ); $body = sprintf( "Nombre: %s\nEmail: %s\nTeléfono: %s\nMotivo: %s\nAnimal: %s\nIdioma: %s\n\n%s", $data['nombre'], $data['email'], $data['telefono'] ?: '-', $data['motivo'], $animal ? $animal . ' — ' . get_permalink( $animal_id ) : '-', $data['idioma'], $data['mensaje'] ?: '(sin mensaje)' ); // Se guarda siempre en el panel, aunque falle el correo. wp_insert_post( array( 'post_type' => 'ga_mensaje', 'post_status' => 'private', 'post_title' => $subject, 'post_content' => $body, ) ); wp_mail( ga_contact_email(), $subject, $body, array( 'Reply-To: ' . $data['nombre'] . ' <' . $data['email'] . '>' ) ); $go( 'ok' ); } /* [ga_necesidades] lista de ayuda material (se edita en Personalizar → Colabora) */ add_shortcode( 'ga_necesidades', function () { $items = array_filter( array_map( 'trim', explode( "\n", (string) ga_setting( 'material', 'list', '' ) ) ) ); $note = ga_setting( 'material', 'note', '' ); ob_start(); if ( $items ) { echo ''; } if ( $note ) { echo '

' . esc_html( $note ) . '

'; } return ob_get_clean(); } ); /* [ga_cita] aviso de cita previa */ add_shortcode( 'ga_cita', function () { $text = ga_info( 'cita' ); return $text ? '

' . esc_html( $text ) . '

' : ''; } );