manager->get_control( $aster_vlogger_setting->id )->choices; return ( array_key_exists( $aster_vlogger_input, $aster_vlogger_choices ) ? $aster_vlogger_input : $aster_vlogger_setting->default ); } function aster_vlogger_sanitize_switch( $aster_vlogger_input ) { if ( true === $aster_vlogger_input ) { return true; } else { return false; } } function aster_vlogger_sanitize_google_fonts( $aster_vlogger_input, $aster_vlogger_setting ) { $aster_vlogger_choices = $aster_vlogger_setting->manager->get_control( $aster_vlogger_setting->id )->choices; return ( array_key_exists( $aster_vlogger_input, $aster_vlogger_choices ) ? $aster_vlogger_input : $aster_vlogger_setting->default ); } /** * Sanitize HTML input. * * @param string $aster_vlogger_input HTML input to sanitize. * @return string Sanitized HTML. */ function aster_vlogger_sanitize_html( $aster_vlogger_input ) { return wp_kses_post( $aster_vlogger_input ); } /** * Sanitize URL input. * * @param string $aster_vlogger_input URL input to sanitize. * @return string Sanitized URL. */ function aster_vlogger_sanitize_url( $aster_vlogger_input ) { return esc_url_raw( $aster_vlogger_input ); } // Sanitize Scroll Top Position function aster_vlogger_sanitize_scroll_top_position( $aster_vlogger_input ) { $aster_vlogger_valid_positions = array( 'bottom-right', 'bottom-left', 'bottom-center' ); if ( in_array( $aster_vlogger_input, $aster_vlogger_valid_positions ) ) { return $aster_vlogger_input; } else { return 'bottom-right'; // Default to bottom-right if invalid value } } function aster_vlogger_sanitize_choices( $aster_vlogger_input, $aster_vlogger_setting ) { global $wp_customize; $aster_vlogger_control = $wp_customize->get_control( $aster_vlogger_setting->id ); if ( array_key_exists( $aster_vlogger_input, $aster_vlogger_control->choices ) ) { return $aster_vlogger_input; } else { return $aster_vlogger_setting->default; } } function aster_vlogger_sanitize_range_value( $aster_vlogger_number, $aster_vlogger_setting ) { // Ensure input is an absolute integer. $aster_vlogger_number = absint( $aster_vlogger_number ); // Get the input attributes associated with the setting. $aster_vlogger_atts = $aster_vlogger_setting->manager->get_control( $aster_vlogger_setting->id )->input_attrs; // Get minimum number in the range. $aster_vlogger_min = ( isset( $aster_vlogger_atts['min'] ) ? $aster_vlogger_atts['min'] : $aster_vlogger_number ); // Get maximum number in the range. $aster_vlogger_max = ( isset( $aster_vlogger_atts['max'] ) ? $aster_vlogger_atts['max'] : $aster_vlogger_number ); // Get step. $aster_vlogger_step = ( isset( $aster_vlogger_atts['step'] ) ? $aster_vlogger_atts['step'] : 1 ); // If the number is within the valid range, return it; otherwise, return the default. return ( $aster_vlogger_min <= $aster_vlogger_number && $aster_vlogger_number <= $aster_vlogger_max && is_int( $aster_vlogger_number / $aster_vlogger_step ) ? $aster_vlogger_number : $aster_vlogger_setting->default ); }