454 lines
18 KiB
PHP
454 lines
18 KiB
PHP
<?php
|
|
/**
|
|
* Registro de campos ACF
|
|
*
|
|
* @package Bloques_Transicion
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class Bloques_ACF_Fields {
|
|
|
|
/**
|
|
* Registrar todos los grupos de campos
|
|
*/
|
|
public static function register() {
|
|
add_action('acf/init', [__CLASS__, 'register_field_groups']);
|
|
}
|
|
|
|
/**
|
|
* Registrar grupos de campos ACF
|
|
*/
|
|
public static function register_field_groups() {
|
|
if (!function_exists('acf_add_local_field_group')) {
|
|
return;
|
|
}
|
|
|
|
self::register_actuacion_fields();
|
|
self::register_recurso_fields();
|
|
self::register_evento_fields();
|
|
self::register_iniciativa_fields();
|
|
self::register_linea_trabajo_fields();
|
|
}
|
|
|
|
/**
|
|
* Campos para Actuaciones
|
|
*/
|
|
private static function register_actuacion_fields() {
|
|
acf_add_local_field_group([
|
|
'key' => 'group_bloques_actuacion',
|
|
'title' => __('Datos de la Actuación', 'bloques-transicion'),
|
|
'fields' => [
|
|
// Es piloto
|
|
[
|
|
'key' => 'field_actuacion_es_piloto',
|
|
'label' => __('Es actuación piloto', 'bloques-transicion'),
|
|
'name' => 'es_piloto',
|
|
'type' => 'true_false',
|
|
'instructions' => __('Marcar si esta actuación es un proyecto piloto', 'bloques-transicion'),
|
|
'ui' => 1,
|
|
'ui_on_text' => __('Sí', 'bloques-transicion'),
|
|
'ui_off_text' => __('No', 'bloques-transicion'),
|
|
'default_value' => 0,
|
|
],
|
|
// Tab Ubicación
|
|
[
|
|
'key' => 'field_actuacion_tab_ubicacion',
|
|
'label' => __('Ubicación', 'bloques-transicion'),
|
|
'name' => '',
|
|
'type' => 'tab',
|
|
'placement' => 'top',
|
|
],
|
|
// Dirección
|
|
[
|
|
'key' => 'field_actuacion_direccion',
|
|
'label' => __('Dirección', 'bloques-transicion'),
|
|
'name' => 'direccion',
|
|
'type' => 'text',
|
|
'instructions' => __('Dirección completa', 'bloques-transicion'),
|
|
],
|
|
// Localidad
|
|
[
|
|
'key' => 'field_actuacion_localidad',
|
|
'label' => __('Localidad', 'bloques-transicion'),
|
|
'name' => 'localidad',
|
|
'type' => 'text',
|
|
'instructions' => __('Ciudad o barrio', 'bloques-transicion'),
|
|
],
|
|
// Latitud
|
|
[
|
|
'key' => 'field_actuacion_latitud',
|
|
'label' => __('Latitud', 'bloques-transicion'),
|
|
'name' => 'latitud',
|
|
'type' => 'number',
|
|
'instructions' => __('Coordenada de latitud (ej: 40.4168)', 'bloques-transicion'),
|
|
'step' => 'any',
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Longitud
|
|
[
|
|
'key' => 'field_actuacion_longitud',
|
|
'label' => __('Longitud', 'bloques-transicion'),
|
|
'name' => 'longitud',
|
|
'type' => 'number',
|
|
'instructions' => __('Coordenada de longitud (ej: -3.7038)', 'bloques-transicion'),
|
|
'step' => 'any',
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Mapa (Google Maps si está disponible, sino texto)
|
|
[
|
|
'key' => 'field_actuacion_mapa',
|
|
'label' => __('Seleccionar en mapa', 'bloques-transicion'),
|
|
'name' => 'mapa',
|
|
'type' => 'google_map',
|
|
'instructions' => __('Haz clic en el mapa para obtener las coordenadas automáticamente', 'bloques-transicion'),
|
|
'center_lat' => '40.4168',
|
|
'center_lng' => '-3.7038',
|
|
'zoom' => 12,
|
|
'conditional_logic' => [
|
|
[
|
|
[
|
|
'field' => 'field_actuacion_latitud',
|
|
'operator' => '==empty',
|
|
],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'location' => [
|
|
[
|
|
[
|
|
'param' => 'post_type',
|
|
'operator' => '==',
|
|
'value' => 'actuacion',
|
|
],
|
|
],
|
|
],
|
|
'menu_order' => 0,
|
|
'position' => 'normal',
|
|
'style' => 'default',
|
|
'label_placement' => 'top',
|
|
'instruction_placement' => 'label',
|
|
'active' => true,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Campos para Recursos
|
|
*/
|
|
private static function register_recurso_fields() {
|
|
acf_add_local_field_group([
|
|
'key' => 'group_bloques_recurso',
|
|
'title' => __('Datos del Recurso', 'bloques-transicion'),
|
|
'fields' => [
|
|
// Archivo
|
|
[
|
|
'key' => 'field_recurso_archivo',
|
|
'label' => __('Archivo', 'bloques-transicion'),
|
|
'name' => 'archivo',
|
|
'type' => 'file',
|
|
'instructions' => __('Sube el archivo del recurso (PDF, DOC, JPG, PNG, etc.)', 'bloques-transicion'),
|
|
'required' => 0,
|
|
'return_format' => 'array',
|
|
'library' => 'all',
|
|
'mime_types' => 'pdf,doc,docx,xls,xlsx,ppt,pptx,jpg,jpeg,png,gif,zip',
|
|
],
|
|
// Tipo de recurso (informativo)
|
|
[
|
|
'key' => 'field_recurso_tipo',
|
|
'label' => __('Tipo de Recurso', 'bloques-transicion'),
|
|
'name' => 'tipo_recurso',
|
|
'type' => 'select',
|
|
'instructions' => __('Categoría del tipo de recurso', 'bloques-transicion'),
|
|
'choices' => [
|
|
'documento' => __('Documento', 'bloques-transicion'),
|
|
'guia' => __('Guía', 'bloques-transicion'),
|
|
'informe' => __('Informe', 'bloques-transicion'),
|
|
'presentacion' => __('Presentación', 'bloques-transicion'),
|
|
'video' => __('Vídeo', 'bloques-transicion'),
|
|
'imagen' => __('Imagen', 'bloques-transicion'),
|
|
'otro' => __('Otro', 'bloques-transicion'),
|
|
],
|
|
'default_value' => 'documento',
|
|
'allow_null' => 0,
|
|
'return_format' => 'value',
|
|
],
|
|
// URL externa (alternativa al archivo)
|
|
[
|
|
'key' => 'field_recurso_url_externa',
|
|
'label' => __('URL Externa', 'bloques-transicion'),
|
|
'name' => 'url_externa',
|
|
'type' => 'url',
|
|
'instructions' => __('Si el recurso está alojado externamente (YouTube, Drive, etc.)', 'bloques-transicion'),
|
|
],
|
|
],
|
|
'location' => [
|
|
[
|
|
[
|
|
'param' => 'post_type',
|
|
'operator' => '==',
|
|
'value' => 'recurso_bloques',
|
|
],
|
|
],
|
|
],
|
|
'menu_order' => 0,
|
|
'position' => 'normal',
|
|
'style' => 'default',
|
|
'label_placement' => 'top',
|
|
'instruction_placement' => 'label',
|
|
'active' => true,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Campos para Eventos
|
|
*/
|
|
private static function register_evento_fields() {
|
|
acf_add_local_field_group([
|
|
'key' => 'group_bloques_evento',
|
|
'title' => __('Datos del Evento', 'bloques-transicion'),
|
|
'fields' => [
|
|
// Tab Fecha y Hora
|
|
[
|
|
'key' => 'field_evento_tab_fecha',
|
|
'label' => __('Fecha y Hora', 'bloques-transicion'),
|
|
'name' => '',
|
|
'type' => 'tab',
|
|
'placement' => 'top',
|
|
],
|
|
// Fecha inicio
|
|
[
|
|
'key' => 'field_evento_fecha_inicio',
|
|
'label' => __('Fecha de inicio', 'bloques-transicion'),
|
|
'name' => 'fecha_inicio',
|
|
'type' => 'date_picker',
|
|
'instructions' => __('Fecha en que comienza el evento', 'bloques-transicion'),
|
|
'required' => 1,
|
|
'display_format' => 'd/m/Y',
|
|
'return_format' => 'Y-m-d',
|
|
'first_day' => 1,
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Hora inicio
|
|
[
|
|
'key' => 'field_evento_hora_inicio',
|
|
'label' => __('Hora de inicio', 'bloques-transicion'),
|
|
'name' => 'hora_inicio',
|
|
'type' => 'time_picker',
|
|
'instructions' => __('Hora de inicio del evento', 'bloques-transicion'),
|
|
'display_format' => 'H:i',
|
|
'return_format' => 'H:i',
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Fecha fin
|
|
[
|
|
'key' => 'field_evento_fecha_fin',
|
|
'label' => __('Fecha de fin', 'bloques-transicion'),
|
|
'name' => 'fecha_fin',
|
|
'type' => 'date_picker',
|
|
'instructions' => __('Fecha en que termina el evento (opcional)', 'bloques-transicion'),
|
|
'display_format' => 'd/m/Y',
|
|
'return_format' => 'Y-m-d',
|
|
'first_day' => 1,
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Hora fin
|
|
[
|
|
'key' => 'field_evento_hora_fin',
|
|
'label' => __('Hora de fin', 'bloques-transicion'),
|
|
'name' => 'hora_fin',
|
|
'type' => 'time_picker',
|
|
'instructions' => __('Hora de finalización (opcional)', 'bloques-transicion'),
|
|
'display_format' => 'H:i',
|
|
'return_format' => 'H:i',
|
|
'wrapper' => ['width' => '50'],
|
|
],
|
|
// Tab Ubicación
|
|
[
|
|
'key' => 'field_evento_tab_ubicacion',
|
|
'label' => __('Ubicación', 'bloques-transicion'),
|
|
'name' => '',
|
|
'type' => 'tab',
|
|
'placement' => 'top',
|
|
],
|
|
// Lugar
|
|
[
|
|
'key' => 'field_evento_lugar',
|
|
'label' => __('Lugar', 'bloques-transicion'),
|
|
'name' => 'lugar',
|
|
'type' => 'text',
|
|
'instructions' => __('Nombre del lugar donde se celebra', 'bloques-transicion'),
|
|
],
|
|
// Dirección
|
|
[
|
|
'key' => 'field_evento_direccion',
|
|
'label' => __('Dirección', 'bloques-transicion'),
|
|
'name' => 'direccion',
|
|
'type' => 'text',
|
|
],
|
|
// URL Online
|
|
[
|
|
'key' => 'field_evento_url_online',
|
|
'label' => __('Enlace para evento online', 'bloques-transicion'),
|
|
'name' => 'url_online',
|
|
'type' => 'url',
|
|
'instructions' => __('URL de Zoom, Meet, YouTube, etc. para eventos online', 'bloques-transicion'),
|
|
],
|
|
// Tab Inscripción
|
|
[
|
|
'key' => 'field_evento_tab_inscripcion',
|
|
'label' => __('Inscripción', 'bloques-transicion'),
|
|
'name' => '',
|
|
'type' => 'tab',
|
|
'placement' => 'top',
|
|
],
|
|
// URL inscripción
|
|
[
|
|
'key' => 'field_evento_url_inscripcion',
|
|
'label' => __('URL de inscripción', 'bloques-transicion'),
|
|
'name' => 'url_inscripcion',
|
|
'type' => 'url',
|
|
'instructions' => __('Enlace al formulario de inscripción', 'bloques-transicion'),
|
|
],
|
|
// Plazas
|
|
[
|
|
'key' => 'field_evento_plazas',
|
|
'label' => __('Número de plazas', 'bloques-transicion'),
|
|
'name' => 'plazas',
|
|
'type' => 'number',
|
|
'instructions' => __('Aforo máximo (dejar vacío si no hay límite)', 'bloques-transicion'),
|
|
'min' => 0,
|
|
],
|
|
],
|
|
'location' => [
|
|
[
|
|
[
|
|
'param' => 'post_type',
|
|
'operator' => '==',
|
|
'value' => 'evento_bloques',
|
|
],
|
|
],
|
|
],
|
|
'menu_order' => 0,
|
|
'position' => 'normal',
|
|
'style' => 'default',
|
|
'label_placement' => 'top',
|
|
'instruction_placement' => 'label',
|
|
'active' => true,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Campos para taxonomía Iniciativas
|
|
*/
|
|
private static function register_iniciativa_fields() {
|
|
acf_add_local_field_group([
|
|
'key' => 'group_bloques_iniciativa_tax',
|
|
'title' => __('Datos de la Iniciativa', 'bloques-transicion'),
|
|
'fields' => [
|
|
// Icono
|
|
[
|
|
'key' => 'field_iniciativa_icono',
|
|
'label' => __('Icono', 'bloques-transicion'),
|
|
'name' => 'icono',
|
|
'type' => 'image',
|
|
'instructions' => __('Icono representativo de la iniciativa (SVG o PNG recomendado)', 'bloques-transicion'),
|
|
'return_format' => 'url',
|
|
'preview_size' => 'thumbnail',
|
|
'library' => 'all',
|
|
'mime_types' => 'svg,png,jpg,jpeg',
|
|
],
|
|
// Color
|
|
[
|
|
'key' => 'field_iniciativa_color',
|
|
'label' => __('Color', 'bloques-transicion'),
|
|
'name' => 'color',
|
|
'type' => 'color_picker',
|
|
'instructions' => __('Color identificativo de la iniciativa', 'bloques-transicion'),
|
|
'default_value' => '#1E6B52',
|
|
],
|
|
// Ubicación
|
|
[
|
|
'key' => 'field_iniciativa_ubicacion',
|
|
'label' => __('Ubicación', 'bloques-transicion'),
|
|
'name' => 'ubicacion_texto',
|
|
'type' => 'text',
|
|
'instructions' => __('Texto descriptivo de la ubicación (ej: "Puente y Villa de Vallecas")', 'bloques-transicion'),
|
|
],
|
|
// Estado
|
|
[
|
|
'key' => 'field_iniciativa_estado',
|
|
'label' => __('Estado', 'bloques-transicion'),
|
|
'name' => 'estado',
|
|
'type' => 'text',
|
|
'instructions' => __('Estado actual de la iniciativa (ej: "En proceso", "Abierta")', 'bloques-transicion'),
|
|
],
|
|
],
|
|
'location' => [
|
|
[
|
|
[
|
|
'param' => 'taxonomy',
|
|
'operator' => '==',
|
|
'value' => 'iniciativa',
|
|
],
|
|
],
|
|
],
|
|
'menu_order' => 0,
|
|
'position' => 'normal',
|
|
'style' => 'default',
|
|
'label_placement' => 'top',
|
|
'instruction_placement' => 'label',
|
|
'active' => true,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Campos para taxonomía Líneas de Trabajo
|
|
*/
|
|
private static function register_linea_trabajo_fields() {
|
|
acf_add_local_field_group([
|
|
'key' => 'group_bloques_linea_trabajo_tax',
|
|
'title' => __('Datos de la Línea de Trabajo', 'bloques-transicion'),
|
|
'fields' => [
|
|
// Icono
|
|
[
|
|
'key' => 'field_linea_trabajo_icono',
|
|
'label' => __('Icono', 'bloques-transicion'),
|
|
'name' => 'icono',
|
|
'type' => 'image',
|
|
'instructions' => __('Icono representativo de la línea de trabajo', 'bloques-transicion'),
|
|
'return_format' => 'url',
|
|
'preview_size' => 'thumbnail',
|
|
'library' => 'all',
|
|
'mime_types' => 'svg,png,jpg,jpeg',
|
|
],
|
|
// Color (opcional para líneas de trabajo)
|
|
[
|
|
'key' => 'field_linea_trabajo_color',
|
|
'label' => __('Color', 'bloques-transicion'),
|
|
'name' => 'color',
|
|
'type' => 'color_picker',
|
|
'instructions' => __('Color identificativo (opcional)', 'bloques-transicion'),
|
|
],
|
|
],
|
|
'location' => [
|
|
[
|
|
[
|
|
'param' => 'taxonomy',
|
|
'operator' => '==',
|
|
'value' => 'linea_trabajo',
|
|
],
|
|
],
|
|
],
|
|
'menu_order' => 0,
|
|
'position' => 'normal',
|
|
'style' => 'default',
|
|
'label_placement' => 'top',
|
|
'instruction_placement' => 'label',
|
|
'active' => true,
|
|
]);
|
|
}
|
|
}
|