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