<?php

if ( ! function_exists( 'ginevra_core_include_blog_single_author_info_template' ) ) {
	/**
	 * Function which includes additional module on single posts page
	 */
	function ginevra_core_include_blog_single_author_info_template() {
		if ( is_single() ) {
			include_once GINEVRA_CORE_INC_PATH . '/blog/templates/single/author-info/templates/author-info.php';
		}
	}

	add_action( 'ginevra_action_after_blog_post_item', 'ginevra_core_include_blog_single_author_info_template', 15 );  // permission 15 is set to define template position
}

if ( ! function_exists( 'ginevra_core_get_author_social_networks' ) ) {
	/**
	 * Function which includes author info templates on single posts page
	 */
	function ginevra_core_get_author_social_networks( $user_id ) {
		$icons           = array();
		$social_networks = array(
			'facebook'  => esc_html__('Facebook', 'ginevra-core'),
			'twitter'   => esc_html__('Twitter', 'ginevra-core'),
			'linkedin'  => esc_html__('Linkedin', 'ginevra-core'),
			'instagram' => esc_html__('Instagram', 'ginevra-core'),
			'pinterest' => esc_html__('Pinterest', 'ginevra-core'),
		);

		foreach ( $social_networks as $key => $value ) {
			$network_meta = get_the_author_meta( 'qodef_user_' . $key, $user_id );

			if ( ! empty( $network_meta ) ) {
				$$key = array(
					'url'   => $network_meta,
					'icon'  => 'social_' . $value,
					'label' => $value,
					'class' => 'qodef-user-social-' . $key,
				);

				$icons[ $key ] = $$key;
			}
		}

		return $icons;
	}
}
