diff --git a/wp-content/themes/apus-theme/functions.php b/wp-content/themes/apus-theme/functions.php index 2183ad21..75b8fc2e 100644 --- a/wp-content/themes/apus-theme/functions.php +++ b/wp-content/themes/apus-theme/functions.php @@ -146,6 +146,11 @@ add_filter('date_format', 'apus_custom_date_format'); /** * Include modular files */ +// Sanitize Functions (load first to avoid redeclaration errors) +if (file_exists(get_template_directory() . '/inc/sanitize-functions.php')) { + require_once get_template_directory() . '/inc/sanitize-functions.php'; +} + // Theme Options Helpers (load first as other files may depend on it) if (file_exists(get_template_directory() . '/inc/theme-options-helpers.php')) { require_once get_template_directory() . '/inc/theme-options-helpers.php'; diff --git a/wp-content/themes/apus-theme/inc/admin/options-api.php b/wp-content/themes/apus-theme/inc/admin/options-api.php index 89f61b31..0180e82f 100644 --- a/wp-content/themes/apus-theme/inc/admin/options-api.php +++ b/wp-content/themes/apus-theme/inc/admin/options-api.php @@ -231,16 +231,6 @@ function apus_sanitize_js($js) { return trim($js); } -/** - * Sanitize checkbox input - * - * @param mixed $input The input value - * @return bool - */ -function apus_sanitize_checkbox($input) { - return (bool) $input; -} - /** * Sanitize integer input * diff --git a/wp-content/themes/apus-theme/inc/adsense-delay.php b/wp-content/themes/apus-theme/inc/adsense-delay.php index c27152c5..aa6ca626 100644 --- a/wp-content/themes/apus-theme/inc/adsense-delay.php +++ b/wp-content/themes/apus-theme/inc/adsense-delay.php @@ -152,12 +152,3 @@ function apus_adsense_delay_customizer($wp_customize) { } add_action('customize_register', 'apus_adsense_delay_customizer'); -/** - * Sanitize checkbox input - * - * @param bool $checked Whether the checkbox is checked - * @return bool Sanitized value - */ -function apus_sanitize_checkbox($checked) { - return (isset($checked) && $checked === true || $checked === '1') ? true : false; -} diff --git a/wp-content/themes/apus-theme/inc/critical-css.php b/wp-content/themes/apus-theme/inc/critical-css.php index 7f95afb5..a20502e9 100644 --- a/wp-content/themes/apus-theme/inc/critical-css.php +++ b/wp-content/themes/apus-theme/inc/critical-css.php @@ -351,17 +351,6 @@ function apus_critical_css_customizer( $wp_customize ) { } add_action( 'customize_register', 'apus_critical_css_customizer' ); -/** - * Sanitize checkbox value - * - * @since 1.0.0 - * @param bool $checked Whether the checkbox is checked. - * @return bool - */ -function apus_sanitize_checkbox( $checked ) { - return ( isset( $checked ) && true === $checked ) ? true : false; -} - /** * Clear critical CSS cache when theme is updated * diff --git a/wp-content/themes/apus-theme/inc/customizer-fonts.php b/wp-content/themes/apus-theme/inc/customizer-fonts.php index 5afaa2f2..81c6b251 100644 --- a/wp-content/themes/apus-theme/inc/customizer-fonts.php +++ b/wp-content/themes/apus-theme/inc/customizer-fonts.php @@ -77,21 +77,6 @@ function apus_customize_register_fonts($wp_customize) { add_action('customize_register', 'apus_customize_register_fonts'); -/** - * Sanitize checkbox - */ -function apus_sanitize_checkbox($input) { - return (isset($input) && true === $input) ? true : false; -} - -/** - * Sanitize select - */ -function apus_sanitize_select($input, $setting) { - $choices = $setting->manager->get_control($setting->id)->choices; - return (array_key_exists($input, $choices) ? $input : $setting->default); -} - /** * Check if custom fonts are enabled */ diff --git a/wp-content/themes/apus-theme/inc/sanitize-functions.php b/wp-content/themes/apus-theme/inc/sanitize-functions.php new file mode 100644 index 00000000..9a10dfe6 --- /dev/null +++ b/wp-content/themes/apus-theme/inc/sanitize-functions.php @@ -0,0 +1,52 @@ +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); + } +}