manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } /** * Color sanitization callback * * @since 1.2.1 */ function bevro_sanitize_color( $color ) { if ( empty( $color ) || is_array( $color ) ) { return ''; } // If string does not start with 'rgba', then treat as hex. // sanitize the hex color and finally convert hex to rgba if ( false === strpos( $color, 'rgba' ) ) { return sanitize_hex_color( $color ); } // By now we know the string is formatted as an rgba color so we need to further sanitize it. $color = str_replace( ' ', '', $color ); sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')'; } /** * vaild int. */ function bevro_sanitize_int( $input ){ $return = absint($input); return $return; } // Multiple Checkbox Show function bevro_checkbox_explode( $values ){ $multi_values = !is_array( $values ) ? explode( ',', $values ) : $values; return !empty( $multi_values ) ? array_map( 'sanitize_text_field', $multi_values ) : array(); } // Multiple Checkbox Show function bevro_sanitize_number( $val, $setting ){ $input_attrs = $setting->manager->get_control( $setting->id )->input_attrs; if ( isset( $input_attrs ) ) { $input_attrs['min'] = isset( $input_attrs['min'] ) ? $input_attrs['min'] : 0; $input_attrs['step'] = isset( $input_attrs['step'] ) ? $input_attrs['step'] : 1; if ( isset( $input_attrs['max'] ) && $val > $input_attrs['max'] ) { $val = $input_attrs['max']; } elseif ( $val < $input_attrs['min'] ) { $val = $input_attrs['min']; } $dv = $val / $input_attrs['step']; $dv = round( $dv ); $val = $dv * $input_attrs['step']; $val = number_format( (float) $val, 2, '.', '' ); if ( $val == (int) $val ) { $val = (int) $val; } } return is_numeric( $val ) ? $val : 0; } // MULTI-CHOICE function bevro_sanitize_multi_choices( $input, $setting ){ // Get list of choices from the control // associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; $input_keys = $input; foreach ( $input_keys as $key => $value ){ if ( ! array_key_exists( $value, $choices ) ){ unset( $input[ $key ] ); } } // If the input is a valid key, return it; // otherwise, return the default. return ( is_array( $input ) ? $input : $setting->default ); } /** * Default color picker palettes */ if ( ! function_exists( 'bevrowp_default_color_palettes' ) ){ function bevrowp_default_color_palettes() { $palettes = array( '#000000', '#ffffff', '#dd3333', '#dd9933', '#eeee22', '#81d742', '#1e73be', '#8224e3', ); // Apply filters and return return apply_filters( 'bevro_default_color_palettes', $palettes ); } } // Bevro_Customizer_Sanitizes if ( ! class_exists( 'Bevro_Customizer_Sanitizes' ) ){ /** * Customizer Sanitizes Initial setup */ class Bevro_Customizer_Sanitizes { /** * Instance * * @access private * @var object */ private static $instance; /** * Initiator */ public static function get_instance(){ if ( ! isset( self::$instance ) ){ self::$instance = new self; } return self::$instance; } /** * Constructor */ public function __construct() { } /** * Sanitize responsive Spacing * * @param number $val Customizer setting input number. * @return number Return number. * @since 1.2.1 */ static public function bevro_sanitize_responsive_spacing( $val ) { $spacing = array( 'desktop' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'tablet' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'mobile' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ); if ( isset( $val['desktop'] ) ) { $spacing['desktop'] = array_map( function ( $value ) { return ( is_numeric( $value ) && $value >= 0 ) ? $value : ''; }, $val['desktop'] ); $spacing['tablet'] = array_map( function ( $value ) { return ( is_numeric( $value ) && $value >= 0 ) ? $value : ''; }, $val['tablet'] ); $spacing['mobile'] = array_map( function ( $value ) { return ( is_numeric( $value ) && $value >= 0 ) ? $value : ''; }, $val['mobile'] ); if ( isset( $val['desktop-unit'] ) ) { $spacing['desktop-unit'] = $val['desktop-unit']; } if ( isset( $val['tablet-unit'] ) ) { $spacing['tablet-unit'] = $val['tablet-unit']; } if ( isset( $val['mobile-unit'] ) ) { $spacing['mobile-unit'] = $val['mobile-unit']; } return $spacing; } else { foreach ( $val as $key => $value ) { $val[ $key ] = is_numeric( $val[ $key ] ) ? $val[ $key ] : ''; } return $val; } } } } Bevro_Customizer_Sanitizes::get_instance(); function bevro_customize_function_register( $wp_customize ){ /** * Multiple checkbox customize control class. * * @since 1.0.0 * @access public */ class Bevro_Customize_Control_Checkbox_Multiple extends WP_Customize_Control{ /** * The type of customize control being rendered. * * @since 1.0.0 * @access public * @var string */ public $type = 'checkbox-multiple'; /** * Enqueue scripts/styles. * * @since 1.0.0 * @access public * @return void */ public function enqueue(){ } /** * Displays the control content. * * @since 1.0.0 * @access public * @return void */ public function render_content(){ if ( empty( $this->choices ) ){ return; } ?> label ) ) : ?> label ); ?> description ) ) : ?> description; ?> value() ) ? explode( ',', $this->value() ) : $this->value(); ?>
' .$this->description. '
'; break; case 'hr' : echo '