defaults = array( 'title' => '', 'show_featured_image' => 0, 'featured_image_alignment' => '', 'featured_image_size' => 'medium', 'gravatar_alignment' => 'left', 'user' => '', 'show_gravatar' => 0, 'size' => '45', 'author_info' => '', 'bio_text' => '', 'page' => '', 'page_link_text' => __( 'Read More', 'display-featured-image-genesis' ) . '…', 'posts_link' => '', 'link_text' => __( 'View My Blog Posts', 'display-featured-image-genesis' ), ); $widget_ops = array( 'classname' => 'author-profile', 'description' => __( 'Displays user profile block with Gravatar', 'display-featured-image-genesis' ), ); $control_ops = array( 'id_base' => 'featured-author', 'width' => 200, 'height' => 250, ); parent::__construct( 'featured-author', __( 'Display Featured Author Profile', 'display-featured-image-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 */ 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']; } if ( $instance['show_featured_image'] ) { $image_id = get_the_author_meta( 'displayfeaturedimagegenesis', $instance['user'] ); $image_src = wp_get_attachment_image_src( $image_id, $instance['featured_image_size'] ); if ( $image_src ) { echo '' . get_the_author_meta( 'display_name', $instance['user'] ) . ''; } } $text = ''; if ( $instance['show_gravatar'] ) { if ( ! empty( $instance['gravatar_alignment'] ) ) { $text .= ''; } $text .= get_avatar( $instance['user'], $instance['size'] ); if( ! empty( $instance['gravatar_alignment'] ) ) { $text .= ''; } } $text .= 'text' === $instance['author_info'] ? $instance['bio_text'] : get_the_author_meta( 'description', $instance['user'] ); $text .= $instance['page'] ? sprintf( ' %s', get_page_link( $instance['page'] ), $instance['page_link_text'] ) : ''; // Echo $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() ) ? '' . $display_name. ': ' : ''; if ( $instance['posts_link'] && $instance['link_text'] ) { printf( '', get_author_posts_url( $instance['user'] ), $user_name, $instance['link_text'] ); } 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 */ 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'] ); $new_instance['link_text'] = esc_html( $new_instance['link_text'] ); return $new_instance; } /** * Echo the settings update form. * * @param array $instance Current settings */ 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', 'display-featured-image-genesis' ), 'selected' => $instance['page'] ) ); ?>

/>