fix(structure): Rename assets and inc folders for Linux compatibility
- assets → Assets - inc → Inc Completes the case-sensitivity fixes for Linux servers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
150
Inc/sanitize-functions.php
Normal file
150
Inc/sanitize-functions.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Funciones de sanitización para el tema ROI
|
||||
*
|
||||
* Este archivo centraliza todas las funciones de sanitización utilizadas
|
||||
* en el Customizer, panel de opciones y demás componentes del tema.
|
||||
*
|
||||
* @package ROI_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_checkbox')) {
|
||||
/**
|
||||
* Sanitiza valores de checkbox
|
||||
*
|
||||
* Convierte cualquier valor a boolean para asegurar que solo
|
||||
* se guarden valores true/false en la base de datos.
|
||||
*
|
||||
* @param mixed $input Valor a sanitizar
|
||||
* @return bool Valor sanitizado como boolean
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_checkbox($input) {
|
||||
return (bool) $input;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_select')) {
|
||||
/**
|
||||
* Sanitiza valores de select
|
||||
*
|
||||
* Verifica que el valor seleccionado existe en las opciones disponibles.
|
||||
* Si no existe, retorna el valor por defecto del setting.
|
||||
*
|
||||
* @param mixed $input Valor a sanitizar
|
||||
* @param object $setting Setting object del Customizer
|
||||
* @return string Valor sanitizado
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_select($input, $setting) {
|
||||
// Asegurar que el setting tiene las opciones disponibles
|
||||
$choices = $setting->manager->get_control($setting->id)->choices;
|
||||
|
||||
// Retornar el input si es una opción válida, de lo contrario retornar el default
|
||||
return (array_key_exists($input, $choices) ? $input : $setting->default);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_css')) {
|
||||
/**
|
||||
* Sanitiza CSS
|
||||
*
|
||||
* Remueve scripts y código PHP potencialmente peligroso del CSS personalizado.
|
||||
*
|
||||
* @param string $css El string CSS a sanitizar
|
||||
* @return string CSS sanitizado
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_css($css) {
|
||||
// Remove <script> tags
|
||||
$css = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $css);
|
||||
// Remove potential PHP code
|
||||
$css = preg_replace('#<\?php(.*?)\?>#is', '', $css);
|
||||
return wp_strip_all_tags($css);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_js')) {
|
||||
/**
|
||||
* Sanitiza JavaScript
|
||||
*
|
||||
* Remueve etiquetas script externas y código PHP del JavaScript personalizado.
|
||||
*
|
||||
* @param string $js El string JavaScript a sanitizar
|
||||
* @return string JavaScript sanitizado
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_js($js) {
|
||||
// Remove <script> tags if present
|
||||
$js = preg_replace('#<script(.*?)>(.*?)</script>#is', '$2', $js);
|
||||
// Remove potential PHP code
|
||||
$js = preg_replace('#<\?php(.*?)\?>#is', '', $js);
|
||||
return trim($js);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_integer')) {
|
||||
/**
|
||||
* Sanitiza valores enteros
|
||||
*
|
||||
* Convierte el valor a un entero absoluto (no negativo).
|
||||
*
|
||||
* @param mixed $input Valor a sanitizar
|
||||
* @return int Valor sanitizado como entero
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_integer($input) {
|
||||
return absint($input);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_text')) {
|
||||
/**
|
||||
* Sanitiza campos de texto
|
||||
*
|
||||
* Remueve etiquetas HTML y caracteres especiales del texto.
|
||||
*
|
||||
* @param string $input Valor a sanitizar
|
||||
* @return string Texto sanitizado
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_text($input) {
|
||||
return sanitize_text_field($input);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_url')) {
|
||||
/**
|
||||
* Sanitiza URLs
|
||||
*
|
||||
* Valida y sanitiza URLs para asegurar que son válidas.
|
||||
*
|
||||
* @param string $input URL a sanitizar
|
||||
* @return string URL sanitizada
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_url($input) {
|
||||
return esc_url_raw($input);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('roi_sanitize_html')) {
|
||||
/**
|
||||
* Sanitiza contenido HTML
|
||||
*
|
||||
* Permite etiquetas HTML seguras, removiendo scripts y código peligroso.
|
||||
*
|
||||
* @param string $input Contenido HTML a sanitizar
|
||||
* @return string HTML sanitizado
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function roi_sanitize_html($input) {
|
||||
return wp_kses_post($input);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user