set_settings(); $widget_ops = [ 'classname' => 'fusion-author-widget', 'description' => __( 'Display author details.', 'Avada' ), ]; $control_ops = [ 'id_base' => 'fusion_author-widget', ]; parent::__construct( 'fusion_author-widget', __( 'Avada: Author', 'Avada' ), $widget_ops, $control_ops ); } /** * Set settings for this widget, * with a fallback to some sane defaults if no customized settings are saved in the database. * * @access public * @since 4.0 * @return void */ public function set_settings() { $fusion_settings = class_exists( 'Fusion_Settings' ) ? awb_get_fusion_settings() : false; if ( $fusion_settings ) { $date_format = $fusion_settings->get( 'date_format' ); $date_format = $date_format ? $date_format : get_option( 'date_format' ); $this->settings = [ 'social_links_color_type' => $fusion_settings->get( 'social_links_color_type' ), 'social_links_icon_color' => $fusion_settings->get( 'social_links_icon_color' ), 'social_links_box_color' => $fusion_settings->get( 'social_links_box_color' ), 'social_links_boxed' => $fusion_settings->get( 'social_links_boxed' ), 'social_links_boxed_radius' => Fusion_Sanitize::size( $fusion_settings->get( 'social_links_boxed_radius' ) ), 'social_links_tooltip_placement' => $fusion_settings->get( 'social_links_tooltip_placement' ), 'social_icons_new' => $fusion_settings->get( 'social_icons_new' ), 'date_format' => $date_format, ]; } else { $this->settings = [ 'social_links_color_type' => 'custom', 'social_links_icon_color' => '#bebdbd', 'social_links_boxed' => '0', 'social_links_box_color' => '#e8e8e8', 'social_links_boxed_radius' => '4px', 'social_links_tooltip_placement' => 'Top', 'social_icons_new' => '1', 'date_format' => get_option( 'date_format' ), ]; } } /** * 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 ) { global $fusion_library; extract( $args ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract // 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() && isset( $queried_object->data->ID ) ) { $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 = ''; } $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, $instance, $this->id_base ); echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput if ( $widget_title ) { echo $before_title . $widget_title . $after_title; // phpcs:ignore WordPress.Security.EscapeOutput } ?>
' . $author_name . '' . $author_link_close; // phpcs:ignore WordPress.Security.EscapeOutput ?>
' . sprintf( esc_html__( 'So far the author has created %s blog entries.', 'Avada' ), count_user_posts( $author_id ) ); } ?>
'yes', 'author_id' => $author_id, 'position' => 'author', 'color_type' => $this->settings['social_links_color_type'], 'icon_colors' => $this->settings['social_links_icon_color'], 'box_colors' => $this->settings['social_links_box_color'], 'icon_boxed' => $this->settings['social_links_boxed'], 'icon_boxed_radius' => $this->settings['social_links_boxed_radius'], 'tooltip_placement' => $this->settings['social_links_tooltip_placement'], 'linktarget' => $this->settings['social_icons_new'], ]; ?>
social_sharing->render_social_icons( $author_social_icon_options ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
settings['date_format'], get_queried_object_id() ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
__( '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' ) ); ?>" />