Skip to content
Permalink
Browse files

Added sanitization to customizer options.

  • Loading branch information...
chriswallace committed Mar 8, 2015
1 parent 3596674 commit 1bcd76c00a3c14519318686b4d9bf58306ae7e44
Showing with 20 additions and 7 deletions.
  1. +20 −7 library/theme-customizer.php
@@ -70,19 +70,32 @@ function upfw_customize_register($wp_customize) {
$default = $option['default'];
}
$sanitize_callback = 'wp_filter_kses';
if( isset( $option['sanitize_callback'] ) ) {
$sanitize_callback = $option['sanitize_callback'];
} else if( $option['type'] === 'text' || $option['type'] === 'select' || $option['type'] === 'radio' ) {
$sanitize_callback = 'sanitize_text_field';
} else if( $option['type'] === 'url' ) {
$sanitize_callback = 'esc_url_raw';
} else if( $option['type'] === 'color' ) {
$sanitize_callback = 'sanitize_hex_color';
}
$wp_customize->add_setting( $optiondb, array(
'default' => $default,
'type' => 'option',
'capabilities' => 'edit_theme_options'
'default' => $default,
'type' => 'option',
'capabilities' => 'edit_theme_options',
'sanitize_callback' => $sanitize_callback
) );
if( $option['type'] == 'text' ){
$wp_customize->add_control( $option['name'], array(
'label' => $option['title'],
'section' => $option_section_name,
'settings' => $optiondb,
'type' => 'text',
'label' => $option['title'],
'section' => $option_section_name,
'settings' => $optiondb,
'type' => 'text',
) );
}

0 comments on commit 1bcd76c

Please sign in to comment.
You can’t perform that action at this time.