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' => '
  • Dribbble
  • ', ), 'email' => array( 'label' => __( 'Email URI', 'mythemeshop' ), 'pattern' => '
  • Email
  • ', ), 'facebook' => array( 'label' => __( 'Facebook URI', 'mythemeshop' ), 'pattern' => '
  • Facebook
  • ', ), 'gplus' => array( 'label' => __( 'Google+ URI', 'mythemeshop' ), 'pattern' => '
  • Google+
  • ', ), 'linkedin' => array( 'label' => __( 'Linkedin URI', 'mythemeshop' ), 'pattern' => '
  • Linkedin
  • ', ), 'pinterest' => array( 'label' => __( 'Pinterest URI', 'mythemeshop' ), 'pattern' => '
  • Pinterest
  • ', ), 'rss' => array( 'label' => __( 'RSS URI', 'mythemeshop' ), 'pattern' => '
  • RSS
  • ', ), 'stumbleupon' => array( 'label' => __( 'StumbleUpon URI', 'mythemeshop' ), 'pattern' => '
  • StumbleUpon
  • ', ), 'twitter' => array( 'label' => __( 'Twitter URI', 'mythemeshop' ), 'pattern' => '
  • Twitter
  • ', ), 'youtube' => array( 'label' => __( 'YouTube URI', 'mythemeshop' ), 'pattern' => '
  • YouTube
  • ', ), 'flickr' => array( 'label' => __( 'Flickr URI', 'mythemeshop' ), 'pattern' => '
  • Flickr
  • ', ), 'lastfm' => array( 'label' => __( 'Lastfm URI', 'mythemeshop' ), 'pattern' => '
  • Lastfm
  • ', ), 'tumblr' => array( 'label' => __( 'Tumblr URI', 'mythemeshop' ), 'pattern' => '
  • Tumblr
  • ', ), 'vimeo' => array( 'label' => __( 'Vimeo URI', 'mythemeshop' ), 'pattern' => '
  • Vimeo
  • ', ), ); $widget_ops = array( 'classname' => 'social-profile-icons', 'description' => __( 'Show profile icons.', 'mythemeshop' ), ); $control_ops = array( 'id_base' => 'social-profile-icons', #'width' => 505, #'height' => 350, ); parent::__construct( 'social-profile-icons', __( 'MyThemeShop: Social Profile Icons', 'mythemeshop' ), $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', 'mythemeshop_load_widget' );