<?php

/**
 * Define the typeface functionality.
 *
 * Loads typefaces for this plugin.
 *
 * @since      1.0.0
 * @package    Organic_Widgets
 * @subpackage Organic_Widgets/includes
 * @author     Organic Themes <info@organicthemes.com>
 */
class Organic_Widgets_Pro_Typefaces {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of the plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

		$this->plugin_name = $plugin_name;
		$this->version = $version;

	}

	/**
	 * Enqueue Google Fonts on Front End
	 *
	 * @since Organic Origin 1.0
	 */
	public function enqueue_fonts() {
		wp_enqueue_style( $this->plugin_name . '-fonts', organic_widgets_fonts_url(), array(), $this->version, 'all' );
	}

}

/**
 * Register Google Font URLs
 *
 * @package Organic Origin
 * @since Organic Origin 1.0
 */
function organic_widgets_fonts_url() {

	$fonts_url = '';

	/*
	Translators: If there are characters in your language that are not
	* supported by Lora, translate this to 'off'. Do not translate
	* into your own language.
	*/

	$abril_fatface = _x( 'on', 'Abril Fatface font: on or off', 'organic-widgets-pro' );
	$amatic_sc = _x( 'on', 'Amatic SC font: on or off', 'organic-widgets-pro' );
	$anton = _x( 'on', 'Anton font: on or off', 'organic-widgets-pro' );
	$arimo = _x( 'on', 'Arimo font: on or off', 'organic-widgets-pro' );
	$astloch = _x( 'on', 'Astloch font: on or off', 'organic-widgets-pro' );
	$bangers = _x( 'on', 'Bangers font: on or off', 'organic-widgets-pro' );
	$berkshire_swash = _x( 'on', 'Berkshire Swash font: on or off', 'organic-widgets-pro' );
	$bitter = _x( 'on', 'Bitter font: on or off', 'organic-widgets-pro' );
	$bungee_shade = _x( 'on', 'Bungee Shade font: on or off', 'organic-widgets-pro' );
	$chela_one = _x( 'on', 'Chela One font: on or off', 'organic-widgets-pro' );
	$cinzel = _x( 'on', 'Cinzel font: on or off', 'organic-widgets-pro' );
	$codystar = _x( 'on', 'Codystar font: on or off', 'organic-widgets-pro' );
	$courgette = _x( 'on', 'Courgette font: on or off', 'organic-widgets-pro' );
	$creepster = _x( 'on', 'Creepster font: on or off', 'organic-widgets-pro' );
	$dancing_script = _x( 'on', 'Dancing Script font: on or off', 'organic-widgets-pro' );
	$dosis = _x( 'on', 'Dosis font: on or off', 'organic-widgets-pro' );
	$droid_serif = _x( 'on', 'Droid Serif font: on or off', 'organic-widgets-pro' );
	$encode_sans = _x( 'on', 'Encode Sans font: on or off', 'organic-widgets-pro' );
	$encode_sans_condensed = _x( 'on', 'Encode Sans Condensed font: on or off', 'organic-widgets-pro' );
	$galada = _x( 'on', 'Galada font: on or off', 'organic-widgets-pro' );
	$great_vibes = _x( 'on', 'Great Vibes font: on or off', 'organic-widgets-pro' );
	$kaushan_script = _x( 'on', 'Kaushan Script font: on or off', 'organic-widgets-pro' );
	$lato = _x( 'on', 'Lato font: on or off', 'organic-widgets-pro' );
	$libre_baskerville = _x( 'on', 'Libre Baskerville font: on or off', 'organic-widgets-pro' );
	$lily_script = _x( 'on', 'Lily Script One font: on or off', 'organic-widgets-pro' );
	$lobster_two = _x( 'on', 'Lobster Two font: on or off', 'organic-widgets-pro' );
	$lora = _x( 'on', 'Lora font: on or off', 'organic-widgets-pro' );
	$merriweather = _x( 'on', 'Merriweather font: on or off', 'organic-widgets-pro' );
	$metal_mania = _x( 'on', 'Metal Mania font: on or off', 'organic-widgets-pro' );
	$monoton = _x( 'on', 'Monoton font: on or off', 'organic-widgets-pro' );
	$montserrat = _x( 'on', 'Montserrat font: on or off', 'organic-widgets-pro' );
	$nanum_gothic = _x( 'on', 'Nanum Gothic font: on or off', 'organic-widgets-pro' );
	$noto_serif = _x( 'on', 'Noto Serif font: on or off', 'organic-widgets-pro' );
	$nunito = _x( 'on', 'Nunito font: on or off', 'organic-widgets-pro' );
	$open_sans = _x( 'on', 'Open Sans font: on or off', 'organic-widgets-pro' );
	$orbitron = _x( 'on', 'Orbitron font: on or off', 'organic-widgets-pro' );
	$oswald = _x( 'on', 'Oswald font: on or off', 'organic-widgets-pro' );
	$pacifico = _x( 'on', 'Pacifico font: on or off', 'organic-widgets-pro' );
	$patua_one = _x( 'on', 'Patua One font: on or off', 'organic-widgets-pro' );
	$permanent_marker = _x( 'on', 'Permanent Marker font: on or off', 'organic-widgets-pro' );
	$playfair_display = _x( 'on', 'Playfair Display font: on or off', 'organic-widgets-pro' );
	$poppins = _x( 'on', 'Poppins font: on or off', 'organic-widgets-pro' );
	$press_start = _x( 'on', 'Press Start 2P font: on or off', 'organic-widgets-pro' );
	$pt_serif = _x( 'on', 'PT Serif font: on or off', 'organic-widgets-pro' );
	$quicksand = _x( 'on', 'Quicksand font: on or off', 'organic-widgets-pro' );
	$raleway = _x( 'on', 'Raleway font: on or off', 'organic-widgets-pro' );
	$raleway_dots = _x( 'on', 'Raleway Dots font: on or off', 'organic-widgets-pro' );
	$roboto = _x( 'on', 'Roboto font: on or off', 'organic-widgets-pro' );
	$roboto_slab = _x( 'on', 'Roboto Slab font: on or off', 'organic-widgets-pro' );
	$rubik = _x( 'on', 'Rubik font: on or off', 'organic-widgets-pro' );
	$russo_one = _x( 'on', 'Russo One font: on or off', 'organic-widgets-pro' );
	$sacramento = _x( 'on', 'Sacramento font: on or off', 'organic-widgets-pro' );
	$satisfy = _x( 'on', 'Satisfy font: on or off', 'organic-widgets-pro' );
	$sigmar_one = _x( 'on', 'Sigmar One font: on or off', 'organic-widgets-pro' );
	$source_sans_pro = _x( 'on', 'Source Sans Pro font: on or off', 'organic-widgets-pro' );
	$trade_winds = _x( 'on', 'Trade Winds font: on or off', 'organic-widgets-pro' );
	$work_sans = _x( 'on', 'Work Sans font: on or off', 'organic-widgets-pro' );

	if ( 'off' !== $abril_fatface || 'off' !== $amatic_sc || 'off' !== $anton || 'off' !== $arimo || 'off' !== $astloch || 'off' !== $bangers || 'off' !== $berkshire_swash || 'off' !== $bitter || 'off' !== $bungee_shade || 'off' !== $chela_one
	|| 'off' !== $cinzel || 'off' !== $codystar || 'off' !== $courgette || 'off' !== $creepster || 'off' !== $dancing_script || 'off' !== $droid_serif || 'off' !== $dosis || 'off' !== $encode_sans || 'off' !== $encode_sans_condensed
	|| 'off' !== $galada || 'off' !== $great_vibes || 'off' !== $kaushan_script || 'off' !== $lato || 'off' !== $libre_baskerville || 'off' !== $lily_script || 'off' !== $lobster_two || 'off' !== $lora
	|| 'off' !== $merriweather || 'off' !== $metal_mania || 'off' !== $monoton || 'off' !== $montserrat || 'off' !== $nanum_gothic || 'off' !== $noto_serif || 'off' !== $nunito || 'off' !== $open_sans || 'off' !== $orbitron
	|| 'off' !== $oswald || 'off' !== $pacifico || 'off' !== $patua_one || 'off' !== $permanent_marker || 'off' !== $playfair_display || 'off' !== $poppins || 'off' !== $press_start || 'off' !== $pt_serif
	|| 'off' !== $quicksand || 'off' !== $raleway || 'off' !== $raleway_dots || 'off' !== $roboto || 'off' !== $roboto_slab || 'off' !== $rubik || 'off' !== $russo_one || 'off' !== $sacramento
	|| 'off' !== $satisfy || 'off' !== $sigmar_one || 'off' !== $source_sans_pro || 'off' !== $trade_winds || 'off' !== $work_sans ) {

		$font_families = array();

		if ( 'off' !== $abril_fatface ) {
			$font_families[] = 'Abril Fatface';
		}

		if ( 'off' !== $amatic_sc ) {
			$font_families[] = 'Amatic SC:400,700';
		}

		if ( 'off' !== $anton ) {
			$font_families[] = 'Anton';
		}

		if ( 'off' !== $arimo ) {
			$font_families[] = 'Arimo:400,400i,700,700i';
		}

		if ( 'off' !== $astloch ) {
			$font_families[] = 'Astloch:400,700';
		}

		if ( 'off' !== $bangers ) {
			$font_families[] = 'Bangers';
		}

		if ( 'off' !== $berkshire_swash ) {
			$font_families[] = 'Berkshire Swash';
		}

		if ( 'off' !== $bitter ) {
			$font_families[] = 'Bitter:400,400i,700';
		}

		if ( 'off' !== $bungee_shade ) {
			$font_families[] = 'Bungee Shade';
		}

		if ( 'off' !== $chela_one ) {
			$font_families[] = 'Chela One';
		}

		if ( 'off' !== $cinzel ) {
			$font_families[] = 'Cinzel:400,700,900';
		}

		if ( 'off' !== $codystar ) {
			$font_families[] = 'Codystar:300,400';
		}

		if ( 'off' !== $courgette ) {
			$font_families[] = 'Courgette';
		}

		if ( 'off' !== $creepster ) {
			$font_families[] = 'Creepster';
		}

		if ( 'off' !== $dancing_script ) {
			$font_families[] = 'Dancing Script';
		}

		if ( 'off' !== $dosis ) {
			$font_families[] = 'Dosis:200,400,700';
		}

		if ( 'off' !== $droid_serif ) {
			$font_families[] = 'Droid Serif:400,400i,700,700i';
		}

		if ( 'off' !== $encode_sans ) {
			$font_families[] = 'Encode Sans:100,200,300,400,500,600,700,800,900';
		}

		if ( 'off' !== $encode_sans_condensed ) {
			$font_families[] = 'Encode Sans Condensed:200,400,800';
		}

		if ( 'off' !== $galada ) {
			$font_families[] = 'Galada';
		}

		if ( 'off' !== $great_vibes ) {
			$font_families[] = 'Great Vibes';
		}

		if ( 'off' !== $kaushan_script ) {
			$font_families[] = 'Kaushan Script';
		}

		if ( 'off' !== $lato ) {
			$font_families[] = 'Lato:100,100i,300,300i,400,400i,700,700i,900,900i';
		}

		if ( 'off' !== $libre_baskerville ) {
			$font_families[] = 'Libre Baskerville:400,400i,700';
		}

		if ( 'off' !== $lily_script ) {
			$font_families[] = 'Lily Script One';
		}

		if ( 'off' !== $lobster_two ) {
			$font_families[] = 'Lobster Two:400,400i,700,700i';
		}

		if ( 'off' !== $lora ) {
			$font_families[] = 'Lora:400,400i,700,700i';
		}

		if ( 'off' !== $merriweather ) {
			$font_families[] = 'Merriweather:300,300i,400,400i,700,700i';
		}

		if ( 'off' !== $metal_mania ) {
			$font_families[] = 'Metal Mania';
		}

		if ( 'off' !== $monoton ) {
			$font_families[] = 'Monoton';
		}

		if ( 'off' !== $montserrat ) {
			$font_families[] = 'Montserrat:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i';
		}

		if ( 'off' !== $nanum_gothic ) {
			$font_families[] = 'Nanum Gothic:400,800';
		}

		if ( 'off' !== $noto_serif ) {
			$font_families[] = 'Noto Serif:400,400i,700,700i';
		}

		if ( 'off' !== $nunito ) {
			$font_families[] = 'Nunito:200,200i,400,400i,700,700i';
		}

		if ( 'off' !== $open_sans ) {
			$font_families[] = 'Open Sans:400,300,600,700,800,800i,700i,600i,400i,300i';
		}

		if ( 'off' !== $orbitron ) {
			$font_families[] = 'Orbitron:400,900';
		}

		if ( 'off' !== $oswald ) {
			$font_families[] = 'Oswald:300,400,700';
		}

		if ( 'off' !== $pacifico ) {
			$font_families[] = 'Pacifico';
		}

		if ( 'off' !== $patua_one ) {
			$font_families[] = 'Patua One';
		}

		if ( 'off' !== $permanent_marker ) {
			$font_families[] = 'Permanent Marker';
		}

		if ( 'off' !== $playfair_display ) {
			$font_families[] = 'Playfair Display:400,400i,700,700i';
		}

		if ( 'off' !== $poppins ) {
			$font_families[] = 'Poppins:200,200i,400,400i,700,700i';
		}

		if ( 'off' !== $press_start ) {
			$font_families[] = 'Press Start 2P';
		}

		if ( 'off' !== $pt_serif ) {
			$font_families[] = 'PT Serif:400,400i,700,700i';
		}

		if ( 'off' !== $quicksand ) {
			$font_families[] = 'Quicksand:300,400,700';
		}

		if ( 'off' !== $raleway ) {
			$font_families[] = 'Raleway:400,200,300,800,700,500,600,900,100';
		}

		if ( 'off' !== $raleway_dots ) {
			$font_families[] = 'Raleway Dots';
		}

		if ( 'off' !== $roboto ) {
			$font_families[] = 'Roboto:300,300i,400,400i,700,700i';
		}

		if ( 'off' !== $roboto_slab ) {
			$font_families[] = 'Roboto Slab:300,400,700';
		}

		if ( 'off' !== $rubik ) {
			$font_families[] = 'Rubik:300,300i,400,400i,700,700i';
		}

		if ( 'off' !== $russo_one ) {
			$font_families[] = 'Russo One';
		}

		if ( 'off' !== $sacramento ) {
			$font_families[] = 'Sacramento';
		}

		if ( 'off' !== $satisfy ) {
			$font_families[] = 'Satisfy';
		}

		if ( 'off' !== $sigmar_one ) {
			$font_families[] = 'Sigmar One';
		}

		if ( 'off' !== $source_sans_pro ) {
			$font_families[] = 'Source Sans Pro:300,300i,400,400i,700,700i';
		}

		if ( 'off' !== $trade_winds ) {
			$font_families[] = 'Trade Winds';
		}

		if ( 'off' !== $work_sans ) {
			$font_families[] = 'Work Sans:100,200,300,400,500,600,700,800,900';
		}

		$query_args = array(
			'family' => urlencode( implode( '|', $font_families ) ),
			'subset' => urlencode( 'latin,latin-ext' ),
		);

		$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
	}

	return esc_url_raw( $fonts_url );
}
