From d7a17a2aca1b4aaaf3a1796443733677c8f0d07f Mon Sep 17 00:00:00 2001 From: Josep Piguillem Date: Fri, 25 Sep 2026 10:32:29 +0200 Subject: [PATCH] =?UTF-8?q?Cuestionario=20de=20adopci=C3=B3n=20online=20y?= =?UTF-8?q?=20hueco=20para=20el=20aviso=20de=20nuevos=20animales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [ga_cuestionario]: preguntas editables en ES/EU (Personalizar), borrador guardado en el navegador, envío a Mensajes y por correo. Páginas «Cuestionario de adopción / Adopzio-galdetegia» fuera del menú y con noindex; admite ?adoptar=ID. - Pie: formulario de suscripción de MailPoet cuando se configure su shortcode. Co-Authored-By: Claude Opus 5.5 --- docker/content/es/cuestionario-adopcion.html | 7 + docker/content/eu/adopzio-galdetegia.html | 7 + docker/setup-content.php | 1 + wp-content/mu-plugins/gure-ametsa-core.php | 1 + .../mu-plugins/gure-ametsa/questionnaire.php | 124 ++++++++++++++++++ .../themes/gure-ametsa/assets/js/main.js | 22 ++++ wp-content/themes/gure-ametsa/footer.php | 7 + .../themes/gure-ametsa/inc/registry.php | 13 ++ wp-content/themes/gure-ametsa/style.css | 6 + 9 files changed, 188 insertions(+) create mode 100644 docker/content/es/cuestionario-adopcion.html create mode 100644 docker/content/eu/adopzio-galdetegia.html create mode 100644 wp-content/mu-plugins/gure-ametsa/questionnaire.php diff --git a/docker/content/es/cuestionario-adopcion.html b/docker/content/es/cuestionario-adopcion.html new file mode 100644 index 0000000..3b7a942 --- /dev/null +++ b/docker/content/es/cuestionario-adopcion.html @@ -0,0 +1,7 @@ + +

Gracias por querer conocernos. Estas preguntas nos ayudan a saber cómo es tu día a día y a encontrar juntos al compañero que mejor encaje contigo. No hay respuestas buenas o malas: cuéntanoslo con naturalidad.

+ + + +[ga_cuestionario] + diff --git a/docker/content/eu/adopzio-galdetegia.html b/docker/content/eu/adopzio-galdetegia.html new file mode 100644 index 0000000..a78a768 --- /dev/null +++ b/docker/content/eu/adopzio-galdetegia.html @@ -0,0 +1,7 @@ + +

Eskerrik asko gu ezagutu nahi izateagatik. Galdera hauek zure eguneroko bizitza nolakoa den jakiten eta zurekin hobekien bat datorren laguna elkarrekin aurkitzen laguntzen digute. Ez dago erantzun onik edo txarrik: kontaiguzu naturaltasunez.

+ + + +[ga_cuestionario] + diff --git a/docker/setup-content.php b/docker/setup-content.php index 3a46b35..95fe2ae 100644 --- a/docker/setup-content.php +++ b/docker/setup-content.php @@ -120,6 +120,7 @@ $pages = array( 'quienes-somos' => array( 'Quiénes somos', 'nor-gara', 'Nor gara' ), 'contacto' => array( 'Contacto', 'harremanetarako', 'Harremanetarako' ), 'preguntas-frecuentes' => array( 'Preguntas frecuentes', 'ohiko-galderak', 'Ohiko galderak' ), + 'cuestionario-adopcion' => array( 'Cuestionario de adopción', 'adopzio-galdetegia', 'Adopzio-galdetegia' ), 'politica-de-privacidad' => array( 'Política de privacidad', 'pribatutasun-politika', 'Pribatutasun-politika' ), 'aviso-legal' => array( 'Aviso legal', 'lege-oharra', 'Lege-oharra' ), ); diff --git a/wp-content/mu-plugins/gure-ametsa-core.php b/wp-content/mu-plugins/gure-ametsa-core.php index 299986b..2d12f83 100644 --- a/wp-content/mu-plugins/gure-ametsa-core.php +++ b/wp-content/mu-plugins/gure-ametsa-core.php @@ -16,3 +16,4 @@ require_once __DIR__ . '/gure-ametsa/admin.php'; require_once __DIR__ . '/gure-ametsa/share.php'; require_once __DIR__ . '/gure-ametsa/seo.php'; require_once __DIR__ . '/gure-ametsa/stories.php'; +require_once __DIR__ . '/gure-ametsa/questionnaire.php'; diff --git a/wp-content/mu-plugins/gure-ametsa/questionnaire.php b/wp-content/mu-plugins/gure-ametsa/questionnaire.php new file mode 100644 index 0000000..0641bde --- /dev/null +++ b/wp-content/mu-plugins/gure-ametsa/questionnaire.php @@ -0,0 +1,124 @@ +' . esc_html( ga_setting( 'cuestionario', 'confirm', '' ) ) . ''; + return ob_get_clean(); + } + if ( 'error' === $status ) { + echo ''; + } + ?> +
+ + + + + + +
+ +
+ + +
+
+ + +
+ +
+ +
+ + $question ) : ?> + + +
+ + +

+ +
+ 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; +} ); diff --git a/wp-content/themes/gure-ametsa/assets/js/main.js b/wp-content/themes/gure-ametsa/assets/js/main.js index 3a7c971..162e7e8 100644 --- a/wp-content/themes/gure-ametsa/assets/js/main.js +++ b/wp-content/themes/gure-ametsa/assets/js/main.js @@ -92,3 +92,25 @@ select.addEventListener( 'change', function () { field.hidden = select.value !== 'visita'; } ); } ); } )(); + +// Cuestionario: guarda el borrador en este navegador hasta que se envía. +( function () { + var done = document.querySelector( '[data-ga-clear-draft]' ); + try { + if ( done ) { Object.keys( localStorage ).filter( function ( k ) { return k.indexOf( 'ga-cuestionario-' ) === 0; } ).forEach( function ( k ) { localStorage.removeItem( k ); } ); } + } catch ( e ) {} + document.querySelectorAll( 'form[data-ga-draft]' ).forEach( function ( form ) { + var key = form.dataset.gaDraft, saved = {}; + try { saved = JSON.parse( localStorage.getItem( key ) || '{}' ); } catch ( e ) {} + Array.prototype.forEach.call( form.elements, function ( el ) { + if ( el.name && el.type !== 'hidden' && el.type !== 'checkbox' && saved[ el.name ] && ! el.value ) { el.value = saved[ el.name ]; } + } ); + form.addEventListener( 'input', function () { + var data = {}; + Array.prototype.forEach.call( form.elements, function ( el ) { + if ( el.name && el.type !== 'hidden' && el.type !== 'checkbox' && el.name !== 'web' ) { data[ el.name ] = el.value; } + } ); + try { localStorage.setItem( key, JSON.stringify( data ) ); } catch ( e ) {} + } ); + } ); +} )(); diff --git a/wp-content/themes/gure-ametsa/footer.php b/wp-content/themes/gure-ametsa/footer.php index 7cb1f2b..a58908f 100644 --- a/wp-content/themes/gure-ametsa/footer.php +++ b/wp-content/themes/gure-ametsa/footer.php @@ -61,6 +61,13 @@ $columns = array( + + + +