Indicaciones del cliente: adopción solo Perros/Gatos, fichas nuevas y todo configurable
- Adopción sin filtros ni etiquetas: acceso a Perros y Gatos, tarjetas de foto y nombre. - Ficha nueva: galería, vídeo, fecha de nacimiento o edad aproximada, carácter, necesidades, convivencia y hogar que buscamos (textos por idioma, datos compartidos). - Estados disponible / en proceso / adoptado y animales destacados. - Botón «Quiero conocerlo/la» con formulario breve (animal incluido) y confirmación. - Botones para compartir cada ficha (WhatsApp, Facebook, copiar enlace). - Portada corta según la propuesta del cliente; donaciones, cifras, etc. ocultas. - Páginas Acoge y Preguntas frecuentes, menú con submenús, sin hotel. - Aviso de cita previa y lista de ayuda material editables desde el panel. - Plugin núcleo dividido en módulos (i18n, animales, formularios, APIs). - Migración 5 idempotente: respeta las páginas editadas por el cliente. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,45 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Contenido inicial bilingüe (castellano / euskera).
|
||||
* Se ejecuta una sola vez con: wp eval-file setup-content.php
|
||||
* Contenido bilingüe (castellano / euskera): idiomas, páginas, especies y menús.
|
||||
*
|
||||
* Idempotente: sirve para la instalación inicial y para las migraciones.
|
||||
* - Las páginas que falten se crean.
|
||||
* - Las páginas existentes solo se actualizan si nadie las ha editado
|
||||
* (se guarda una huella del contenido original en _ga_seed_hash).
|
||||
*
|
||||
* Uso: wp eval-file setup-content.php (GA_SEED_MENUS=true para rehacer los menús)
|
||||
*/
|
||||
|
||||
$src = ( getenv( 'GA_SRC' ) ?: '/usr/src/gure-ametsa' ) . '/content';
|
||||
$pll = function_exists( 'pll_set_post_language' ) && function_exists( 'PLL' );
|
||||
|
||||
if ( ! $pll ) {
|
||||
WP_CLI::warning( 'Polylang no está activo: se crea solo el contenido en castellano.' );
|
||||
WP_CLI::warning( 'Polylang no está activo: se gestiona solo el contenido en castellano.' );
|
||||
}
|
||||
|
||||
/* ---------- 1. Idiomas y ajustes de Polylang ---------- */
|
||||
if ( $pll ) {
|
||||
$model = PLL()->model;
|
||||
$existing = wp_list_pluck( $model->get_languages_list(), 'slug' );
|
||||
$langs = array(
|
||||
foreach ( array(
|
||||
array( 'locale' => 'es_ES', 'slug' => 'es', 'name' => 'Español', 'flag' => 'es', 'term_group' => 0 ),
|
||||
array( 'locale' => 'eu', 'slug' => 'eu', 'name' => 'Euskara', 'flag' => 'basque', 'term_group' => 1 ),
|
||||
);
|
||||
foreach ( $langs as $lang ) {
|
||||
if ( in_array( $lang['slug'], $existing, true ) ) {
|
||||
continue;
|
||||
}
|
||||
$result = $model->add_language( $lang );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
WP_CLI::warning( 'No se pudo crear el idioma ' . $lang['slug'] . ': ' . $result->get_error_message() );
|
||||
) as $lang ) {
|
||||
if ( ! in_array( $lang['slug'], $existing, true ) ) {
|
||||
$result = $model->add_language( $lang );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
WP_CLI::warning( 'No se pudo crear el idioma ' . $lang['slug'] . ': ' . $result->get_error_message() );
|
||||
}
|
||||
}
|
||||
}
|
||||
$model->clean_languages_cache();
|
||||
|
||||
$settings = array(
|
||||
'default_lang' => 'es',
|
||||
'force_lang' => 1, // Idioma en el directorio: /eu/...
|
||||
'hide_default' => true, // Castellano sin prefijo.
|
||||
'rewrite' => true, // /eu/ en lugar de /language/eu/.
|
||||
'redirect_lang' => true, // Portada en euskera en /eu/ (no /eu/hasiera/).
|
||||
'browser' => false,
|
||||
'post_types' => array( 'animal' ),
|
||||
'taxonomies' => array( 'especie' ),
|
||||
'sync' => array( 'taxonomies', 'post_meta', '_thumbnail_id', 'menu_order', 'post_parent' ),
|
||||
'default_lang' => 'es',
|
||||
'force_lang' => 1, // Idioma en el directorio: /eu/...
|
||||
'hide_default' => true, // Castellano sin prefijo.
|
||||
'rewrite' => true, // /eu/ en lugar de /language/eu/.
|
||||
'redirect_lang' => true, // Portada en euskera en /eu/.
|
||||
'browser' => false,
|
||||
'post_types' => array( 'animal' ),
|
||||
'taxonomies' => array( 'especie' ),
|
||||
'sync' => array( 'taxonomies', 'post_meta', '_thumbnail_id', 'menu_order', 'post_parent' ),
|
||||
);
|
||||
$options = PLL()->options;
|
||||
if ( is_object( $options ) && method_exists( $options, 'set' ) ) {
|
||||
@@ -52,7 +56,6 @@ if ( $pll ) {
|
||||
} else {
|
||||
update_option( 'polylang', array_merge( (array) get_option( 'polylang', array() ), $settings ) );
|
||||
}
|
||||
// Traducción al euskera del lema del sitio.
|
||||
if ( class_exists( 'PLL_MO' ) && ( $eu = $model->get_language( 'eu' ) ) ) {
|
||||
$mo = new PLL_MO();
|
||||
$mo->import_from_db( $eu );
|
||||
@@ -62,25 +65,46 @@ if ( $pll ) {
|
||||
if ( class_exists( 'PLL_Admin_Notices' ) ) {
|
||||
PLL_Admin_Notices::dismiss( 'wizard' );
|
||||
}
|
||||
WP_CLI::log( '[ga-setup] Idiomas: castellano (por defecto) y euskera' );
|
||||
}
|
||||
|
||||
/* ---------- 2. Páginas ---------- */
|
||||
function ga_setup_page( $slug, $title, $file, $lang ) {
|
||||
$existing = get_page_by_path( $slug, OBJECT, 'page' );
|
||||
if ( $existing ) {
|
||||
return $existing->ID;
|
||||
|
||||
/** ¿La página sigue con el contenido que pusimos nosotros? */
|
||||
function ga_setup_untouched( WP_Post $post ) {
|
||||
$hash = get_post_meta( $post->ID, '_ga_seed_hash', true );
|
||||
if ( $hash ) {
|
||||
return md5( $post->post_content ) === $hash;
|
||||
}
|
||||
$content = file_get_contents( $file );
|
||||
$id = wp_insert_post( array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => $title,
|
||||
'post_name' => $slug,
|
||||
'post_content' => $content,
|
||||
), true );
|
||||
if ( is_wp_error( $id ) ) {
|
||||
WP_CLI::error( "No se pudo crear la página $slug: " . $id->get_error_message() );
|
||||
// Páginas de la primera instalación (sin huella): intactas si nunca se han modificado.
|
||||
return $post->post_modified_gmt === $post->post_date_gmt;
|
||||
}
|
||||
|
||||
function ga_setup_page( $slug, $title, $file, $lang ) {
|
||||
$content = file_exists( $file ) ? file_get_contents( $file ) : '';
|
||||
$page = get_page_by_path( $slug, OBJECT, 'page' );
|
||||
|
||||
if ( $page && 'trash' !== $page->post_status ) {
|
||||
if ( $content && ga_setup_untouched( $page ) && trim( $page->post_content ) !== trim( $content ) ) {
|
||||
wp_update_post( array( 'ID' => $page->ID, 'post_content' => $content, 'post_title' => $title ) );
|
||||
update_post_meta( $page->ID, '_ga_seed_hash', md5( get_post( $page->ID )->post_content ) );
|
||||
WP_CLI::log( "[ga-setup] actualizada: $slug" );
|
||||
} elseif ( ! ga_setup_untouched( $page ) ) {
|
||||
WP_CLI::log( "[ga-setup] se respeta (editada): $slug" );
|
||||
}
|
||||
$id = $page->ID;
|
||||
} else {
|
||||
$id = wp_insert_post( array(
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_title' => $title,
|
||||
'post_name' => $slug,
|
||||
'post_content' => $content,
|
||||
), true );
|
||||
if ( is_wp_error( $id ) ) {
|
||||
WP_CLI::error( "No se pudo crear la página $slug: " . $id->get_error_message() );
|
||||
}
|
||||
update_post_meta( $id, '_ga_seed_hash', md5( get_post( $id )->post_content ) );
|
||||
WP_CLI::log( "[ga-setup] creada: $slug" );
|
||||
}
|
||||
if ( function_exists( 'pll_set_post_language' ) ) {
|
||||
pll_set_post_language( $id, $lang );
|
||||
@@ -88,43 +112,50 @@ function ga_setup_page( $slug, $title, $file, $lang ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
// slug es => [título es, archivo es, slug eu, título eu, archivo eu]
|
||||
// slug es => [título es, slug eu, título eu]
|
||||
$pages = array(
|
||||
'inicio' => array( 'Inicio', 'inicio', 'hasiera', 'Hasiera', 'hasiera' ),
|
||||
'quienes-somos' => array( 'Quiénes somos', 'quienes-somos', 'nor-gara', 'Nor gara', 'nor-gara' ),
|
||||
'colabora' => array( 'Colabora', 'colabora', 'lagundu', 'Lagundu', 'lagundu' ),
|
||||
'hotel' => array( 'Hotel para perros y gatos', 'hotel', 'hotela', 'Txakur eta katuentzako hotela', 'hotela' ),
|
||||
'contacto' => array( 'Contacto', 'contacto', 'harremanetarako', 'Harremanetarako', 'harremanetarako' ),
|
||||
'politica-de-privacidad' => array( 'Política de privacidad', 'privacidad', 'pribatutasun-politika', 'Pribatutasun-politika', 'pribatutasun-politika' ),
|
||||
'aviso-legal' => array( 'Aviso legal', 'aviso-legal', 'lege-oharra', 'Lege-oharra', 'lege-oharra' ),
|
||||
'inicio' => array( 'Inicio', 'hasiera', 'Hasiera' ),
|
||||
'acoge' => array( 'Acoge', 'harrera', 'Harrera' ),
|
||||
'colabora' => array( 'Colabora', 'lagundu', 'Lagundu' ),
|
||||
'quienes-somos' => array( 'Quiénes somos', 'nor-gara', 'Nor gara' ),
|
||||
'contacto' => array( 'Contacto', 'harremanetarako', 'Harremanetarako' ),
|
||||
'preguntas-frecuentes' => array( 'Preguntas frecuentes', 'ohiko-galderak', 'Ohiko galderak' ),
|
||||
'politica-de-privacidad' => array( 'Política de privacidad', 'pribatutasun-politika', 'Pribatutasun-politika' ),
|
||||
'aviso-legal' => array( 'Aviso legal', 'lege-oharra', 'Lege-oharra' ),
|
||||
);
|
||||
$files = array( 'politica-de-privacidad' => 'privacidad' );
|
||||
|
||||
$ids = array();
|
||||
foreach ( $pages as $slug => [ $title_es, $file_es, $slug_eu, $title_eu, $file_eu ] ) {
|
||||
$ids[ $slug ]['es'] = ga_setup_page( $slug, $title_es, "$src/es/$file_es.html", 'es' );
|
||||
foreach ( $pages as $slug => [ $title_es, $slug_eu, $title_eu ] ) {
|
||||
$ids[ $slug ]['es'] = ga_setup_page( $slug, $title_es, "$src/es/" . ( $files[ $slug ] ?? $slug ) . '.html', 'es' );
|
||||
if ( $pll ) {
|
||||
$ids[ $slug ]['eu'] = ga_setup_page( $slug_eu, $title_eu, "$src/eu/$file_eu.html", 'eu' );
|
||||
$ids[ $slug ]['eu'] = ga_setup_page( $slug_eu, $title_eu, "$src/eu/$slug_eu.html", 'eu' );
|
||||
pll_save_post_translations( $ids[ $slug ] );
|
||||
}
|
||||
}
|
||||
|
||||
// El hotel ya no forma parte de la web: se retira si nadie lo ha editado.
|
||||
foreach ( array( 'hotel', 'hotela' ) as $slug ) {
|
||||
$page = get_page_by_path( $slug, OBJECT, 'page' );
|
||||
if ( $page && 'trash' !== $page->post_status ) {
|
||||
if ( ga_setup_untouched( $page ) ) {
|
||||
wp_trash_post( $page->ID );
|
||||
WP_CLI::log( "[ga-setup] a la papelera: $slug" );
|
||||
} else {
|
||||
WP_CLI::warning( "La página «$slug» se ha editado: no se borra, revísala a mano." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_on_front', $ids['inicio']['es'] );
|
||||
update_option( 'wp_page_for_privacy_policy', $ids['politica-de-privacidad']['es'] );
|
||||
WP_CLI::log( '[ga-setup] Páginas creadas' );
|
||||
WP_CLI::log( '[ga-setup] Páginas listas' );
|
||||
|
||||
/* ---------- 3. Especies ---------- */
|
||||
$species = array(
|
||||
'perro' => array( 'Perro', 'txakurra', 'Txakurra' ),
|
||||
'gato' => array( 'Gato', 'katua', 'Katua' ),
|
||||
'otros' => array( 'Otros', 'besteak', 'Besteak' ),
|
||||
);
|
||||
/* ---------- 3. Especies: solo perros y gatos ---------- */
|
||||
$term_ids = array();
|
||||
foreach ( $species as $slug => [ $name_es, $slug_eu, $name_eu ] ) {
|
||||
$pairs = array( 'es' => array( $slug, $name_es ) );
|
||||
if ( $pll ) {
|
||||
$pairs['eu'] = array( $slug_eu, $name_eu );
|
||||
}
|
||||
foreach ( array( 'perro' => array( 'Perro', 'txakurra', 'Txakurra' ), 'gato' => array( 'Gato', 'katua', 'Katua' ) ) as $slug => [ $name_es, $slug_eu, $name_eu ] ) {
|
||||
$pairs = array( 'es' => array( $slug, $name_es ) ) + ( $pll ? array( 'eu' => array( $slug_eu, $name_eu ) ) : array() );
|
||||
foreach ( $pairs as $lang => [ $term_slug, $term_name ] ) {
|
||||
$term = get_term_by( 'slug', $term_slug, 'especie' );
|
||||
if ( ! $term ) {
|
||||
@@ -138,64 +169,95 @@ foreach ( $species as $slug => [ $name_es, $slug_eu, $name_eu ] ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $pll && count( $term_ids[ $slug ] ?? array() ) === 2 ) {
|
||||
if ( $pll && 2 === count( $term_ids[ $slug ] ?? array() ) ) {
|
||||
pll_save_term_translations( $term_ids[ $slug ] );
|
||||
}
|
||||
}
|
||||
foreach ( array( 'otros', 'besteak' ) as $slug ) {
|
||||
$term = get_term_by( 'slug', $slug, 'especie' );
|
||||
if ( $term && 0 === (int) $term->count ) {
|
||||
wp_delete_term( $term->term_id, 'especie' );
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 4. Menús ---------- */
|
||||
function ga_setup_menu( $name, $items ) {
|
||||
function ga_setup_menu( $name, $items, $rebuild ) {
|
||||
$menu = wp_get_nav_menu_object( $name );
|
||||
if ( $menu ) {
|
||||
if ( $menu && ! $rebuild ) {
|
||||
return $menu->term_id;
|
||||
}
|
||||
if ( $menu ) {
|
||||
wp_delete_nav_menu( $menu->term_id );
|
||||
}
|
||||
$menu_id = wp_create_nav_menu( $name );
|
||||
foreach ( $items as $pos => $item ) {
|
||||
$args = array( 'menu-item-status' => 'publish', 'menu-item-position' => $pos + 1, 'menu-item-title' => $item['title'] );
|
||||
if ( isset( $item['page'] ) ) {
|
||||
$args += array( 'menu-item-type' => 'post_type', 'menu-item-object' => 'page', 'menu-item-object-id' => $item['page'] );
|
||||
} else {
|
||||
$args += array( 'menu-item-type' => 'custom', 'menu-item-url' => $item['url'] );
|
||||
$pos = 0;
|
||||
$add = function ( $item, $parent = 0 ) use ( $menu_id, &$pos, &$add ) {
|
||||
$args = array(
|
||||
'menu-item-status' => 'publish',
|
||||
'menu-item-position' => ++$pos,
|
||||
'menu-item-title' => $item['title'],
|
||||
'menu-item-parent-id' => $parent,
|
||||
);
|
||||
$args += isset( $item['page'] )
|
||||
? array( 'menu-item-type' => 'post_type', 'menu-item-object' => 'page', 'menu-item-object-id' => $item['page'] )
|
||||
: array( 'menu-item-type' => 'custom', 'menu-item-url' => $item['url'] );
|
||||
$id = wp_update_nav_menu_item( $menu_id, 0, $args );
|
||||
foreach ( $item['children'] ?? array() as $child ) {
|
||||
$add( $child, $id );
|
||||
}
|
||||
wp_update_nav_menu_item( $menu_id, 0, $args );
|
||||
};
|
||||
foreach ( $items as $item ) {
|
||||
$add( $item );
|
||||
}
|
||||
return $menu_id;
|
||||
}
|
||||
|
||||
$menus = array(
|
||||
$rebuild = 'true' === getenv( 'GA_SEED_MENUS' );
|
||||
$menus = array(
|
||||
'primary' => array(
|
||||
'es' => ga_setup_menu( 'Principal', array(
|
||||
array( 'title' => 'Adopta', 'url' => '/adopta/' ),
|
||||
array( 'title' => 'Acoge', 'url' => '/colabora/#acogida' ),
|
||||
array( 'title' => 'Voluntariado', 'url' => '/colabora/#voluntariado' ),
|
||||
array( 'title' => 'Dona', 'url' => '/colabora/#donaciones' ),
|
||||
array( 'title' => 'Hotel', 'page' => $ids['hotel']['es'] ),
|
||||
array( 'title' => 'Inicio', 'page' => $ids['inicio']['es'] ),
|
||||
array( 'title' => 'Adopta', 'url' => '/adopta/', 'children' => array(
|
||||
array( 'title' => 'Perros', 'url' => '/especie/perro/' ),
|
||||
array( 'title' => 'Gatos', 'url' => '/especie/gato/' ),
|
||||
) ),
|
||||
array( 'title' => 'Acoge', 'page' => $ids['acoge']['es'] ),
|
||||
array( 'title' => 'Colabora', 'page' => $ids['colabora']['es'], 'children' => array(
|
||||
array( 'title' => 'Voluntariado', 'url' => '/colabora/#voluntariado' ),
|
||||
array( 'title' => 'Ayuda material', 'url' => '/colabora/#material' ),
|
||||
) ),
|
||||
array( 'title' => 'Quiénes somos', 'page' => $ids['quienes-somos']['es'] ),
|
||||
array( 'title' => 'Contacto', 'page' => $ids['contacto']['es'] ),
|
||||
) ),
|
||||
), $rebuild ),
|
||||
),
|
||||
'footer' => array(
|
||||
'es' => ga_setup_menu( 'Legal', array(
|
||||
array( 'title' => 'Aviso legal', 'page' => $ids['aviso-legal']['es'] ),
|
||||
array( 'title' => 'Política de privacidad', 'page' => $ids['politica-de-privacidad']['es'] ),
|
||||
) ),
|
||||
), $rebuild ),
|
||||
),
|
||||
);
|
||||
if ( $pll ) {
|
||||
$menus['primary']['eu'] = ga_setup_menu( 'Nagusia (euskara)', array(
|
||||
array( 'title' => 'Adoptatu', 'url' => '/eu/adopta/' ),
|
||||
array( 'title' => 'Harrera', 'url' => '/eu/lagundu/#acogida' ),
|
||||
array( 'title' => 'Boluntariotza', 'url' => '/eu/lagundu/#voluntariado' ),
|
||||
array( 'title' => 'Dohaintza', 'url' => '/eu/lagundu/#donaciones' ),
|
||||
array( 'title' => 'Hotela', 'page' => $ids['hotel']['eu'] ),
|
||||
array( 'title' => 'Hasiera', 'page' => $ids['inicio']['eu'] ),
|
||||
array( 'title' => 'Adoptatu', 'url' => '/eu/adopta/', 'children' => array(
|
||||
array( 'title' => 'Txakurrak', 'url' => '/eu/especie/txakurra/' ),
|
||||
array( 'title' => 'Katuak', 'url' => '/eu/especie/katua/' ),
|
||||
) ),
|
||||
array( 'title' => 'Harrera', 'page' => $ids['acoge']['eu'] ),
|
||||
array( 'title' => 'Lagundu', 'page' => $ids['colabora']['eu'], 'children' => array(
|
||||
array( 'title' => 'Boluntariotza', 'url' => '/eu/lagundu/#voluntariado' ),
|
||||
array( 'title' => 'Laguntza materiala', 'url' => '/eu/lagundu/#material' ),
|
||||
) ),
|
||||
array( 'title' => 'Nor gara', 'page' => $ids['quienes-somos']['eu'] ),
|
||||
array( 'title' => 'Harremanetarako', 'page' => $ids['contacto']['eu'] ),
|
||||
) );
|
||||
), $rebuild );
|
||||
$menus['footer']['eu'] = ga_setup_menu( 'Legala (euskara)', array(
|
||||
array( 'title' => 'Lege-oharra', 'page' => $ids['aviso-legal']['eu'] ),
|
||||
array( 'title' => 'Pribatutasun-politika', 'page' => $ids['politica-de-privacidad']['eu'] ),
|
||||
) );
|
||||
), $rebuild );
|
||||
|
||||
$theme = get_stylesheet();
|
||||
$nav_menus = array( $theme => $menus );
|
||||
$nav_menus = array( get_stylesheet() => $menus );
|
||||
if ( is_object( PLL()->options ) && method_exists( PLL()->options, 'set' ) ) {
|
||||
PLL()->options->set( 'nav_menus', $nav_menus );
|
||||
if ( method_exists( PLL()->options, 'save_all' ) ) {
|
||||
@@ -207,44 +269,51 @@ if ( $pll ) {
|
||||
update_option( 'polylang', $opts );
|
||||
}
|
||||
}
|
||||
set_theme_mod( 'nav_menu_locations', array(
|
||||
'primary' => $menus['primary']['es'],
|
||||
'footer' => $menus['footer']['es'],
|
||||
) );
|
||||
WP_CLI::log( '[ga-setup] Menús creados' );
|
||||
set_theme_mod( 'nav_menu_locations', array( 'primary' => $menus['primary']['es'], 'footer' => $menus['footer']['es'] ) );
|
||||
WP_CLI::log( '[ga-setup] Menús listos' );
|
||||
|
||||
/* ---------- 5. Animales de ejemplo (opcional) ---------- */
|
||||
if ( 'true' === getenv( 'SEED_DEMO_ANIMALS' ) ) {
|
||||
/* ---------- 5. Animales ---------- */
|
||||
|
||||
// Estados antiguos → nuevos (disponible / proceso / adoptado).
|
||||
foreach ( get_posts( array( 'post_type' => 'animal', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids', 'lang' => '' ) ) as $animal_id ) {
|
||||
$estado = get_post_meta( $animal_id, '_ga_estado', true );
|
||||
$map = array( 'reservado' => 'proceso', 'urgente' => 'disponible', 'acogida' => 'disponible' );
|
||||
if ( isset( $map[ $estado ] ) ) {
|
||||
update_post_meta( $animal_id, '_ga_estado', $map[ $estado ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'true' === getenv( 'SEED_DEMO_ANIMALS' ) && ! get_posts( array( 'post_type' => 'animal', 'numberposts' => 1, 'post_status' => 'any', 'lang' => '' ) ) ) {
|
||||
$demo = array(
|
||||
array(
|
||||
'es' => array( 'Txuri (ejemplo)', 'Txuri es cariñosa, tranquila en casa y le encantan los paseos por Jaizkibel.' ),
|
||||
'eu' => array( 'Txuri (adibidea)', 'Txuri maitekorra da, lasaia etxean, eta Jaizkibelen barrena paseatzea asko gustatzen zaio.' ),
|
||||
'es' => array( 'Txuri (ejemplo)', 'Llegó un poco asustada, pero en cuanto coge confianza no se separa de ti.', array( 'caracter' => 'Tranquila en casa y muy cariñosa con quien conoce. Le encantan los paseos largos.', 'hogar' => 'Una familia que respete su ritmo y le acompañe con paciencia.' ) ),
|
||||
'eu' => array( 'Txuri (adibidea)', 'Beldur pixka batekin iritsi zen, baina konfiantza hartzen duenean ez da zure ondotik aldentzen.', array( 'caracter' => 'Lasaia etxean eta oso maitekorra ezagutzen dituenekin. Ibilaldi luzeak asko gustatzen zaizkio.', 'hogar' => 'Bere erritmoa errespetatu eta pazientziaz lagunduko dion familia bat.' ) ),
|
||||
'sp' => 'perro',
|
||||
'meta' => array( 'sexo' => 'hembra', 'edad' => '3', 'edad_unidad' => 'anos', 'tamano' => 'mediano', 'estado' => 'disponible', 'raza' => 'Mestiza' ),
|
||||
'meta' => array( 'sexo' => 'hembra', 'edad' => '3', 'edad_unidad' => 'anos', 'tamano' => 'mediano', 'estado' => 'disponible', 'destacado' => '1' ),
|
||||
),
|
||||
array(
|
||||
'es' => array( 'Beltza (ejemplo)', 'Beltza es un gato curioso y juguetón que busca un hogar sin prisas.' ),
|
||||
'eu' => array( 'Beltza (adibidea)', 'Beltza katu jakin-nahia eta jostalaria da, eta presarik gabe etxe baten bila dabil.' ),
|
||||
'es' => array( 'Beltza (ejemplo)', 'Curioso y juguetón, siempre quiere saber qué estás haciendo.', array( 'caracter' => 'Muy sociable con las personas. Le gusta jugar y dormir al sol.' ) ),
|
||||
'eu' => array( 'Beltza (adibidea)', 'Jakin-mina eta jostalaria, beti jakin nahi du zer egiten ari zaren.', array( 'caracter' => 'Oso soziala pertsonekin. Jolastea eta eguzkitan lo egitea gustatzen zaizkio.' ) ),
|
||||
'sp' => 'gato',
|
||||
'meta' => array( 'sexo' => 'macho', 'edad' => '1', 'edad_unidad' => 'anos', 'tamano' => 'pequeno', 'estado' => 'disponible', 'raza' => 'Común europeo' ),
|
||||
'meta' => array( 'sexo' => 'macho', 'edad' => '1', 'edad_unidad' => 'anos', 'estado' => 'disponible' ),
|
||||
),
|
||||
array(
|
||||
'es' => array( 'Hartz (ejemplo)', 'Hartz es un abuelito noble que merece pasar sus mejores años en familia.' ),
|
||||
'eu' => array( 'Hartz (adibidea)', 'Hartz aitona noblea da, eta bere urterik onenak familian igarotzea merezi du.' ),
|
||||
'es' => array( 'Hartz (ejemplo)', 'Un abuelito noble que merece pasar sus mejores años en familia.', array( 'necesidades' => 'Paseos tranquilos y una casa sin muchas escaleras.' ) ),
|
||||
'eu' => array( 'Hartz (adibidea)', 'Aitona noblea, bere urterik onenak familian igarotzea merezi duena.', array( 'necesidades' => 'Ibilaldi lasaiak eta eskailera askorik gabeko etxea.' ) ),
|
||||
'sp' => 'perro',
|
||||
'meta' => array( 'sexo' => 'macho', 'edad' => '7', 'edad_unidad' => 'anos', 'tamano' => 'grande', 'estado' => 'urgente', 'raza' => 'Mastín' ),
|
||||
'meta' => array( 'sexo' => 'macho', 'edad' => '9', 'edad_unidad' => 'anos', 'tamano' => 'grande', 'estado' => 'disponible', 'destacado' => '1' ),
|
||||
),
|
||||
array(
|
||||
'es' => array( 'Ilargi (ejemplo)', 'Ilargi es una gatita sociable que se lleva bien con otros gatos.' ),
|
||||
'eu' => array( 'Ilargi (adibidea)', 'Ilargi katakume soziala da eta beste katuekin ondo moldatzen da.' ),
|
||||
'es' => array( 'Ilargi (ejemplo)', 'Una gatita sociable que se lleva bien con otros gatos.', array() ),
|
||||
'eu' => array( 'Ilargi (adibidea)', 'Beste katuekin ondo moldatzen den katakume soziala.', array() ),
|
||||
'sp' => 'gato',
|
||||
'meta' => array( 'sexo' => 'hembra', 'edad' => '4', 'edad_unidad' => 'meses', 'tamano' => 'pequeno', 'estado' => 'reservado', 'raza' => 'Común europeo' ),
|
||||
'meta' => array( 'sexo' => 'hembra', 'edad' => '4', 'edad_unidad' => 'meses', 'estado' => 'proceso' ),
|
||||
),
|
||||
);
|
||||
foreach ( $demo as $animal ) {
|
||||
$translations = array();
|
||||
foreach ( $pll ? array( 'es', 'eu' ) : array( 'es' ) as $lang ) {
|
||||
[ $title, $text ] = $animal[ $lang ];
|
||||
[ $title, $text, $texts ] = $animal[ $lang ];
|
||||
$id = wp_insert_post( array(
|
||||
'post_type' => 'animal',
|
||||
'post_status' => 'publish',
|
||||
@@ -254,7 +323,7 @@ if ( 'true' === getenv( 'SEED_DEMO_ANIMALS' ) ) {
|
||||
if ( ! empty( $term_ids[ $animal['sp'] ][ $lang ] ) ) {
|
||||
wp_set_object_terms( $id, array( $term_ids[ $animal['sp'] ][ $lang ] ), 'especie' );
|
||||
}
|
||||
foreach ( $animal['meta'] + array( 'salud' => 'chip,vacunado,esterilizado', 'compatible' => 'perros,ninos' ) as $key => $value ) {
|
||||
foreach ( $animal['meta'] + $texts as $key => $value ) {
|
||||
update_post_meta( $id, "_ga_$key", $value );
|
||||
}
|
||||
if ( $pll ) {
|
||||
|
||||
Reference in New Issue
Block a user