defaults = array( 'title' => '', 'new_tab' => 0, 'size' => 32, 'facebook' => '', 'twitter' => '', 'gplus' => '', 'linkedin' => '', ); $this->sizes = array( '32' ); $this->profiles = array( 'facebook' => array( 'label' => __( 'Facebook URI', 'elicit' ), 'pattern' => '
  • ', ), 'twitter' => array( 'label' => __( 'Twitter URI', 'elicit' ), 'pattern' => '
  • ', ), 'gplus' => array( 'label' => __( 'Google+ URI', 'elicit' ), 'pattern' => '
  • ', ), 'linkedin' => array( 'label' => __( 'Linkedin URI', 'elicit' ), 'pattern' => '
  • ', ), ); $widget_ops = array( 'classname' => 'Elicit_Social_Profile', 'description' => __( 'Show social profile icons.', 'elicit' ), ); $control_ops = array( 'id_base' => 'social-icons', #'width' => 505, #'height' => 350, ); parent::__construct ( 'social-icons', __( 'Elicit Social Icons', 'elicit' ), $widget_ops, $control_ops ); } 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] ) ); } } 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; } 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_tab = $instance['new_tab'] ? 'target="_blank"' : ''; foreach ( (array) $this->profiles as $profile => $data ) { if ( ! empty( $instance[$profile] ) ) $output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_tab ); } if ( $output ) printf( '
    ', '',$output ); echo $after_widget; } }