defaults = array( 'title' => '', 'alignment' => 'left', 'user' => '', 'size' => '45', 'author_info' => '', 'bio_text' => '', 'page' => '', 'page_link_text' => __( 'Read More', 'genesis' ) . '…', 'posts_link' => '', ); $widget_ops = array( 'classname' => 'user-profile', 'description' => __( 'Displays user profile block with Gravatar', 'genesis' ), ); $control_ops = array( 'id_base' => 'user-profile', 'width' => 200, 'height' => 250, ); parent::__construct( 'user-profile', __( 'Genesis - User Profile', 'genesis' ), $widget_ops, $control_ops ); } /** * Echo the widget content. * * @param array $args Display arguments including `before_title`, `after_title`, * `before_widget`, and `after_widget`. * @param array $instance The settings for the particular instance of the widget. */ public function widget( $args, $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; // WPCS: prefix ok. } $text = ''; if ( ! empty( $instance['alignment'] ) ) { $text .= ''; } $text .= get_avatar( $instance['user'], $instance['size'] ); if ( ! empty( $instance['alignment'] ) ) { $text .= ''; } if ( 'text' === $instance['author_info'] ) { $text .= $instance['bio_text']; // We run KSES on update. } else { $text .= get_the_author_meta( 'description', $instance['user'] ); } $text .= $instance['page'] ? sprintf( ' %s', get_page_link( $instance['page'] ), $instance['page_link_text'] ) : ''; echo wpautop( $text ); // If posts link option checked, add posts link to output. $display_name = get_the_author_meta( 'display_name', $instance['user'] ); $user_name = ( ! empty( $display_name ) && genesis_a11y( 'screen-reader-text' ) ) ? '' . $display_name . ': ' : ''; if ( $instance['posts_link'] ) { printf( '', get_author_posts_url( $instance['user'] ), $user_name, __( 'View My Blog Posts', 'genesis' ) ); } echo $args['after_widget']; } /** * Update a particular instance. * * This function should check that $new_instance is set correctly. * The newly calculated value of $instance should be returned. * If "false" is returned, the instance won't be saved/updated. * * @param array $new_instance New settings for this instance as input by the user via `form()`. * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */ public function update( $new_instance, $old_instance ) { $new_instance['title'] = strip_tags( $new_instance['title'] ); $new_instance['bio_text'] = current_user_can( 'unfiltered_html' ) ? $new_instance['bio_text'] : genesis_formatting_kses( $new_instance['bio_text'] ); $new_instance['page_link_text'] = strip_tags( $new_instance['page_link_text'] ); return $new_instance; } /** * Echo the settings update form. * * @param array $instance Current settings. * @return void */ public function form( $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>


'authors', 'name' => $this->get_field_name( 'user' ), 'selected' => $instance['user'], ) ); ?>

/>
/>


$this->get_field_name( 'page' ), 'show_option_none' => __( 'None', 'genesis' ), 'selected' => $instance['page'], ) ); ?>

/>