esc_html__( 'Display links to your social network profiles, enter full profile URLs', 'biru' ) ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $fields = array( // Title 'widget_title' => array( 'biru_widgets_name' => 'widget_title', 'biru_widgets_title' => esc_html__( 'Title', 'biru' ), 'biru_widgets_field_type' => 'text' ), // Other fields 'twitter' => array ( 'biru_widgets_name' => 'twitter', 'biru_widgets_title' => esc_html__( 'Twitter', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'facebook' => array ( 'biru_widgets_name' => 'facebook', 'biru_widgets_title' => esc_html__( 'Facebook', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'linkedin' => array ( 'biru_widgets_name' => 'linkedin', 'biru_widgets_title' => esc_html__( 'LinkedIn', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'google' => array ( 'biru_widgets_name' => 'google', 'biru_widgets_title' => esc_html__( 'Google+', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'pinterest' => array ( 'biru_widgets_name' => 'pinterest', 'biru_widgets_title' => esc_html__( 'Pinterest', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'youtube' => array ( 'biru_widgets_name' => 'youtube', 'biru_widgets_title' => esc_html__( 'YouTube', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'vimeo' => array ( 'biru_widgets_name' => 'vimeo', 'biru_widgets_title' => esc_html__( 'Vimeo', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'flickr' => array ( 'biru_widgets_name' => 'flickr', 'biru_widgets_title' => esc_html__( 'Flickr', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'dribbble' => array ( 'biru_widgets_name' => 'dribbble', 'biru_widgets_title' => esc_html__( 'Dribbble', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'tumblr' => array ( 'biru_widgets_name' => 'tumblr', 'biru_widgets_title' => esc_html__( 'Tumblr', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'instagram' => array ( 'biru_widgets_name' => 'instagram', 'biru_widgets_title' => esc_html__( 'Instagram', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'github' => array ( 'biru_widgets_name' => 'github', 'biru_widgets_title' => esc_html__( 'Github', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'reddit' => array ( 'biru_widgets_name' => 'reddit', 'biru_widgets_title' => esc_html__( 'Reddit', 'biru' ), 'biru_widgets_field_type' => 'text' ), 'soundcloud' => array ( 'biru_widgets_name' => 'soundcloud', 'biru_widgets_title' => esc_html__( 'SoundCloud', 'biru' ), 'biru_widgets_field_type' => 'text' ), ); return $fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { extract( $args ); $widget_title = apply_filters( 'widget_title', $instance['widget_title'] ); echo $before_widget; // Show title if( $widget_title ) { echo $before_title . $widget_title . $after_title; } echo '
'; echo $after_widget; } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @uses biru_widgets_show_widget_field() defined in widget-fields.php * * @return array Updated safe values to be saved. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $widget_fields = $this->widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { extract( $widget_field ); // Use helper function to get updated field values $instance[$biru_widgets_name] = biru_widgets_updated_field_value( $widget_field, $new_instance[$biru_widgets_name] ); echo $instance[$biru_widgets_name]; } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. * * @uses biru_widgets_show_widget_field() defined in widget-fields.php */ public function form( $instance ) { $widget_fields = $this->widget_fields(); // Loop through fields foreach( $widget_fields as $widget_field ) { // Make array elements available as variables extract( $widget_field ); $biru_widgets_field_value = isset( $instance[$biru_widgets_name] ) ? esc_attr( $instance[$biru_widgets_name] ) : ''; biru_widgets_show_widget_field( $this, $widget_field, $biru_widgets_field_value ); } } }