add_section('berkeley_social_section', array( 'title' => __('Social Icons','berkeley'), 'priority' => 1 , 'panel' => 'berkeley_content_panel' ) ); //Social Icons Array $social_networks = array( //Redefinied in Sanitization Function. 'none' => __('-','berkeley'), 'facebook' => __('Facebook','berkeley'), 'twitter' => __('Twitter','berkeley'), 'google-plus' => __('Google Plus','berkeley'), 'instagram' => __('Instagram','berkeley'), 'rss' => __('RSS Feeds','berkeley'), 'vine' => __('Vine','berkeley'), 'vimeo-square' => __('Vimeo','berkeley'), 'youtube' => __('Youtube','berkeley'), 'flickr' => __('Flickr','berkeley'), ); //Social Icon Controls Loop $social_count = count($social_networks); for ($x = 1 ; $x <= ($social_count - 3) ; $x++) : $wp_customize->add_setting( 'berkeley_social_'.$x, array( 'sanitize_callback' => 'berkeley_sanitize_social', 'default' => 'none' )); $wp_customize->add_control( 'berkeley_social_'.$x, array( 'settings' => 'berkeley_social_'.$x, 'label' => __('Icon ','berkeley').$x, 'section' => 'berkeley_social_section', 'type' => 'select', 'choices' => $social_networks, )); $wp_customize->add_setting( 'berkeley_social_url'.$x, array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control( 'berkeley_social_url'.$x, array( 'settings' => 'berkeley_social_url'.$x, 'description' => __('Icon ','berkeley').$x.__(' Url','berkeley'), 'section' => 'berkeley_social_section', 'type' => 'url', 'choices' => $social_networks, )); endfor; function berkeley_sanitize_social( $input ) { $social_networks = array( 'none' , 'facebook', 'twitter', 'google-plus', 'instagram', 'rss', 'vine', 'vimeo-square', 'youtube', 'flickr' ); if ( in_array($input, $social_networks) ) return $input; else return ''; } }