defaults = array(
'title' => '',
'new_window' => 0,
'size' => 32,
'facebook' => '',
'behance' => '',
'flickr' => '',
'gplus' => '',
'pinterest' => '',
'instagram' => '',
'dribbble' => '',
'linkedin' => '',
'skype' => '',
'soundcloud' => '',
'email' => '',
'rss' => '',
'stumbleupon' => '',
'twitter' => '',
'youtube' => '',
'vimeo' => '',
'foursquare' => '',
'reddit' => '',
'github' => '',
'dropbox' => '',
'tumblr' => '',
);
$this->sizes = array( '32' );
$this->profiles = array(
'facebook' => array(
'label' => __( 'Facebook URI', 'blue-lily' ),
'pattern' => '
',
),
'behance' => array(
'label' => __( 'Behance URI', 'blue-lily' ),
'pattern' => '',
),
'flickr' => array(
'label' => __( 'Flickr URI', 'blue-lily' ),
'pattern' => '',
),
'gplus' => array(
'label' => __( 'Google+ URI', 'blue-lily' ),
'pattern' => '',
),
'pinterest' => array(
'label' => __( 'Pinterest URI', 'blue-lily' ),
'pattern' => '',
),
'instagram' => array(
'label' => __( 'Instagram URI', 'blue-lily' ),
'pattern' => '',
),
'dribbble' => array(
'label' => __( 'Dribbble URI', 'blue-lily' ),
'pattern' => '',
),
'linkedin' => array(
'label' => __( 'Linkedin URI', 'blue-lily' ),
'pattern' => '',
),
'soundcloud' => array(
'label' => __( 'Soundcloud URI', 'blue-lily' ),
'pattern' => '',
),
'twitter' => array(
'label' => __( 'Twitter URI', 'blue-lily' ),
'pattern' => '',
),
'vimeo' => array(
'label' => __( 'Vimeo URI', 'blue-lily' ),
'pattern' => '',
),
'stumbleupon' => array(
'label' => __( 'StumbleUpon URI', 'blue-lily' ),
'pattern' => '',
),
'tumblr' => array(
'label' => __( 'Tumblr URI', 'blue-lily' ),
'pattern' => '',
),
'github' => array(
'label' => __( 'GitHub URI', 'blue-lily' ),
'pattern' => '',
),
'youtube' => array(
'label' => __( 'YouTube URI', 'blue-lily' ),
'pattern' => '',
),
'foursquare' => array(
'label' => __( 'FourSquare URI', 'blue-lily' ),
'pattern' => '',
),
'reddit' => array(
'label' => __( 'Reddit URI', 'blue-lily' ),
'pattern' => '',
),
'dropbox' => array(
'label' => __( 'Dropbox URI', 'blue-lily' ),
'pattern' => '',
),
'skype' => array(
'label' => __( 'Skype URI', 'blue-lily' ),
'pattern' => '',
),
'email' => array(
'label' => __( 'Email URI', 'blue-lily' ),
'pattern' => '',
),
'rss' => array(
'label' => __( 'RSS URI', 'blue-lily' ),
'pattern' => '',
),
);
$widget_ops = array(
'classname' => 'social-profile-icons',
'description' => __( 'Show profile icons.', 'blue-lily' ),
);
$control_ops = array(
'id_base' => 'social-profile-icons',
);
parent::__construct( 'social-profile-icons', sprintf( __( '%s Social Profile Icons', 'blue-lily' ), 'BLL' ), $widget_ops, $control_ops );
}
/**
* Widget Form.
*
* Outputs the widget form that allows users to control the output of the widget.
*
*/
function form( $instance ) {
/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );
?>
profiles as $profile => $data ) {
printf( '', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) );
printf( '
', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), esc_url( $instance[$profile] ) );
}
}
/**
* Form validation and sanitization.
*
* Runs when you save the widget form. Allows you to validate or sanitize widget options before they are saved.
*
*/
function update( $newinstance, $oldinstance ) {
foreach ( $newinstance as $key => $value ) {
/** Sanitize Profile URIs */
if ( array_key_exists( $key, (array) $this->profiles ) ) {
$newinstance[$key] = esc_url( $newinstance[$key] );
}
}
return $newinstance;
}
/**
* Widget Output.
*
* Outputs the actual widget on the front-end based on the widget options the user selected.
*
*/
function widget( $args, $instance ) {
extract( $args );
/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );
echo $before_widget;
if ( ! empty( $instance['title'] ) )
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
$output = '';
$new_window = $instance['new_window'] ? 'target="_blank"' : '';
foreach ( (array) $this->profiles as $profile => $data ) {
if ( ! empty( $instance[$profile] ) )
$output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_window );
}
if ( $output )
printf( '', '',$output );
echo $after_widget;
}
}
add_action( 'widgets_init', 'bll_load_widget' );