SEO local, perdidos/encontrados y solicitud de cita
- Datos estructurados schema.org AnimalShelter en la portada (dirección, horario para Google configurable, teléfono, redes, idiomas). - Preguntas frecuentes: animales perdidos o encontrados, con el buscador oficial de Euskadi. - Formulario: motivo «Pedir cita para una visita» con día y hora preferidos. - Migración 6: actualiza las preguntas frecuentes si no se han editado. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ defined( 'ABSPATH' ) || exit;
|
||||
function ga_contact_reasons() {
|
||||
return array(
|
||||
'adopcion' => ga__( 'Adopción', 'Adopzioa' ),
|
||||
'visita' => ga__( 'Pedir cita para una visita', 'Bisita baterako hitzordua eskatu' ),
|
||||
'acogida' => ga__( 'Casa de acogida', 'Harrera-etxea' ),
|
||||
'voluntario' => ga__( 'Voluntariado', 'Boluntariotza' ),
|
||||
'material' => ga__( 'Ayuda material', 'Laguntza materiala' ),
|
||||
@@ -74,6 +75,11 @@ add_shortcode( 'ga_contacto', function ( $atts ) {
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ( ! $is_animal ) : ?>
|
||||
<label class="ga-form__visit"<?php echo 'visita' === $preselect ? '' : ' hidden'; ?>><?php ga_e( '¿Qué día y hora te vendría bien?', 'Zein egun eta ordu komeni zaizu?' ); ?>
|
||||
<input type="text" name="preferencia" placeholder="<?php echo esc_attr( ga__( 'Por ejemplo: martes o jueves por la tarde', 'Adibidez: asteartea edo osteguna arratsaldez' ) ); ?>">
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
<?php if ( $animal_id && ! $is_animal ) : ?>
|
||||
<p class="ga-form__animal"><?php echo esc_html( ga__( 'Animal: ', 'Animalia: ' ) . get_the_title( $animal_id ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
@@ -124,6 +130,7 @@ function ga_handle_contact() {
|
||||
'telefono' => sanitize_text_field( wp_unslash( $_POST['telefono'] ?? '' ) ),
|
||||
'motivo' => $reasons[ $reason ] ?? $reasons['otro'],
|
||||
'mensaje' => sanitize_textarea_field( wp_unslash( $_POST['mensaje'] ?? '' ) ),
|
||||
'visita' => 'visita' === $reason ? sanitize_text_field( wp_unslash( $_POST['preferencia'] ?? '' ) ) : '',
|
||||
'idioma' => 'eu' === ( $_POST['idioma'] ?? '' ) ? 'Euskera' : 'Castellano',
|
||||
);
|
||||
$message_required = ! $animal;
|
||||
@@ -135,8 +142,9 @@ function ga_handle_contact() {
|
||||
? 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",
|
||||
"Nombre: %s\nEmail: %s\nTeléfono: %s\nMotivo: %s%s\nAnimal: %s\nIdioma: %s\n\n%s",
|
||||
$data['nombre'], $data['email'], $data['telefono'] ?: '-', $data['motivo'],
|
||||
$data['visita'] ? "\nPreferencia de cita: " . $data['visita'] : '',
|
||||
$animal ? $animal . ' — ' . get_permalink( $animal_id ) : '-',
|
||||
$data['idioma'], $data['mensaje'] ?: '(sin mensaje)'
|
||||
);
|
||||
|
||||
50
wp-content/mu-plugins/gure-ametsa/seo.php
Normal file
50
wp-content/mu-plugins/gure-ametsa/seo.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* SEO local: datos estructurados schema.org de la protectora (AnimalShelter) en la portada.
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/** Dirección estructurada a partir de «Calle, nº · CP Localidad (Provincia)». */
|
||||
function ga_postal_address() {
|
||||
$raw = (string) ga_info( 'direccion' );
|
||||
$address = array( '@type' => 'PostalAddress', 'addressCountry' => 'ES' );
|
||||
if ( preg_match( '/^(.+?)\s*·\s*(\d{5})\s+(.+?)(?:\s*\((.+)\))?$/u', $raw, $m ) ) {
|
||||
$address += array_filter( array(
|
||||
'streetAddress' => trim( $m[1] ),
|
||||
'postalCode' => $m[2],
|
||||
'addressLocality' => trim( $m[3] ),
|
||||
'addressRegion' => $m[4] ?? '',
|
||||
) );
|
||||
} else {
|
||||
$address['streetAddress'] = $raw;
|
||||
}
|
||||
return $address;
|
||||
}
|
||||
|
||||
add_action( 'wp_head', function () {
|
||||
if ( ! is_front_page() ) {
|
||||
return;
|
||||
}
|
||||
$hours = array_filter( array_map( 'trim', explode( ',', (string) ga_setting( 'contact', 'hours_schema', 'Mo-Fr 10:00-13:00, Mo-Fr 14:00-19:00' ) ) ) );
|
||||
$data = array_filter( array(
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'AnimalShelter',
|
||||
'@id' => home_url( '/#protectora' ),
|
||||
'name' => 'Bilagun · Gure Ametsa Bi Lagun',
|
||||
'alternateName'=> array( 'Bilagun', 'Gure Ametsa Bi Lagun' ),
|
||||
'url' => home_url( '/' ),
|
||||
'logo' => content_url( 'mu-plugins/gure-ametsa/assets/logo-mark.png' ),
|
||||
'image' => content_url( 'mu-plugins/gure-ametsa/assets/logo-mark.png' ),
|
||||
'description' => get_bloginfo( 'description' ),
|
||||
'telephone' => ga_info( 'telefono' ) ? '+34 ' . ga_info( 'telefono' ) : '',
|
||||
'email' => ga_info( 'email' ),
|
||||
'address' => ga_postal_address(),
|
||||
'openingHours' => $hours,
|
||||
'hasMap' => ga_info( 'maps' ),
|
||||
'areaServed' => array( 'Hondarribia', 'Irun' ),
|
||||
'sameAs' => array_values( array_filter( array( ga_info( 'instagram' ), ga_info( 'facebook' ), ga_info( 'tiktok' ), ga_info( 'youtube' ) ) ) ),
|
||||
'knowsLanguage'=> array( 'es', 'eu' ),
|
||||
) );
|
||||
echo '<script type="application/ld+json">' . wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) . "</script>\n";
|
||||
}, 20 );
|
||||
Reference in New Issue
Block a user