defaults = array( 'title' => '', 'new_window' => 0, 'size' => 32, 'dribbble' => '', 'email' => '', 'facebook' => '', 'gplus' => '', 'linkedin' => '', 'pinterest' => '', 'rss' => '', 'stumbleupon' => '', 'twitter' => '', 'youtube' => '', 'flickr' => '', 'lastfm' => '', 'tumblr' => '', 'vimeo' => '', ); $this->sizes = array( '32' ); $this->profiles = array( 'dribbble' => array( 'label' => __( 'Dribbble URI', 'mythemeshop' ), 'pattern' => '
', 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', 'mythemeshop_load_widget' );