change logo and colors
This commit is contained in:
@@ -14,6 +14,9 @@ defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/** Idioma actual: 'es' o 'eu'. El panel de administración siempre en castellano. */
|
||||
function ga_lang() {
|
||||
if ( isset( $GLOBALS['ga_forced_lang'] ) ) {
|
||||
return 'eu' === $GLOBALS['ga_forced_lang'] ? 'eu' : 'es';
|
||||
}
|
||||
if ( is_admin() && ! wp_doing_ajax() ) {
|
||||
return 'es';
|
||||
}
|
||||
@@ -108,6 +111,11 @@ add_action( 'init', function () {
|
||||
'menu_position' => 5,
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'animales',
|
||||
// WPGraphQL
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => 'animal',
|
||||
'graphql_plural_name' => 'animales',
|
||||
) );
|
||||
|
||||
register_taxonomy( 'especie', 'animal', array(
|
||||
@@ -119,6 +127,10 @@ add_action( 'init', function () {
|
||||
'hierarchical' => true,
|
||||
'show_admin_column' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'especies',
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => 'especie',
|
||||
'graphql_plural_name' => 'especies',
|
||||
'rewrite' => array( 'slug' => 'especie', 'with_front' => false ),
|
||||
) );
|
||||
|
||||
@@ -632,3 +644,121 @@ function ga_handle_contact() {
|
||||
|
||||
$go( 'ok' );
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* APIs: REST (/wp-json/wp/v2/animales) y GraphQL (/graphql)
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Ficha de un animal lista para las APIs: valores internos + textos legibles. */
|
||||
function ga_animal_api_data( $post_id ) {
|
||||
$lang = function_exists( 'pll_get_post_language' ) ? ( pll_get_post_language( $post_id ) ?: 'es' ) : 'es';
|
||||
$list = fn( $key ) => array_values( array_filter( explode( ',', ga_get( $post_id, $key ) ) ) );
|
||||
$data = array(
|
||||
'estado' => ga_get( $post_id, 'estado' ) ?: 'disponible',
|
||||
'sexo' => ga_get( $post_id, 'sexo' ),
|
||||
'edad' => '' === ga_get( $post_id, 'edad' ) ? null : (float) ga_get( $post_id, 'edad' ),
|
||||
'edad_unidad' => ga_get( $post_id, 'edad_unidad' ),
|
||||
'tamano' => ga_get( $post_id, 'tamano' ),
|
||||
'raza' => ga_get( $post_id, 'raza' ),
|
||||
'llegada' => ga_get( $post_id, 'llegada' ),
|
||||
'salud' => $list( 'salud' ),
|
||||
'compatible' => $list( 'compatible' ),
|
||||
'idioma' => $lang,
|
||||
);
|
||||
// Textos legibles en el idioma del animal.
|
||||
$labels = function () use ( $post_id ) {
|
||||
return array(
|
||||
'estado' => ga_label( $post_id, 'estado' ) ?: ga__( 'En adopción', 'Adopzioan' ),
|
||||
'sexo' => ga_label( $post_id, 'sexo' ),
|
||||
'edad' => ga_age( $post_id ),
|
||||
'tamano' => ga_label( $post_id, 'tamano' ),
|
||||
'salud' => ga_label( $post_id, 'salud' ) ?: array(),
|
||||
'compatible' => ga_label( $post_id, 'compatible' ) ?: array(),
|
||||
);
|
||||
};
|
||||
$data['textos'] = ga_with_lang( $lang, $labels );
|
||||
return $data;
|
||||
}
|
||||
|
||||
/** Ejecuta $callback como si el idioma actual fuera $lang (para las etiquetas). */
|
||||
function ga_with_lang( $lang, callable $callback ) {
|
||||
$GLOBALS['ga_forced_lang'] = $lang;
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
unset( $GLOBALS['ga_forced_lang'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* REST: campo «ficha» de solo lectura en /wp/v2/animales */
|
||||
add_action( 'rest_api_init', function () {
|
||||
register_rest_field( 'animal', 'ficha', array(
|
||||
'get_callback' => fn( $post ) => ga_animal_api_data( $post['id'] ),
|
||||
'schema' => array(
|
||||
'description' => 'Ficha del animal (valores internos y textos legibles en su idioma).',
|
||||
'type' => 'object',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
'properties' => array(
|
||||
'estado' => array( 'type' => 'string', 'enum' => array( 'disponible', 'urgente', 'acogida', 'reservado', 'adoptado' ) ),
|
||||
'sexo' => array( 'type' => 'string' ),
|
||||
'edad' => array( 'type' => array( 'number', 'null' ) ),
|
||||
'edad_unidad' => array( 'type' => 'string', 'enum' => array( '', 'anos', 'meses' ) ),
|
||||
'tamano' => array( 'type' => 'string' ),
|
||||
'raza' => array( 'type' => 'string' ),
|
||||
'llegada' => array( 'type' => 'string', 'format' => 'date' ),
|
||||
'salud' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ) ),
|
||||
'compatible' => array( 'type' => 'array', 'items' => array( 'type' => 'string' ) ),
|
||||
'idioma' => array( 'type' => 'string' ),
|
||||
'textos' => array( 'type' => 'object' ),
|
||||
),
|
||||
),
|
||||
) );
|
||||
} );
|
||||
|
||||
/* GraphQL: tipo AnimalFicha y campo «ficha» en Animal */
|
||||
add_action( 'graphql_register_types', function () {
|
||||
register_graphql_object_type( 'AnimalFichaTextos', array(
|
||||
'description' => 'Textos legibles de la ficha, en el idioma del animal.',
|
||||
'fields' => array(
|
||||
'estado' => array( 'type' => 'String' ),
|
||||
'sexo' => array( 'type' => 'String' ),
|
||||
'edad' => array( 'type' => 'String' ),
|
||||
'tamano' => array( 'type' => 'String' ),
|
||||
'salud' => array( 'type' => array( 'list_of' => 'String' ) ),
|
||||
'compatible' => array( 'type' => array( 'list_of' => 'String' ) ),
|
||||
),
|
||||
) );
|
||||
register_graphql_object_type( 'AnimalFicha', array(
|
||||
'description' => 'Ficha del animal en adopción.',
|
||||
'fields' => array(
|
||||
'estado' => array( 'type' => 'String', 'description' => 'disponible, urgente, acogida, reservado o adoptado' ),
|
||||
'sexo' => array( 'type' => 'String' ),
|
||||
'edad' => array( 'type' => 'Float' ),
|
||||
'edadUnidad' => array( 'type' => 'String', 'description' => 'anos o meses' ),
|
||||
'tamano' => array( 'type' => 'String' ),
|
||||
'raza' => array( 'type' => 'String' ),
|
||||
'llegada' => array( 'type' => 'String' ),
|
||||
'salud' => array( 'type' => array( 'list_of' => 'String' ) ),
|
||||
'compatible' => array( 'type' => array( 'list_of' => 'String' ) ),
|
||||
'idioma' => array( 'type' => 'String' ),
|
||||
'textos' => array( 'type' => 'AnimalFichaTextos' ),
|
||||
),
|
||||
) );
|
||||
register_graphql_field( 'Animal', 'ficha', array(
|
||||
'type' => 'AnimalFicha',
|
||||
'resolve' => function ( $post ) {
|
||||
$data = ga_animal_api_data( $post->databaseId );
|
||||
$data['edadUnidad'] = $data['edad_unidad'];
|
||||
return $data;
|
||||
},
|
||||
) );
|
||||
} );
|
||||
|
||||
/* Documentación Swagger (/rest-api/docs/): solo para usuarios conectados, salvo API_DOCS_PUBLIC=true */
|
||||
add_action( 'template_redirect', function () {
|
||||
if ( 'docs' === get_query_var( 'swagger_api' ) && 'true' !== getenv( 'API_DOCS_PUBLIC' ) && ! is_user_logged_in() ) {
|
||||
auth_redirect();
|
||||
}
|
||||
}, 1 );
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 5.9 KiB |
4
wp-content/themes/gure-ametsa/assets/img/logo-mark.svg
Normal file
4
wp-content/themes/gure-ametsa/assets/img/logo-mark.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 6.0 KiB |
5
wp-content/themes/gure-ametsa/assets/img/logo.svg
Normal file
5
wp-content/themes/gure-ametsa/assets/img/logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 28 KiB |
@@ -21,7 +21,7 @@ $columns = array(
|
||||
<div class="ga-wrap">
|
||||
<div class="ga-footer__grid">
|
||||
<div class="ga-footer__about">
|
||||
<?php ga_brand(); ?>
|
||||
<?php ga_brand( 'footer' ); ?>
|
||||
<p><?php ga_opt_e( 'footer', 'about' ); ?></p>
|
||||
<div class="ga-footer__social"><?php echo ga_social_links(); // Escapado en la función. ?></div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'GA_THEME_VERSION', '2.0.0' );
|
||||
define( 'GA_THEME_VERSION', '2.1.0' );
|
||||
|
||||
require_once __DIR__ . '/inc/customizer.php';
|
||||
require_once __DIR__ . '/inc/dynamic-css.php';
|
||||
@@ -129,19 +129,45 @@ function ga_tel_link() {
|
||||
return 'tel:+34' . preg_replace( '/\D/', '', ga_info( 'telefono' ) );
|
||||
}
|
||||
|
||||
function ga_brand() {
|
||||
/** SVG del logo (assets/img/logo.svg o logo-mark.svg), en línea para poder recolorearlo con CSS. */
|
||||
function ga_logo_svg( $variant = 'full' ) {
|
||||
static $cache = array();
|
||||
if ( ! isset( $cache[ $variant ] ) ) {
|
||||
$file = get_theme_file_path( 'assets/img/' . ( 'mark' === $variant ? 'logo-mark.svg' : 'logo.svg' ) );
|
||||
$cache[ $variant ] = is_readable( $file ) ? trim( file_get_contents( $file ) ) : '';
|
||||
}
|
||||
return $cache[ $variant ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marca del sitio.
|
||||
*
|
||||
* @param string $context 'header' o 'footer'.
|
||||
*/
|
||||
function ga_brand( $context = 'header' ) {
|
||||
if ( has_custom_logo() ) {
|
||||
the_custom_logo();
|
||||
return;
|
||||
}
|
||||
printf(
|
||||
'<a class="ga-brand" href="%s" rel="home"><span class="ga-brand__mark">%s</span><span class="ga-brand__name"><b>%s</b><b>%s</b><small>%s</small></span></a>',
|
||||
esc_url( ga_home_url() ),
|
||||
ga_icon( 'mark' ), // SVG estático.
|
||||
$style = 'footer' === $context ? 'full' : ga_opt( 'header', 'logo_style' );
|
||||
$name = sprintf(
|
||||
'<span class="ga-brand__name"><b>%s</b><b>%s</b><small>%s</small></span>',
|
||||
esc_html( ga_opt( 'header', 'brand_line1' ) ),
|
||||
esc_html( ga_opt( 'header', 'brand_line2' ) ),
|
||||
esc_html( ga_opt( 'header', 'brand_line3' ) )
|
||||
);
|
||||
$inner = match ( $style ) {
|
||||
'full' => '<span class="ga-brand__logo">' . ga_logo_svg( 'full' ) . '</span>',
|
||||
'text' => $name,
|
||||
default => '<span class="ga-brand__mark">' . ga_logo_svg( 'mark' ) . '</span>' . $name,
|
||||
};
|
||||
printf(
|
||||
'<a class="ga-brand ga-brand--%s" href="%s" rel="home" aria-label="%s">%s</a>',
|
||||
esc_attr( $style ),
|
||||
esc_url( ga_home_url() ),
|
||||
esc_attr( get_bloginfo( 'name' ) ),
|
||||
$inner // SVG estático del tema y textos escapados.
|
||||
);
|
||||
}
|
||||
|
||||
/* ---------- Ayudantes de animales ---------- */
|
||||
|
||||
@@ -27,6 +27,14 @@ function ga_fonts() {
|
||||
/** Paletas rápidas. 'custom' usa los colores elegidos a mano. */
|
||||
function ga_palettes() {
|
||||
return array(
|
||||
'logo' => array(
|
||||
'label' => 'Colores del logo (marrón y beige)',
|
||||
'primary' => '#401f0c', // marrón del logo
|
||||
'accent' => '#bd8537', // caramelo: el tono del beige, más intenso
|
||||
'background' => '#fcfaf5',
|
||||
'surface' => '#f3ecdc', // beige del logo aclarado
|
||||
'text' => '#2b1508',
|
||||
),
|
||||
'ciruela' => array(
|
||||
'label' => 'Ciruela y mostaza',
|
||||
'primary' => '#5b2c4e',
|
||||
@@ -98,7 +106,7 @@ function ga_customizer_registry() {
|
||||
};
|
||||
|
||||
$palette_choices = array_map( fn( $p ) => $p['label'], ga_palettes() ) + array( 'custom' => 'Personalizada (colores de abajo)' );
|
||||
$default = ga_palettes()['ciruela'];
|
||||
$default = ga_palettes()['logo'];
|
||||
|
||||
$registry = array(
|
||||
/* ================= Diseño ================= */
|
||||
@@ -106,7 +114,7 @@ function ga_customizer_registry() {
|
||||
'panel' => 'ga_design',
|
||||
'title' => 'Colores',
|
||||
'fields' => array(
|
||||
'palette' => array( 'type' => 'select', 'label' => 'Paleta', 'default' => 'ciruela', 'choices' => $palette_choices, 'description' => 'Elige una paleta lista, o «Personalizada» para usar los colores de abajo.' ),
|
||||
'palette' => array( 'type' => 'select', 'label' => 'Paleta', 'default' => 'logo', 'choices' => $palette_choices, 'description' => 'Elige una paleta lista, o «Personalizada» para usar los colores de abajo.' ),
|
||||
'primary' => array( 'type' => 'color', 'label' => 'Color principal', 'default' => $default['primary'], 'description' => 'Títulos, botones de la cabecera, secciones oscuras y pie.' ),
|
||||
'accent' => array( 'type' => 'color', 'label' => 'Color de acento', 'default' => $default['accent'], 'description' => 'Botones principales, detalles y palabras resaltadas.' ),
|
||||
'background' => array( 'type' => 'color', 'label' => 'Fondo de la página', 'default' => $default['background'] ),
|
||||
@@ -135,6 +143,11 @@ function ga_customizer_registry() {
|
||||
'panel' => 'ga_design',
|
||||
'title' => 'Cabecera',
|
||||
'fields' => array(
|
||||
'logo_style' => array( 'type' => 'select', 'label' => 'Logo en la cabecera', 'default' => 'mark', 'choices' => array(
|
||||
'mark' => 'Símbolo + nombre escrito',
|
||||
'full' => 'Logo completo',
|
||||
'text' => 'Solo el nombre escrito',
|
||||
), 'description' => 'Si subes otro logo en «Identidad del sitio», se usa ese.' ),
|
||||
'phone' => array( 'type' => 'checkbox', 'label' => 'Mostrar el teléfono en la cabecera', 'default' => true ),
|
||||
'switcher' => array( 'type' => 'checkbox', 'label' => 'Mostrar selector de idioma ES | EU', 'default' => true ),
|
||||
'sticky' => array( 'type' => 'checkbox', 'label' => 'Cabecera fija al hacer scroll', 'default' => true ),
|
||||
|
||||
@@ -173,7 +173,11 @@ p { margin: 0 0 1.1em; }
|
||||
.ga-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ga-green-dark); flex: none; }
|
||||
.ga-brand:hover { color: var(--ga-green-dark); }
|
||||
.ga-brand img, .ga-brand .custom-logo, .custom-logo-link img { max-height: 58px; width: auto; }
|
||||
.ga-brand__mark { width: 46px; height: 46px; flex: none; }
|
||||
.ga-brand__mark { width: 54px; height: auto; flex: none; }
|
||||
.ga-brand__mark svg, .ga-brand__logo svg { display: block; width: 100%; height: auto; }
|
||||
.ga-brand__logo { width: 76px; display: block; }
|
||||
.ga-footer .ga-brand__logo { width: 150px; }
|
||||
.ga-footer .ga-logo__text { fill: var(--ga-sand); }
|
||||
.ga-brand__name { display: flex; flex-direction: column; }
|
||||
.ga-brand__name b { font: 800 1.08rem/1.02 var(--ga-serif); letter-spacing: -.01em; }
|
||||
.ga-brand__name small { margin-top: 4px; font: 700 .66rem/1 var(--ga-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ga-muted); }
|
||||
@@ -224,7 +228,8 @@ p { margin: 0 0 1.1em; }
|
||||
.ga-brand__name small { display: none; }
|
||||
.ga-header .ga-wrap { gap: 10px; min-height: 68px; }
|
||||
.ga-brand { gap: 9px; }
|
||||
.ga-brand__mark { width: 40px; height: 40px; }
|
||||
.ga-brand__mark { width: 44px; }
|
||||
.ga-brand__logo { width: 60px; }
|
||||
.ga-brand__name b { font-size: .96rem; }
|
||||
.ga-header__actions { gap: 8px; }
|
||||
.ga-menu-toggle { padding: 8px 10px; }
|
||||
@@ -262,7 +267,11 @@ body { overflow-x: clip; }
|
||||
color-mix(in srgb, var(--ga-green) calc(var(--ga-overlay, .7) * 80%), transparent) 55%,
|
||||
color-mix(in srgb, var(--ga-green) calc(var(--ga-overlay, .7) * 35%), transparent) 100%);
|
||||
}
|
||||
.ga-hero__paw { position: absolute; right: -40px; bottom: -60px; width: min(46vw, 540px); color: #fff; opacity: .07; transform: rotate(-16deg); z-index: 1; }
|
||||
.ga-hero__paw { position: absolute; right: 2%; bottom: 0; width: min(44vw, 560px); color: #fff; opacity: .09; z-index: 1; }
|
||||
.ga-hero__paw svg { display: block; width: 100%; height: auto; }
|
||||
.ga-hero__paw .ga-logo__arch { fill: none; }
|
||||
.ga-hero__paw .ga-logo__animals { fill: #fff; }
|
||||
.has-doors .ga-hero__paw { bottom: 0; }
|
||||
|
||||
/* Dos columnas */
|
||||
.ga-hero--split { background: var(--ga-sand); padding: clamp(56px, 8vw, 110px) 0; }
|
||||
@@ -605,7 +614,7 @@ ol.is-style-ga-pasos li::before {
|
||||
/* =========================================================================
|
||||
Pie
|
||||
========================================================================= */
|
||||
.ga-footer { background: var(--ga-footer-bg); color: color-mix(in srgb, #fff 72%, var(--ga-footer-bg)); padding: 72px 0 28px; font-size: .95rem; }
|
||||
.ga-footer { border-top: 1px solid rgba(255, 255, 255, .08); background: var(--ga-footer-bg); color: color-mix(in srgb, #fff 72%, var(--ga-footer-bg)); padding: 72px 0 28px; font-size: .95rem; }
|
||||
.ga-footer a { color: #fff; text-decoration: none; }
|
||||
.ga-footer a:hover { text-decoration: underline; color: #fff; }
|
||||
.ga-footer__grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.1fr; gap: 40px; }
|
||||
|
||||
@@ -36,7 +36,7 @@ if ( $doors ) {
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif ( $full ) : ?>
|
||||
<div class="ga-hero__paw" aria-hidden="true"><?php echo ga_icon( 'paw' ); ?></div>
|
||||
<div class="ga-hero__paw" aria-hidden="true"><?php echo ga_logo_svg( 'mark' ) ?: ga_icon( 'paw' ); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="ga-wrap ga-hero__inner">
|
||||
|
||||
Reference in New Issue
Block a user