API en inglés: /animals, /species, campo profile (lectura y escritura) y GraphQL

- REST: rutas animals/species, campo «profile» con nombres y valores en inglés
  (available/pending/adopted, male/female…), escribible con validación; los datos
  comunes se copian a las traducciones y los textos no. Metadatos internos ocultos.
- GraphQL: animals / speciesList, tipos AnimalProfile y enums, filtros
  where { language, adoptionStatus }.
- Las peticiones a la API usan el idioma inglés (descripciones, errores).
- Esquema OpenAPI: componente AnimalProfile y cuerpos JSON documentados.
- La web y sus URLs siguen en castellano/euskera; los datos internos no cambian.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 09:15:05 +02:00
parent 1630428b46
commit c9011d4677
3 changed files with 372 additions and 101 deletions

View File

@@ -37,10 +37,10 @@ add_action( 'init', function () {
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'show_in_rest' => true,
'rest_base' => 'animales',
'rest_base' => 'animals',
'show_in_graphql' => true,
'graphql_single_name' => 'animal',
'graphql_plural_name' => 'animales',
'graphql_plural_name' => 'animals',
) );
register_taxonomy( 'especie', 'animal', array(
@@ -52,10 +52,10 @@ add_action( 'init', function () {
'hierarchical' => true,
'show_admin_column' => true,
'show_in_rest' => true,
'rest_base' => 'especies',
'rest_base' => 'species',
'show_in_graphql' => true,
'graphql_single_name' => 'especie',
'graphql_plural_name' => 'especies',
'graphql_single_name' => 'species',
'graphql_plural_name' => 'speciesList',
'rewrite' => array( 'slug' => 'especie', 'with_front' => false ),
) );
@@ -78,10 +78,11 @@ add_action( 'init', function () {
) );
foreach ( array_keys( ga_fields() ) as $key ) {
// Los metadatos internos no se exponen tal cual: la API usa el campo «profile» (en inglés, ver api.php).
register_post_meta( 'animal', "_ga_$key", array(
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'show_in_rest' => false,
'auth_callback' => fn() => current_user_can( 'edit_posts' ),
) );
}