' . esc_html( ga_setting( 'cuestionario', 'confirm', '' ) ) . '';
return ob_get_clean();
}
if ( 'error' === $status ) {
echo '
' . esc_html( ga__( 'Falta algún dato obligatorio. Revisa el formulario: lo que habías escrito se ha guardado.', 'Derrigorrezko daturen bat falta da. Berrikusi formularioa: idatzitakoa gorde da.' ) ) . '
';
}
?>
sanitize_textarea_field( wp_unslash( $a ) ), (array) ( $_POST['respuestas'] ?? array() ) );
$data = array(
'nombre' => sanitize_text_field( wp_unslash( $_POST['nombre'] ?? '' ) ),
'email' => sanitize_email( wp_unslash( $_POST['email'] ?? '' ) ),
'telefono' => sanitize_text_field( wp_unslash( $_POST['telefono'] ?? '' ) ),
'localidad' => sanitize_text_field( wp_unslash( $_POST['localidad'] ?? '' ) ),
'animal' => sanitize_text_field( wp_unslash( $_POST['animal'] ?? '' ) ),
);
if ( ! $data['nombre'] || ! is_email( $data['email'] ) || ! $data['telefono'] || empty( $_POST['privacidad'] ) ) {
$go( 'error' );
}
foreach ( array_keys( $questions ) as $i ) {
if ( '' === trim( $answers[ $i ] ?? '' ) ) {
$go( 'error' );
}
}
$subject = sprintf( '[Web] Cuestionario de adopción – %s%s', $data['nombre'], $data['animal'] ? ' (' . $data['animal'] . ')' : '' );
$body = sprintf(
"Nombre: %s\nEmail: %s\nTeléfono: %s\nLocalidad: %s\nAnimal: %s\nIdioma: %s\n",
$data['nombre'], $data['email'], $data['telefono'], $data['localidad'] ?: '-', $data['animal'] ?: '-', 'eu' === $lang ? 'Euskera' : 'Castellano'
);
foreach ( $questions as $i => $question ) {
$body .= "\n" . $question . "\n" . ( $answers[ $i ] ?? '' ) . "\n";
}
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' );
}
/* La página del cuestionario no aparece en buscadores (el enlace lo envía el equipo). */
add_filter( 'wp_robots', function ( $robots ) {
if ( is_page( array( 'cuestionario-adopcion', 'adopzio-galdetegia' ) ) ) {
$robots['noindex'] = true;
$robots['nofollow'] = true;
}
return $robots;
} );