89 lines
2.3 KiB
PHP
89 lines
2.3 KiB
PHP
<?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')
|
|
)))
|
|
);
|
|
}
|
|
}
|