Astra_Ext_Blog_Pro_Markup::astra_render_author_box_sharing()

Render Author Box sharing.


Description


Return

(mixed) HTML markup


Source

File: addons/blog-pro/classes/class-astra-ext-blog-pro-markup.php

		public function astra_render_author_box_sharing() {
			$is_author_box_enabled  = astra_get_option( 'ast-author-info' );
			$social_sharing_enabled = astra_get_option( 'author-box-socials' );
			if ( ! is_single() || ! $is_author_box_enabled || ! $social_sharing_enabled ) {
				return;
			}

			$prefix     = 'author-box';
			$title      = get_the_title();
			$show_label = false;
			$items      = astra_get_option( 'author-box-social-icon-list' );

			$items                 = isset( $items['items'] ) ? $items['items'] : array();
			$post_categories       = wp_strip_all_tags( get_the_category_list( ',' ) );
			$post_title            = $title;
			$post_link             = urlencode( get_the_permalink() ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode
			$email_title           = str_replace( '&', '%26', $title );
			$enable_heading        = astra_get_option( 'single-post-social-sharing-heading-enable' );
			$heading_text          = astra_get_option( 'single-post-social-sharing-heading-text' );
			$heading_position      = astra_get_option( 'single-post-social-sharing-heading-position' );
			$show_label            = $show_label;
			$show_label_class      = $show_label ? 'social-show-label-true' : 'social-show-label-false';
			$color_type            = astra_get_option( 'single-post-social-sharing-icon-color-type' );
			$label_position        = astra_get_option( 'single-post-social-sharing-icon-label-position' );
			$social_icon_condition = array( 'facebook', 'pinterest', 'linkedin', 'reddit', 'whatsapp', 'sms' );

			$markup = '<div class="ast-author-box-sharing"> <div class="ast-social-inner-wrap element-social-inner-wrap ' . esc_attr( $show_label_class ) . ' ast-social-color-type-' . esc_attr( $color_type ) . '">';

			if ( is_array( $items ) && ! empty( $items ) ) {
				foreach ( $items as $item ) {
					if ( $item['enabled'] ) {
						$link = $item['url'];
						switch ( $item['id'] ) {
							case 'phone':
								$link = 'tel:' . $item['url'];
								break;

							case 'email':
								$link = 'mailto:' . $item['url'];
								break;

							case 'whatsapp':
								$link = 'https://api.whatsapp.com/send?phone=' . $item['url'];
								break;
						}

						$link = apply_filters( 'astra_addon_author_social_sharing_link', $link, $item['id'] );

						$aria_label        = $item['label'] ? $item['label'] : $item['id'];
						$is_phone_or_email = 'phone' === $item['id'] || 'email' === $item['id'];
						$add_target        = $is_phone_or_email ? '' : '_blank';
						$add_rel           = $is_phone_or_email ? '' : 'noopener noreferrer';

						$icon_color            = ! empty( $item['color'] ) ? $item['color'] : '#3a3a3a';
						$icon_background_color = ! empty( $item['background'] ) ? $item['background'] : 'transparent';

						$markup .= '<a href="' . esc_url( $link ) . '" aria-label="' . esc_attr( $aria_label ) . '" target="' . esc_attr( $add_target ) . '" rel="' . esc_attr( $add_rel ) . '" class="ast-inline-flex ast-social-icon-a">
								<div style="--color: ' . esc_attr( $icon_color ) . '; --background-color:' . esc_attr( $icon_background_color ) . ';" class="ast-social-element ast-' . esc_attr( $item['id'] ) . '-social-item">
									' . Astra_Builder_UI_Controller::fetch_svg_icon( in_array( $item['icon'], $social_icon_condition ) ? $item['icon'] . '-fill' : $item['icon'] ) . '
								</div>
							</a>';
					}
				}
			}

			$markup .= '</div></div>';
			return $markup;
		}

Changelog

Changelog
Version Description
4.6.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.