__( 'Show Users.', 'user-profile' ), ) ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); $count = isset( $instance[ 'count' ] ) ? $instance[ 'count' ] : 5; $template = isset( $instance[ 'template' ] ) ? $instance[ 'template' ] : 'default'; global $userprofile; echo $args['before_widget']; if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title']; $users = get_users( array( 'number' => $count, ) ); foreach( $users as $user ) : $thisuser = new user_profile_user_data( $user->ID ); if( is_wp_error( $html_user = $userprofile->generate_html_user( $thisuser, $template ) ) ) { $userprofile->print_error( $html_user ); continue; } printf( $html_user ); endforeach; echo $args['after_widget']; } public function form( $instance ) { $title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : __( 'Users', 'user-profile' ); $count = isset( $instance[ 'count' ] ) ? $instance[ 'count' ] : 5; $template = isset( $instance[ 'template' ] ) ? $instance[ 'template' ] : 'default'; global $userprofile; printf( "

", $this->get_field_id( 'title' ), __( 'Title' ), $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), esc_attr( $title ) ); printf( "

", $this->get_field_id( 'count' ), __( 'Count' ), $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), esc_attr( $count ) ); printf( "

" ); } public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; $instance['count'] = ( ! empty( $new_instance['count'] ) ) ? strip_tags( $new_instance['count'] ) : ''; $instance['template'] = ( ! empty( $new_instance['template'] ) ) ? strip_tags( $new_instance['template'] ) : ''; return $instance; } }