<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Direct access forbidden.' ); }
/**
 * Include static files: javascript and css
 */

if ( is_admin() ) {
	return;
}

/**
 * Enqueue scripts and styles for the front end.
 */


$use_custom_typo = '';
$use_custom_typo = wishbone_option('use_custom_typo');
// Add Google fonts, used in the main stylesheet.
if( false == $use_custom_typo ):
	wp_enqueue_style(
		'wishbone_theme-fonts',
		wishbone_theme_font_url(),
		array(),
		'1.0'
	);
endif;

// Foundation
wp_enqueue_style(
	'wishbone_foundation',
	get_template_directory_uri() . '/assets/css/foundation.css',
	array(),
	'1.0'
);
if ( is_rtl() ) {
	wp_enqueue_style(
		'wishbone_foundation',
		get_template_directory_uri() . '/assets/css/foundation-rtl.css',
		array(),
		'1.0'
	);
}

// Fontello
wp_enqueue_style(
	'wishbone_fontello',
	get_template_directory_uri() . '/assets/css/fontello.css',
	array(),
	'1.0'
);

// Fontello embed
wp_enqueue_style(
	'wishbone_fontello-embedded',
	get_template_directory_uri() . '/assets/css/fontello-embedded.css',
	array(),
	'1.0'
);

// Plugins
wp_enqueue_style(
	'wishbone_app',
	get_template_directory_uri() . '/assets/css/app.css',
	array(),
	'1.0'
);

// Load our main stylesheet.
wp_enqueue_style(
	'wishbone-theme-style',
	get_template_directory_uri() . '/style.css',
	array(),
	'1.0'
);

// Decide to load custom styling whether from head, or from static css
ob_start();
require get_template_directory() . '/assets/scss/style.scss.php';
$custom_css = ob_get_clean();
$custom_css_min = wishbone_minify_css( $custom_css );
wp_add_inline_style( 'wishbone-theme-style', $custom_css_min );


/**
 * Predefined Color Scheme
 */
$predefinedcolor = '';
$predefinedcolor = wishbone_option('predefinedcolor');
if( 'none' != $predefinedcolor AND !empty($predefinedcolor) ){
	wp_enqueue_style(
		'wishbone_predefined',
		get_template_directory_uri() . '/assets/css/schemes/'.$predefinedcolor.'.css',
		array(),
		'1.0'
	);
}

// Load responsive.
wp_enqueue_style(
	'wishbone-responsive-style',
	get_template_directory_uri() . '/assets/css/responsive.css',
	array(),
	'1.0'
);


/*if ( ! is_admin() )
    wp_enqueue_style( 'style-less', get_stylesheet_directory_uri() . '/style.less' );*/

/* ===============================================================================
Javascript
=============================================================================== */

wp_enqueue_script( 'jquery' );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
	wp_enqueue_script( 'comment-reply' );
}

// what input
wp_enqueue_script(
	'wishbone_foundation-js',
	get_template_directory_uri() . '/assets/js/foundation.min.js',
	array( 'jquery' ),
	'1.0',
	true
);

// what input
wp_enqueue_script(
	'wishbone_whatinput',
	get_template_directory_uri() . '/assets/js/vendor/what-input.min.js',
	array( 'jquery' ),
	'1.0',
	true
);

// Owl Carousel
wp_enqueue_script(
	'wishbone_owlcarousel',
	get_template_directory_uri() . '/assets/js/vendor/owl.carousel.min.js',
	array( 'jquery' ),
	'1.0',
	true
);

// 3rd Party plugins
wp_enqueue_script(
	'wishbone_plugins',
	get_template_directory_uri() . '/assets/js/plugins.js',
	array( 'jquery' ),
	'1.0',
	true
);

// The script that runs all necessary effects
wp_enqueue_script(
	'wishbone_app',
	get_template_directory_uri() . '/assets/js/app.js',
	array( 'jquery' ),
	'1.0',
	true
);

wp_localize_script( 'wishbone_app', 'simpleLikes', array(
	'ajaxurl' => admin_url( 'admin-ajax.php' ),
	'like' => esc_html__( 'Like', 'jt-wishbone' ),
	'unlike' => esc_html__( 'Unlike', 'jt-wishbone' )
) );

$jp = array(
   'nonce' => wp_create_nonce( 'nonce' ),
   'ajaxURL' => admin_url( 'admin-ajax.php' ),
   'loadmore' => esc_html__( 'LOAD MORE', 'jt-wishbone' ),
   'loading' => esc_html__( 'LOADING', 'jt-wishbone' ),
   'caughtup' => esc_html__( 'ALL CAUGHT UP', 'jt-wishbone' ),
   'readmore' => esc_html__( 'Read More', 'jt-wishbone' ),
   'less' => esc_html__( 'Less', 'jt-wishbone' ),
);
wp_localize_script( 'wishbone_app', 'jp', $jp );