esc_html__( 'Displays author information.', 'bloglex' ) ) ); $this->social_networks = apply_filters( 'bloglex_author_widget_social_networks', array( 'facebook', 'twitter', 'linkedin', 'instagram', 'pinterest', 'youtube', 'threads', 'tiktok', 'twitch', 'vk', 'whatsapp', 'amazon', 'codepen', 'dropbox', 'flickr', 'vimeo', 'spotify', 'github', 'reddit', 'skype', 'soundcloud', ) ); } /** * Outputs the content for the current widget instance. */ public function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; } $image_border_radius = ! empty( $instance['image_border_radius'] ) ? ' has-border-radius' : ''; echo '
'; echo $args['after_widget']; } /** * Display social links. */ private function display_social_links( $instance ) { $social_networks = $this->social_networks; if ( empty( $social_networks ) || ! is_array( $social_networks ) ) { return; } $social_links = ''; foreach ( $social_networks as $network ) { if ( ! empty( $instance[ $network ] ) ) { $svg = Bloglex_SVG_Icons::get_social_link_svg( $instance[ $network ] ); if ( $svg ) { $social_links .= ''; echo '
'; break; case 'author_img': ?>
'; echo '
'; break; case 'social_links_color': $default_value = 'has-brand-background'; // Set your default value here $selected_value = empty($value) ? $default_value : $value; echo ''; echo '
'; break; default: echo ''; echo '
'; break; } } /** * Render social network fields in the form. */ private function render_social_network_fields( $instance ) { foreach ( $this->social_networks as $network ) { $value = ! empty( $instance[ $network ] ) ? $instance[ $network ] : ''; ?>esc_html__( 'Has Brand Background', 'bloglex' ), 'has-default-color' => esc_html__( 'Theme Color', 'bloglex' ), 'has-brand-color' => esc_html__( 'Has Brand Color', 'bloglex' ), ); default: return array(); } } /** * Sanitize widget form values as they are saved. */ public function update( $new_instance, $old_instance ) { $instance = array(); $fields = array( 'title', 'author_name', 'author_pos', 'author_desc', 'author_img', 'image_border_radius', 'social_border_radius', 'social_links_color', ); foreach ( $fields as $field ) { $instance[ $field ] = ! empty( $new_instance[ $field ] ) ? strip_tags( $new_instance[ $field ] ) : ''; } foreach ( $this->social_networks as $network ) { $instance[ $network ] = ! empty( $new_instance[ $network ] ) ? esc_url_raw( $new_instance[ $network ] ) : ''; } return $instance; } }