'fusion-author-widget', 'description' => 'Display author details.', ); $control_ops = array( 'id_base' => 'fusion_author-widget', ); parent::__construct( 'fusion_author-widget', 'Avada: Author', $widget_ops, $control_ops ); } /** * Echoes the widget content. * * @access public * @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 ) { extract( $args ); // Initialize needed variables. $custom_author = isset( $instance['custom_author'] ) ? trim( $instance['custom_author'] ) : ''; $display_avatar = isset( $instance['display_avatar'] ) ? (int) $instance['display_avatar'] : 54; $display_biography = isset( $instance['display_biography'] ) ? (int) $instance['display_biography'] : 0; $display_custom_message = isset( $instance['display_custom_message'] ) ? (int) $instance['display_custom_message'] : 0; $display_sep = isset( $instance['display_sep'] ) ? (int) $instance['display_sep'] : 1; $separator_class = ( $display_sep ) ? 'fusion-author-widget-separator' : ''; $display_name = isset( $instance['display_name'] ) ? $instance['display_name'] : 'name_with_label'; $display_post_date = isset( $instance['display_post_date'] ) ? $instance['display_post_date'] : 'date_only'; $display_social_links = isset( $instance['display_social_links'] ) ? (int) $instance['display_social_links'] : 0; $link_author_page = isset( $instance['link_author_page'] ) ? (int) $instance['link_author_page'] : 1; $queried_object = get_queried_object(); $author_id = 0; if ( '' !== $custom_author ) { $author_id = (int) $custom_author; if ( ! is_numeric( $custom_author ) ) { $user = get_user_by( 'slug', $custom_author ); if ( ! empty( $user ) ) { $author_id = $user->ID; } } } elseif ( is_author() ) { $author_id = $queried_object->data->ID; } elseif ( is_single() ) { $author_id = $queried_object->post_author; } // Early exit if no author could be found. if ( ! $author_id ) { return; } $author_name = get_the_author_meta( 'display_name', $author_id ); $author_link_open = ''; $author_link_close = ''; if ( $link_author_page ) { $author_link_open = ''; $author_link_close = ''; } $custom_message = ''; if ( $display_custom_message ) { $custom_message = get_the_author_meta( 'author_custom', $author_id ); } $widget_title = ''; if ( 'name_as_title' === $display_name ) { $widget_title = $author_name; } elseif ( isset( $instance['title'] ) ) { $widget_title = $instance['title']; } $widget_title = apply_filters( 'widget_title', $widget_title ); echo $before_widget; // WPCS: XSS ok. if ( $widget_title ) { echo $before_title . $widget_title . $after_title; // WPCS: XSS ok. } ?>
__( 'Author', 'Avada' ), 'custom_author' => '', 'display_avatar' => '54', 'display_biography' => 0, 'display_custom_message' => 0, 'display_name' => 'name_with_label', 'display_post_date' => 'date_only', 'display_sep' => 1, 'display_social_links' => 0, 'link_author_page' => 1, ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>
id="get_field_id( 'link_author_page' ) ); ?>" name="get_field_name( 'link_author_page' ) ); ?>" />
id="get_field_id( 'display_custom_message' ) ); ?>" name="get_field_name( 'display_custom_message' ) ); ?>" />
id="get_field_id( 'display_biography' ) ); ?>" name="get_field_name( 'display_biography' ) ); ?>" />
id="get_field_id( 'display_social_links' ) ); ?>" name="get_field_name( 'display_social_links' ) ); ?>" />
id="get_field_id( 'display_sep' ) ); ?>" name="get_field_name( 'display_sep' ) ); ?>" />