FASE 1 COMPLETADA: Limpieza de defaults hardcodeados
Eliminados todos los componentes incorrectos y defaults duplicados preparando el sistema para la implementación correcta con tabla de BD. ARCHIVOS ELIMINADOS (11 archivos): - admin/assets/js/component-navbar.js - admin/assets/css/component-navbar.css - admin/components/component-top-bar.php - admin/components/component-navbar.php - admin/components/component-hero-section.php - admin/components/component-lets-talk-button.php - admin/includes/sanitizers/class-topbar-sanitizer.php - admin/includes/sanitizers/class-navbar-sanitizer.php - admin/includes/sanitizers/class-herosection-sanitizer.php - admin/includes/sanitizers/class-letstalkbutton-sanitizer.php - template-parts/navbar-configurable.php ARCHIVOS MODIFICADOS (6 archivos): - admin/includes/class-admin-menu.php: Eliminados enqueues de componentes - admin/includes/class-settings-manager.php: Limpiados get_defaults() y sanitize_settings() - admin/includes/class-validator.php: Eliminado validate_top_bar() - admin/pages/main.php: Reducido de 521 a 37 líneas (93%) - admin/assets/js/admin-app.js: Reducido de 431 a 219 líneas (49%) - header.php: Eliminado código de Top Bar (92 líneas) BASE DE DATOS: - Eliminada opción 'apus_theme_settings' de wp_options RESUMEN: - 11 archivos eliminados - 6 archivos limpiados - 1 opción de BD eliminada - Todos los defaults hardcodeados eliminados - Sistema preparado para FASE 2 (crear tabla de defaults) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -80,13 +80,6 @@ class APUS_Admin_Menu {
|
||||
APUS_ADMIN_PANEL_VERSION
|
||||
);
|
||||
|
||||
// Component: Navbar CSS (estilos admin específicos)
|
||||
wp_enqueue_style(
|
||||
'apus-component-navbar-css',
|
||||
APUS_ADMIN_PANEL_URL . 'assets/css/component-navbar.css',
|
||||
array('apus-admin-panel-css'),
|
||||
APUS_ADMIN_PANEL_VERSION
|
||||
);
|
||||
|
||||
// Bootstrap 5.3.2 JS
|
||||
wp_enqueue_script(
|
||||
@@ -106,20 +99,12 @@ class APUS_Admin_Menu {
|
||||
true
|
||||
);
|
||||
|
||||
// Component: Navbar JS (cargar antes de admin-app.js)
|
||||
wp_enqueue_script(
|
||||
'apus-component-navbar-js',
|
||||
APUS_ADMIN_PANEL_URL . 'assets/js/component-navbar.js',
|
||||
array('jquery'),
|
||||
APUS_ADMIN_PANEL_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
// Admin Panel JS (Core - depende de componentes)
|
||||
// Admin Panel JS (Core)
|
||||
wp_enqueue_script(
|
||||
'apus-admin-panel-js',
|
||||
APUS_ADMIN_PANEL_URL . 'assets/js/admin-app.js',
|
||||
array('jquery', 'axios', 'apus-component-navbar-js'),
|
||||
array('jquery', 'axios'),
|
||||
APUS_ADMIN_PANEL_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
@@ -68,74 +68,27 @@ class APUS_Settings_Manager {
|
||||
|
||||
/**
|
||||
* Valores por defecto
|
||||
* NOTA: Aquí se agregan los defaults de cada componente
|
||||
* NOTA: Los defaults se cargarán desde la tabla wp_apus_theme_components_defaults
|
||||
*/
|
||||
public function get_defaults() {
|
||||
return array(
|
||||
'version' => APUS_ADMIN_PANEL_VERSION,
|
||||
'components' => array(
|
||||
'top_bar' => array(
|
||||
'enabled' => true,
|
||||
'show_on_mobile' => true,
|
||||
'show_on_desktop' => true,
|
||||
'icon_class' => 'bi bi-megaphone-fill',
|
||||
'show_icon' => true,
|
||||
'highlight_text' => 'Nuevo:',
|
||||
'message_text' => 'Accede a más de 200,000 Análisis de Precios Unitarios actualizados para 2025.',
|
||||
'link_text' => 'Ver Catálogo',
|
||||
'link_url' => '/catalogo',
|
||||
'link_target' => '_self',
|
||||
'show_link' => true,
|
||||
'custom_styles' => array(
|
||||
// Valores extraídos de componente-top-bar.css
|
||||
'background_color' => '#0E2337', // var(--color-navy-dark)
|
||||
'text_color' => '#ffffff',
|
||||
'highlight_color' => '#FF8600', // var(--color-orange-primary)
|
||||
'link_hover_color' => '#FF8600', // var(--color-orange-primary)
|
||||
'font_size' => 'normal' // 0.9rem del CSS
|
||||
)
|
||||
)
|
||||
// Navbar - Pendiente
|
||||
// Hero - Pendiente
|
||||
// Footer - Pendiente
|
||||
// Los componentes se agregarán aquí cuando se ejecute el algoritmo
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizar configuraciones
|
||||
* NOTA: Aquí se agrega sanitización de cada componente
|
||||
* NOTA: Los sanitizers de componentes se ejecutarán aquí cuando se implementen
|
||||
*/
|
||||
public function sanitize_settings($data) {
|
||||
$sanitized = array(
|
||||
'components' => array()
|
||||
);
|
||||
|
||||
// Sanitizar Top Bar
|
||||
if (isset($data['components']['top_bar'])) {
|
||||
$top_bar = $data['components']['top_bar'];
|
||||
|
||||
$sanitized['components']['top_bar'] = array(
|
||||
'enabled' => !empty($top_bar['enabled']),
|
||||
'show_on_mobile' => !empty($top_bar['show_on_mobile']),
|
||||
'show_on_desktop' => !empty($top_bar['show_on_desktop']),
|
||||
'icon_class' => sanitize_text_field($top_bar['icon_class'] ?? ''),
|
||||
'show_icon' => !empty($top_bar['show_icon']),
|
||||
'highlight_text' => sanitize_text_field($top_bar['highlight_text'] ?? ''),
|
||||
'message_text' => sanitize_text_field($top_bar['message_text'] ?? ''),
|
||||
'link_text' => sanitize_text_field($top_bar['link_text'] ?? ''),
|
||||
'link_url' => esc_url_raw($top_bar['link_url'] ?? ''),
|
||||
'link_target' => in_array($top_bar['link_target'] ?? '', array('_self', '_blank')) ? $top_bar['link_target'] : '_self',
|
||||
'show_link' => !empty($top_bar['show_link']),
|
||||
'custom_styles' => array(
|
||||
'background_color' => sanitize_hex_color($top_bar['custom_styles']['background_color'] ?? ''),
|
||||
'text_color' => sanitize_hex_color($top_bar['custom_styles']['text_color'] ?? ''),
|
||||
'highlight_color' => sanitize_hex_color($top_bar['custom_styles']['highlight_color'] ?? ''),
|
||||
'link_hover_color' => sanitize_hex_color($top_bar['custom_styles']['link_hover_color'] ?? ''),
|
||||
'font_size' => in_array($top_bar['custom_styles']['font_size'] ?? '', array('small', 'normal', 'large')) ? $top_bar['custom_styles']['font_size'] : 'normal'
|
||||
)
|
||||
);
|
||||
}
|
||||
// Los componentes se sanitizarán aquí cuando se ejecute el algoritmo
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class APUS_Validator {
|
||||
|
||||
/**
|
||||
* Validar todas las configuraciones
|
||||
* Los validators de componentes se ejecutarán aquí cuando se implementen
|
||||
*/
|
||||
public function validate($data) {
|
||||
$errors = array();
|
||||
@@ -26,81 +27,11 @@ class APUS_Validator {
|
||||
return array('valid' => false, 'errors' => $errors);
|
||||
}
|
||||
|
||||
// Validar Top Bar
|
||||
if (isset($data['components']['top_bar'])) {
|
||||
$top_bar_errors = $this->validate_top_bar($data['components']['top_bar']);
|
||||
$errors = array_merge($errors, $top_bar_errors);
|
||||
}
|
||||
// Los componentes se validarán aquí cuando se ejecute el algoritmo
|
||||
|
||||
return array(
|
||||
'valid' => empty($errors),
|
||||
'errors' => $errors
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validar Top Bar
|
||||
*/
|
||||
public function validate_top_bar($top_bar) {
|
||||
$errors = array();
|
||||
|
||||
// Validar icon_class
|
||||
if (!empty($top_bar['icon_class']) && strlen($top_bar['icon_class']) > 50) {
|
||||
$errors[] = 'La clase del icono no puede exceder 50 caracteres';
|
||||
}
|
||||
|
||||
// Validar highlight_text
|
||||
if (!empty($top_bar['highlight_text']) && strlen($top_bar['highlight_text']) > 30) {
|
||||
$errors[] = 'El texto destacado no puede exceder 30 caracteres';
|
||||
}
|
||||
|
||||
// Validar message_text
|
||||
if (empty($top_bar['message_text'])) {
|
||||
$errors[] = 'El mensaje principal es obligatorio';
|
||||
} elseif (strlen($top_bar['message_text']) > 250) {
|
||||
$errors[] = 'El mensaje principal no puede exceder 250 caracteres';
|
||||
}
|
||||
|
||||
// Validar link_text
|
||||
if (!empty($top_bar['link_text']) && strlen($top_bar['link_text']) > 50) {
|
||||
$errors[] = 'El texto del enlace no puede exceder 50 caracteres';
|
||||
}
|
||||
|
||||
// Validar link_url (acepta URLs completas y relativas que empiecen con /)
|
||||
if (!empty($top_bar['link_url'])) {
|
||||
$url = $top_bar['link_url'];
|
||||
$is_valid_url = filter_var($url, FILTER_VALIDATE_URL) !== false;
|
||||
$is_relative_url = preg_match('/^\//', $url);
|
||||
|
||||
if (!$is_valid_url && !$is_relative_url) {
|
||||
$errors[] = 'La URL del enlace no es válida';
|
||||
}
|
||||
}
|
||||
|
||||
// Validar link_target
|
||||
if (!in_array($top_bar['link_target'] ?? '', array('_self', '_blank'))) {
|
||||
$errors[] = 'El target del enlace debe ser _self o _blank';
|
||||
}
|
||||
|
||||
// Validar colores
|
||||
if (!empty($top_bar['custom_styles']['background_color']) && !preg_match('/^#[a-f0-9]{6}$/i', $top_bar['custom_styles']['background_color'])) {
|
||||
$errors[] = 'El color de fondo debe ser un color hexadecimal válido';
|
||||
}
|
||||
if (!empty($top_bar['custom_styles']['text_color']) && !preg_match('/^#[a-f0-9]{6}$/i', $top_bar['custom_styles']['text_color'])) {
|
||||
$errors[] = 'El color de texto debe ser un color hexadecimal válido';
|
||||
}
|
||||
if (!empty($top_bar['custom_styles']['highlight_color']) && !preg_match('/^#[a-f0-9]{6}$/i', $top_bar['custom_styles']['highlight_color'])) {
|
||||
$errors[] = 'El color del highlight debe ser un color hexadecimal válido';
|
||||
}
|
||||
if (!empty($top_bar['custom_styles']['link_hover_color']) && !preg_match('/^#[a-f0-9]{6}$/i', $top_bar['custom_styles']['link_hover_color'])) {
|
||||
$errors[] = 'El color hover del enlace debe ser un color hexadecimal válido';
|
||||
}
|
||||
|
||||
// Validar font_size
|
||||
if (!in_array($top_bar['custom_styles']['font_size'] ?? '', array('small', 'normal', 'large'))) {
|
||||
$errors[] = 'El tamaño de fuente debe ser small, normal o large';
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Hero Section Sanitizer
|
||||
*
|
||||
* Sanitiza configuraciones del componente Hero Section
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @subpackage Admin_Panel\Sanitizers
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class APUS_HeroSection_Sanitizer
|
||||
*
|
||||
* Sanitiza todas las configuraciones del componente Hero Section
|
||||
*/
|
||||
class APUS_HeroSection_Sanitizer {
|
||||
|
||||
/**
|
||||
* Obtiene los valores por defecto del Hero Section
|
||||
*
|
||||
* @return array Valores por defecto
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_defaults() {
|
||||
return array(
|
||||
// Activación y Visibilidad
|
||||
'enabled' => true,
|
||||
'show_on_mobile' => true,
|
||||
'show_on_desktop' => true,
|
||||
|
||||
// Contenido y Estructura
|
||||
'show_category_badges' => true,
|
||||
'category_badge_icon' => 'bi bi-folder-fill',
|
||||
'excluded_categories' => array('Uncategorized', 'Sin categoría'),
|
||||
'title_alignment' => 'center',
|
||||
'title_display_class' => 'display-5',
|
||||
|
||||
// Colores del Hero
|
||||
'use_gradient_background' => true,
|
||||
'gradient_start_color' => '#1e3a5f',
|
||||
'gradient_end_color' => '#2c5282',
|
||||
'gradient_angle' => 135,
|
||||
'hero_text_color' => '#ffffff',
|
||||
'solid_background_color' => '#1e3a5f',
|
||||
|
||||
// Colores de Category Badges
|
||||
'badge_bg_color' => 'rgba(255, 255, 255, 0.15)',
|
||||
'badge_bg_hover_color' => 'rgba(255, 133, 0, 0.2)',
|
||||
'badge_border_color' => 'rgba(255, 255, 255, 0.2)',
|
||||
'badge_text_color' => 'rgba(255, 255, 255, 0.95)',
|
||||
'badge_icon_color' => '#FFB800',
|
||||
|
||||
// Espaciado y Dimensiones
|
||||
'hero_padding_vertical' => 3.0,
|
||||
'hero_padding_horizontal' => 0.0,
|
||||
'hero_margin_bottom' => 1.5,
|
||||
'badges_gap' => 0.5,
|
||||
'badge_padding_vertical' => 0.375,
|
||||
'badge_padding_horizontal' => 0.875,
|
||||
'badge_border_radius' => 20,
|
||||
|
||||
// Tipografía
|
||||
'h1_font_weight' => 700,
|
||||
'badge_font_size' => 0.813,
|
||||
'badge_font_weight' => 500,
|
||||
'h1_line_height' => 1.4,
|
||||
|
||||
// Efectos Visuales
|
||||
'enable_h1_text_shadow' => true,
|
||||
'h1_text_shadow' => '1px 1px 2px rgba(0, 0, 0, 0.2)',
|
||||
'enable_hero_box_shadow' => true,
|
||||
'hero_box_shadow' => '0 4px 16px rgba(30, 58, 95, 0.25)',
|
||||
'enable_badge_backdrop_filter' => true,
|
||||
'badge_backdrop_filter' => 'blur(10px)',
|
||||
|
||||
// Transiciones y Animaciones
|
||||
'badge_transition_speed' => 'normal',
|
||||
'badge_hover_effect' => 'background',
|
||||
|
||||
// Avanzado
|
||||
'custom_hero_classes' => '',
|
||||
'custom_badge_classes' => ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitiza los datos del Hero Section
|
||||
*
|
||||
* @param array $data Datos sin sanitizar del Hero Section
|
||||
* @return array Datos sanitizados
|
||||
*/
|
||||
public function sanitize($data) {
|
||||
return array_merge(
|
||||
// Activación y Visibilidad - Booleanos
|
||||
APUS_Sanitizer_Helper::sanitize_booleans($data, array(
|
||||
'enabled', 'show_on_mobile', 'show_on_desktop', 'show_category_badges',
|
||||
'use_gradient_background', 'enable_h1_text_shadow', 'enable_hero_box_shadow',
|
||||
'enable_badge_backdrop_filter'
|
||||
)),
|
||||
|
||||
// Contenido y Estructura - Textos
|
||||
APUS_Sanitizer_Helper::sanitize_texts($data, array(
|
||||
'category_badge_icon' => 'bi bi-folder-fill',
|
||||
'title_display_class' => 'display-5',
|
||||
'h1_text_shadow' => '1px 1px 2px rgba(0, 0, 0, 0.2)',
|
||||
'hero_box_shadow' => '0 4px 16px rgba(30, 58, 95, 0.25)',
|
||||
'badge_backdrop_filter' => 'blur(10px)',
|
||||
'custom_hero_classes' => '',
|
||||
'custom_badge_classes' => ''
|
||||
)),
|
||||
|
||||
// Colores de Category Badges - RGBA strings (text)
|
||||
array(
|
||||
'badge_bg_color' => APUS_Sanitizer_Helper::sanitize_text($data, 'badge_bg_color', 'rgba(255, 255, 255, 0.15)'),
|
||||
'badge_bg_hover_color' => APUS_Sanitizer_Helper::sanitize_text($data, 'badge_bg_hover_color', 'rgba(255, 133, 0, 0.2)'),
|
||||
'badge_border_color' => APUS_Sanitizer_Helper::sanitize_text($data, 'badge_border_color', 'rgba(255, 255, 255, 0.2)'),
|
||||
'badge_text_color' => APUS_Sanitizer_Helper::sanitize_text($data, 'badge_text_color', 'rgba(255, 255, 255, 0.95)')
|
||||
),
|
||||
|
||||
// Colores del Hero - Hex colors
|
||||
array(
|
||||
'gradient_start_color' => APUS_Sanitizer_Helper::sanitize_color($data, 'gradient_start_color', '#1e3a5f'),
|
||||
'gradient_end_color' => APUS_Sanitizer_Helper::sanitize_color($data, 'gradient_end_color', '#2c5282'),
|
||||
'hero_text_color' => APUS_Sanitizer_Helper::sanitize_color($data, 'hero_text_color', '#ffffff'),
|
||||
'solid_background_color' => APUS_Sanitizer_Helper::sanitize_color($data, 'solid_background_color', '#1e3a5f'),
|
||||
'badge_icon_color' => APUS_Sanitizer_Helper::sanitize_color($data, 'badge_icon_color', '#FFB800')
|
||||
),
|
||||
|
||||
// Enums
|
||||
APUS_Sanitizer_Helper::sanitize_enums($data, array(
|
||||
'title_alignment' => array('allowed' => array('left', 'center', 'right'), 'default' => 'center'),
|
||||
'badge_transition_speed' => array('allowed' => array('fast', 'normal', 'slow'), 'default' => 'normal'),
|
||||
'badge_hover_effect' => array('allowed' => array('none', 'background', 'scale', 'brightness'), 'default' => 'background')
|
||||
)),
|
||||
|
||||
// Enteros
|
||||
APUS_Sanitizer_Helper::sanitize_ints($data, array(
|
||||
'gradient_angle' => 135,
|
||||
'badge_border_radius' => 20
|
||||
)),
|
||||
|
||||
// Enteros en arrays (h1_font_weight, badge_font_weight)
|
||||
array(
|
||||
'h1_font_weight' => APUS_Sanitizer_Helper::sanitize_enum($data, 'h1_font_weight', array(400, 500, 600, 700), 700),
|
||||
'badge_font_weight' => APUS_Sanitizer_Helper::sanitize_enum($data, 'badge_font_weight', array(400, 500, 600, 700), 500)
|
||||
),
|
||||
|
||||
// Floats
|
||||
APUS_Sanitizer_Helper::sanitize_floats($data, array(
|
||||
'hero_padding_vertical' => 3.0,
|
||||
'hero_padding_horizontal' => 0.0,
|
||||
'hero_margin_bottom' => 1.5,
|
||||
'badges_gap' => 0.5,
|
||||
'badge_padding_vertical' => 0.375,
|
||||
'badge_padding_horizontal' => 0.875,
|
||||
'badge_font_size' => 0.813,
|
||||
'h1_line_height' => 1.4
|
||||
)),
|
||||
|
||||
// Array de strings
|
||||
array('excluded_categories' => APUS_Sanitizer_Helper::sanitize_array_of_strings(
|
||||
$data,
|
||||
'excluded_categories',
|
||||
array('Uncategorized', 'Sin categoría')
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Let's Talk Button Sanitizer
|
||||
*
|
||||
* Sanitiza configuraciones del componente Let's Talk Button
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @subpackage Admin_Panel\Sanitizers
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class APUS_LetsTalkButton_Sanitizer
|
||||
*
|
||||
* Sanitiza todas las configuraciones del componente Let's Talk Button
|
||||
*/
|
||||
class APUS_LetsTalkButton_Sanitizer {
|
||||
|
||||
/**
|
||||
* Obtiene los valores por defecto del Let's Talk Button
|
||||
*
|
||||
* @return array Valores por defecto
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_defaults() {
|
||||
return array(
|
||||
'enabled' => true,
|
||||
'text' => "Let's Talk",
|
||||
'icon_class' => 'bi bi-lightning-charge-fill',
|
||||
'show_icon' => true,
|
||||
'position' => 'right',
|
||||
'enable_box_shadow' => false,
|
||||
'hover_effect' => 'none',
|
||||
'modal_target' => '#contactModal',
|
||||
'custom_styles' => array(
|
||||
'background_color' => '#FF8600',
|
||||
'background_hover_color' => '#FF6B35',
|
||||
'text_color' => '#ffffff',
|
||||
'icon_color' => '#ffffff',
|
||||
'font_weight' => '600',
|
||||
'padding_vertical' => 0.5,
|
||||
'padding_horizontal' => 1.5,
|
||||
'border_radius' => 6,
|
||||
'border_width' => 0,
|
||||
'border_color' => '',
|
||||
'border_style' => 'solid',
|
||||
'transition_speed' => 'normal',
|
||||
'box_shadow' => '0 2px 8px rgba(0, 0, 0, 0.15)'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitiza los datos del Let's Talk Button
|
||||
*
|
||||
* @param array $data Datos sin sanitizar del Let's Talk Button
|
||||
* @return array Datos sanitizados
|
||||
*/
|
||||
public function sanitize($data) {
|
||||
return array_merge(
|
||||
// Booleanos
|
||||
APUS_Sanitizer_Helper::sanitize_booleans($data, array(
|
||||
'enabled', 'show_icon', 'enable_box_shadow'
|
||||
)),
|
||||
|
||||
// Textos
|
||||
APUS_Sanitizer_Helper::sanitize_texts($data, array(
|
||||
'text', 'icon_class', 'modal_target'
|
||||
)),
|
||||
|
||||
// Enums
|
||||
APUS_Sanitizer_Helper::sanitize_enums($data, array(
|
||||
'position' => array('allowed' => array('left', 'center', 'right'), 'default' => 'right'),
|
||||
'hover_effect' => array('allowed' => array('none', 'scale', 'brightness'), 'default' => 'none')
|
||||
)),
|
||||
|
||||
// Custom styles anidado
|
||||
array('custom_styles' => APUS_Sanitizer_Helper::sanitize_nested_group($data, 'custom_styles', array(
|
||||
'background_color' => array('type' => 'color', 'default' => ''),
|
||||
'background_hover_color' => array('type' => 'color', 'default' => ''),
|
||||
'text_color' => array('type' => 'color', 'default' => ''),
|
||||
'icon_color' => array('type' => 'color', 'default' => ''),
|
||||
'font_weight' => array('type' => 'text', 'default' => ''),
|
||||
'padding_vertical' => array('type' => 'float', 'default' => 0.0),
|
||||
'padding_horizontal' => array('type' => 'float', 'default' => 0.0),
|
||||
'border_radius' => array('type' => 'int', 'default' => 0),
|
||||
'border_width' => array('type' => 'int', 'default' => 0),
|
||||
'border_color' => array('type' => 'color', 'default' => ''),
|
||||
'border_style' => array('type' => 'enum', 'allowed' => array('solid', 'dashed', 'dotted'), 'default' => 'solid'),
|
||||
'transition_speed' => array('type' => 'enum', 'allowed' => array('fast', 'normal', 'slow'), 'default' => 'normal'),
|
||||
'box_shadow' => array('type' => 'text', 'default' => '')
|
||||
)))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Navbar Sanitizer
|
||||
*
|
||||
* Sanitiza configuraciones del componente Navbar
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @subpackage Admin_Panel\Sanitizers
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class APUS_Navbar_Sanitizer
|
||||
*
|
||||
* Sanitiza todas las configuraciones del componente Navbar
|
||||
*/
|
||||
class APUS_Navbar_Sanitizer {
|
||||
|
||||
/**
|
||||
* Obtiene los valores por defecto del Navbar
|
||||
*
|
||||
* @return array Valores por defecto
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_defaults() {
|
||||
return array(
|
||||
'enabled' => true,
|
||||
'show_on_mobile' => true,
|
||||
'show_on_desktop' => true,
|
||||
'position' => 'sticky',
|
||||
'responsive_breakpoint' => 'lg',
|
||||
'enable_box_shadow' => true,
|
||||
'enable_underline_effect' => true,
|
||||
'enable_hover_background' => true,
|
||||
|
||||
'lets_talk_button' => array(
|
||||
'enabled' => true,
|
||||
'text' => "Let's Talk",
|
||||
'icon_class' => 'bi bi-lightning-charge-fill',
|
||||
'show_icon' => true,
|
||||
'position' => 'right'
|
||||
),
|
||||
|
||||
'dropdown' => array(
|
||||
'enable_hover_desktop' => true,
|
||||
'max_height' => 70,
|
||||
'border_radius' => 8,
|
||||
'item_padding_vertical' => 0.5,
|
||||
'item_padding_horizontal' => 1.25
|
||||
),
|
||||
|
||||
'custom_styles' => array(
|
||||
'background_color' => '#1e3a5f',
|
||||
'text_color' => '#ffffff',
|
||||
'link_hover_color' => '#FF8600',
|
||||
'link_hover_bg_color' => '#FF8600',
|
||||
'dropdown_bg_color' => '#ffffff',
|
||||
'dropdown_item_color' => '#4A5568',
|
||||
'dropdown_item_hover_color' => '#FF8600',
|
||||
'font_size' => 'normal',
|
||||
'font_weight' => '500',
|
||||
'box_shadow_intensity' => 'normal',
|
||||
'border_radius' => 4,
|
||||
'padding_vertical' => 0.75,
|
||||
'link_padding_vertical' => 0.5,
|
||||
'link_padding_horizontal' => 0.65,
|
||||
'z_index' => 1030,
|
||||
'transition_speed' => 'normal'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitiza los datos del Navbar
|
||||
*
|
||||
* @param array $data Datos sin sanitizar del Navbar
|
||||
* @return array Datos sanitizados
|
||||
*/
|
||||
public function sanitize($data) {
|
||||
return array_merge(
|
||||
// Booleanos principales
|
||||
APUS_Sanitizer_Helper::sanitize_booleans($data, array(
|
||||
'enabled', 'show_on_mobile', 'show_on_desktop',
|
||||
'enable_box_shadow', 'enable_underline_effect', 'enable_hover_background'
|
||||
)),
|
||||
|
||||
// Enums principales
|
||||
APUS_Sanitizer_Helper::sanitize_enums($data, array(
|
||||
'position' => array('allowed' => array('sticky', 'static', 'fixed'), 'default' => 'sticky'),
|
||||
'responsive_breakpoint' => array('allowed' => array('sm', 'md', 'lg', 'xl', 'xxl'), 'default' => 'lg')
|
||||
)),
|
||||
|
||||
// Let's Talk Button anidado
|
||||
array('lets_talk_button' => APUS_Sanitizer_Helper::sanitize_nested_group($data, 'lets_talk_button', array(
|
||||
'enabled' => array('type' => 'bool'),
|
||||
'text' => array('type' => 'text', 'default' => ''),
|
||||
'icon_class' => array('type' => 'text', 'default' => ''),
|
||||
'show_icon' => array('type' => 'bool'),
|
||||
'position' => array('type' => 'enum', 'allowed' => array('left', 'center', 'right'), 'default' => 'right')
|
||||
))),
|
||||
|
||||
// Dropdown anidado
|
||||
array('dropdown' => APUS_Sanitizer_Helper::sanitize_nested_group($data, 'dropdown', array(
|
||||
'enable_hover_desktop' => array('type' => 'bool'),
|
||||
'max_height' => array('type' => 'int', 'default' => 70),
|
||||
'border_radius' => array('type' => 'int', 'default' => 8),
|
||||
'item_padding_vertical' => array('type' => 'float', 'default' => 0.5),
|
||||
'item_padding_horizontal' => array('type' => 'float', 'default' => 1.25)
|
||||
))),
|
||||
|
||||
// Custom styles anidado
|
||||
array('custom_styles' => APUS_Sanitizer_Helper::sanitize_nested_group($data, 'custom_styles', array(
|
||||
'background_color' => array('type' => 'color', 'default' => ''),
|
||||
'text_color' => array('type' => 'color', 'default' => ''),
|
||||
'link_hover_color' => array('type' => 'color', 'default' => ''),
|
||||
'link_hover_bg_color' => array('type' => 'color', 'default' => ''),
|
||||
'dropdown_bg_color' => array('type' => 'color', 'default' => ''),
|
||||
'dropdown_item_color' => array('type' => 'color', 'default' => ''),
|
||||
'dropdown_item_hover_color' => array('type' => 'color', 'default' => ''),
|
||||
'font_size' => array('type' => 'enum', 'allowed' => array('small', 'normal', 'large'), 'default' => 'normal'),
|
||||
'font_weight' => array('type' => 'enum', 'allowed' => array('400', '500', '600', '700'), 'default' => '500'),
|
||||
'box_shadow_intensity' => array('type' => 'enum', 'allowed' => array('none', 'light', 'normal', 'strong'), 'default' => 'normal'),
|
||||
'border_radius' => array('type' => 'int', 'default' => 4),
|
||||
'padding_vertical' => array('type' => 'float', 'default' => 0.75),
|
||||
'link_padding_vertical' => array('type' => 'float', 'default' => 0.5),
|
||||
'link_padding_horizontal' => array('type' => 'float', 'default' => 0.65),
|
||||
'z_index' => array('type' => 'int', 'default' => 1030),
|
||||
'transition_speed' => array('type' => 'enum', 'allowed' => array('fast', 'normal', 'slow'), 'default' => 'normal')
|
||||
)))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Top Bar Sanitizer
|
||||
*
|
||||
* Sanitiza configuraciones del componente Top Bar
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @subpackage Admin_Panel\Sanitizers
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class APUS_TopBar_Sanitizer
|
||||
*
|
||||
* Sanitiza todas las configuraciones del componente Top Bar
|
||||
*/
|
||||
class APUS_TopBar_Sanitizer {
|
||||
|
||||
/**
|
||||
* Obtiene los valores por defecto del Top Bar
|
||||
*
|
||||
* @return array Valores por defecto
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_defaults() {
|
||||
return array(
|
||||
'enabled' => true,
|
||||
'show_on_mobile' => true,
|
||||
'show_on_desktop' => true,
|
||||
'icon_class' => 'bi bi-megaphone-fill',
|
||||
'show_icon' => true,
|
||||
'highlight_text' => 'Nuevo:',
|
||||
'message_text' => 'Accede a más de 200,000 Análisis de Precios Unitarios actualizados para 2025.',
|
||||
'link_text' => 'Ver Catálogo',
|
||||
'link_url' => '/catalogo',
|
||||
'link_target' => '_self',
|
||||
'show_link' => true,
|
||||
'custom_styles' => array(
|
||||
'background_color' => '#0E2337',
|
||||
'text_color' => '#ffffff',
|
||||
'highlight_color' => '#FF8600',
|
||||
'link_hover_color' => '#FF8600',
|
||||
'font_size' => 'normal'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitiza los datos del Top Bar
|
||||
*
|
||||
* @param array $data Datos sin sanitizar del Top Bar
|
||||
* @return array Datos sanitizados
|
||||
*/
|
||||
public function sanitize($data) {
|
||||
return array_merge(
|
||||
// Booleanos
|
||||
APUS_Sanitizer_Helper::sanitize_booleans($data, array(
|
||||
'enabled', 'show_on_mobile', 'show_on_desktop', 'show_icon', 'show_link'
|
||||
)),
|
||||
|
||||
// Textos
|
||||
APUS_Sanitizer_Helper::sanitize_texts($data, array(
|
||||
'icon_class', 'highlight_text', 'message_text', 'link_text'
|
||||
)),
|
||||
|
||||
// URL
|
||||
array('link_url' => APUS_Sanitizer_Helper::sanitize_url($data, 'link_url')),
|
||||
|
||||
// Enum
|
||||
array('link_target' => APUS_Sanitizer_Helper::sanitize_enum(
|
||||
$data, 'link_target', array('_self', '_blank'), '_self'
|
||||
)),
|
||||
|
||||
// Custom styles anidado
|
||||
array('custom_styles' => APUS_Sanitizer_Helper::sanitize_nested_group($data, 'custom_styles', array(
|
||||
'background_color' => array('type' => 'color', 'default' => ''),
|
||||
'text_color' => array('type' => 'color', 'default' => ''),
|
||||
'highlight_color' => array('type' => 'color', 'default' => ''),
|
||||
'link_hover_color' => array('type' => 'color', 'default' => ''),
|
||||
'font_size' => array('type' => 'enum', 'allowed' => array('small', 'normal', 'large'), 'default' => 'normal')
|
||||
)))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user