manager->get_control($bakery_confectionery_setting->id)->choices; return (array_key_exists($bakery_confectionery_input, $bakery_confectionery_choices) ? $bakery_confectionery_input : $bakery_confectionery_setting->default); } function bakery_confectionery_sanitize_switch( $bakery_confectionery_input ) { if ( true === $bakery_confectionery_input ) { return true; } else { return false; } } function bakery_confectionery_sanitize_google_fonts( $bakery_confectionery_input, $bakery_confectionery_setting ) { $bakery_confectionery_choices = $bakery_confectionery_setting->manager->get_control( $bakery_confectionery_setting->id )->choices; return ( array_key_exists( $bakery_confectionery_input, $bakery_confectionery_choices ) ? $bakery_confectionery_input : $bakery_confectionery_setting->default ); } /** * Sanitize HTML input. * * @param string $bakery_confectionery_input HTML input to sanitize. * @return string Sanitized HTML. */ function bakery_confectionery_sanitize_html( $bakery_confectionery_input ) { return wp_kses_post( $bakery_confectionery_input ); } /** * Sanitize URL input. * * @param string $bakery_confectionery_input URL input to sanitize. * @return string Sanitized URL. */ function bakery_confectionery_sanitize_url( $bakery_confectionery_input ) { return esc_url_raw( $bakery_confectionery_input ); } // Sanitize Scroll Top Position function bakery_confectionery_sanitize_scroll_top_position( $bakery_confectionery_input ) { $bakery_confectionery_valid_positions = array( 'bottom-right', 'bottom-left', 'bottom-center' ); if ( in_array( $bakery_confectionery_input, $bakery_confectionery_valid_positions ) ) { return $bakery_confectionery_input; } else { return 'bottom-right'; // Default to bottom-right if invalid value } } function bakery_confectionery_sanitize_choices( $bakery_confectionery_input, $bakery_confectionery_setting ) { global $wp_customize; $bakery_confectionery_control = $wp_customize->get_control( $bakery_confectionery_setting->id ); if ( array_key_exists( $bakery_confectionery_input, $bakery_confectionery_control->choices ) ) { return $bakery_confectionery_input; } else { return $bakery_confectionery_setting->default; } } function bakery_confectionery_sanitize_range_value( $bakery_confectionery_number, $bakery_confectionery_setting ) { // Ensure input is an absolute integer. $bakery_confectionery_number = absint( $bakery_confectionery_number ); // Get the input attributes associated with the setting. $bakery_confectionery_atts = $bakery_confectionery_setting->manager->get_control( $bakery_confectionery_setting->id )->input_attrs; // Get minimum number in the range. $bakery_confectionery_min = ( isset( $bakery_confectionery_atts['min'] ) ? $bakery_confectionery_atts['min'] : $bakery_confectionery_number ); // Get maximum number in the range. $bakery_confectionery_max = ( isset( $bakery_confectionery_atts['max'] ) ? $bakery_confectionery_atts['max'] : $bakery_confectionery_number ); // Get step. $bakery_confectionery_step = ( isset( $bakery_confectionery_atts['step'] ) ? $bakery_confectionery_atts['step'] : 1 ); // If the number is within the valid range, return it; otherwise, return the default. return ( $bakery_confectionery_min <= $bakery_confectionery_number && $bakery_confectionery_number <= $bakery_confectionery_max && is_int( $bakery_confectionery_number / $bakery_confectionery_step ) ? $bakery_confectionery_number : $bakery_confectionery_setting->default ); }