backup: estado antes de limpieza de defaults
This commit is contained in:
173
admin/includes/sanitizers/class-herosection-sanitizer.php
Normal file
173
admin/includes/sanitizers/class-herosection-sanitizer.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?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')
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user