
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

/* -----------------------------------------------------------------------------
 * Allow Font File Uploads
 * -------------------------------------------------------------------------- */
add_filter( 'upload_mimes', 'presso_allowed_upload_mimes' );
if ( ! function_exists( 'presso_allowed_upload_mimes' ) ) {
	function presso_allowed_upload_mimes( $existing_mimes = array() ) {
		$existing_mimes['ttf'] = 'font/ttf';
		$existing_mimes['otf'] = 'font/opentype';
		$existing_mimes['woff'] = 'font/woff';
		$existing_mimes['eot'] = 'font/eot';
		
		return $existing_mimes;
	}
}


/**
 * Add custom font into font list option
 */
add_filter( 'redux/presso_options/field/typography/custom_fonts', 'presso_custom_font_list' );
if ( ! function_exists( 'presso_custom_font_list' ) ) {
	function presso_custom_font_list( $list ) {
		$list['Custom Fonts'][ 'custom_font_1' ] = 'Custom Font 1';
		$list['Custom Fonts'][ 'custom_font_2' ] = 'Custom Font 2';

		return $list;
	}
}

/* -----------------------------------------------------------------------------
 * Render Custom Font
 * -------------------------------------------------------------------------- */
add_action( 'wp_head', 'presso_render_custom_font', 99 );
if ( ! function_exists( 'presso_render_custom_font' ) ) {
	function presso_render_custom_font() {
		?>
		<style id="vw-custom-font" type="text/css">
			<?php
			$font_url_format = "url( '%s' ) format('%s')";
			?>
			<?php
			$font1_urls = array();

			$custom_font1_ttf = presso_get_theme_option( 'custom_font1_ttf' );
			if ( ! empty( $custom_font1_ttf['url'] ) ) {
				$font1_urls[] = sprintf( $font_url_format, $custom_font1_ttf['url'], 'truetype' );
			}

			$custom_font1_woff = presso_get_theme_option( 'custom_font1_woff' );
			if ( ! empty( $custom_font1_woff['url'] ) ) {
				$font1_urls[] = sprintf( $font_url_format, $custom_font1_woff['url'], 'woff' );
			}

			$custom_font1_eot = presso_get_theme_option( 'custom_font1_eot' );
			if ( ! empty( $custom_font1_eot['url'] ) ) {
				$font1_urls[] = sprintf( $font_url_format, $custom_font1_eot['url'], 'embedded-opentype' );
			}

			if ( ! empty( $font1_urls ) ) : ?>
			@font-face {
				font-family: 'custom_font_1';
				src: <?php echo implode( ",", $font1_urls ); ?>;
			}
			<?php endif; ?>

			<?php
			$font2_urls = array();
			
			$custom_font2_ttf = presso_get_theme_option( 'custom_font2_ttf' );
			if ( ! empty( $custom_font2_ttf['url'] ) ) {
				$font2_urls[] = sprintf( $font_url_format, $custom_font2_ttf['url'], 'truetype' );
			}

			$custom_font2_woff = presso_get_theme_option( 'custom_font2_woff' );
			if ( ! empty( $custom_font2_woff['url'] ) ) {
				$font2_urls[] = sprintf( $font_url_format, $custom_font2_woff['url'], 'woff' );
			}

			$custom_font2_eot = presso_get_theme_option( 'custom_font2_eot' );
			if ( ! empty( $custom_font2_eot['url'] ) ) {
				$font2_urls[] = sprintf( $font_url_format, $custom_font2_eot['url'], 'embedded-opentype' );
			}

			if ( ! empty( $font2_urls ) ) : ?>
			@font-face {
				font-family: 'custom_font_2';
				src: <?php echo implode( ",", $font2_urls ); ?>;
			}
			<?php endif; ?>
		</style>
		<?php
	}
}
