<?php
/**
 * Define theme constants
 */
define( 'TB_THEME_ID', 'gnar' );
define( 'TB_THEME_NAME', 'Gnar' );

/**
 * Modify framework's theme options
 */
include_once( get_template_directory() . '/includes/options.php' );

/**
 * Automatic updates
 */
include_once( get_template_directory() . '/includes/updates.php' );

/**
 * Global framework config
 *
 * @since 1.0.0
 */
function gnar_global_config( $config ) {

	// Enable admin bases
	$config['admin']['base'] = false;

	// Enable comments on pages
	$config['comments']['pages'] = true;

	// Disable framework responsive menu
	$config['display']['mobile_side_menu'] = false;

	// Disable framework side panel
	$config['display']['side_panel'] = false;

	// Disable sticky menu, in favor of default
	// theme header, which will already "stick"
	$config['display']['sticky'] = false;

	// Disable scroll effects
	if ( ! themeblvd_get_option('scroll_effects') ) {
		$config['display']['scroll_effects'] = false;
	}

	// Enable dark content
	if ( themeblvd_get_option('style') == 'dark' ) {
		$config['display']['dark'] = true;
	}

	return $config;
}
add_filter('themeblvd_global_config', 'gnar_global_config');

/**
 * Add any recommended plugins.
 *
 * @since 1.0.0
 */
function gnar_plugins( $plugins ) {
	// No added plugins currently
	return $plugins;
}
// add_filter('themeblvd_plugins', 'gnar_plugins');

/**
 * Add Gnar sample layouts.
 *
 * @since 1.0.0
 */
function gnar_sample_layouts( $layouts ) {

	$layouts['gnar-home'] = array(
		'name'		=> __('Gnar: Home (demo default)', 'gnar'),
		'id'		=> 'gnar-home',
		'dir'		=> get_template_directory() . '/includes/layout/home/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-basic'] = array(
		'name'		=> __('Gnar: Home Basic', 'gnar'),
		'id'		=> 'gnar-home-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);


	$layouts['gnar-home-maui'] = array(
		'name'		=> __('Gnar: Home Maui', 'gnar'),
		'id'		=> 'gnar-home-maui',
		'dir'		=> get_template_directory() . '/includes/layout/home-maui/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-maui/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-maui-basic'] = array(
		'name'		=> __('Gnar: Home Maui Basic', 'gnar'),
		'id'		=> 'gnar-home-maui-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-maui-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-maui-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-newyork'] = array(
		'name'		=> __('Gnar: Home New York', 'gnar'),
		'id'		=> 'gnar-home-newyork',
		'dir'		=> get_template_directory() . '/includes/layout/home-newyork/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-newyork/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-newyork-basic'] = array(
		'name'		=> __('Gnar: Home New York Basic', 'gnar'),
		'id'		=> 'gnar-home-newyork-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-newyork-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-newyork-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-portland'] = array(
		'name'		=> __('Gnar: Home Portland', 'gnar'),
		'id'		=> 'gnar-home-portland',
		'dir'		=> get_template_directory() . '/includes/layout/home-portland/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-portland/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-portland-basic'] = array(
		'name'		=> __('Gnar: Home Portland Basic', 'gnar'),
		'id'		=> 'gnar-home-portland-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-portland-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-portland-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-santamonica'] = array(
		'name'		=> __('Gnar: Home Santa Monica', 'gnar'),
		'id'		=> 'gnar-home-santamonica',
		'dir'		=> get_template_directory() . '/includes/layout/home-santamonica/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-santamonica/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-santamonica-basic'] = array(
		'name'		=> __('Gnar: Home Santa Monica Basic', 'gnar'),
		'id'		=> 'gnar-home-santamonica-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-santamonica-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-santamonica-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-vail'] = array(
		'name'		=> __('Gnar: Home Vail', 'gnar'),
		'id'		=> 'gnar-home-vail',
		'dir'		=> get_template_directory() . '/includes/layout/home-vail/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-vail/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-vail-basic'] = array(
		'name'		=> __('Gnar: Home Vail Basic', 'gnar'),
		'id'		=> 'gnar-home-vail-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-vail-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-vail-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-agency'] = array(
		'name'		=> __('Gnar: Home Agency', 'gnar'),
		'id'		=> 'gnar-home-agency',
		'dir'		=> get_template_directory() . '/includes/layout/home-agency/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-agency/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-agency-basic'] = array(
		'name'		=> __('Gnar: Home Agency Basic', 'gnar'),
		'id'		=> 'gnar-home-agency-basic',
		'dir'		=> get_template_directory() . '/includes/layout/home-agency-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-agency-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-blog'] = array(
		'name'		=> __('Gnar: Home Blog', 'gnar'),
		'id'		=> 'gnar-home-blog',
		'dir'		=> get_template_directory() . '/includes/layout/home-blog/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-blog/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-corporate'] = array(
		'name'		=> __('Gnar: Home Corporate', 'gnar'),
		'id'		=> 'gnar-home-corporate',
		'dir'		=> get_template_directory() . '/includes/layout/home-corporate/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-corporate/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-parallax'] = array(
		'name'		=> __('Gnar: Home Parallax', 'gnar'),
		'id'		=> 'gnar-home-parallax',
		'dir'		=> get_template_directory() . '/includes/layout/home-parallax/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-parallax/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-portfolio'] = array(
		'name'		=> __('Gnar: Home Portfolio', 'gnar'),
		'id'		=> 'gnar-home-portfolio',
		'dir'		=> get_template_directory() . '/includes/layout/home-portfolio/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-portfolio/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-about-agency'] = array(
		'name'		=> __('Gnar: About Agency', 'gnar'),
		'id'		=> 'gnar-about-agency',
		'dir'		=> get_template_directory() . '/includes/layout/about-agency/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/about-agency/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-about-basic'] = array(
		'name'		=> __('Gnar: About Basic', 'gnar'),
		'id'		=> 'gnar-about-basic',
		'dir'		=> get_template_directory() . '/includes/layout/about-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/about-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-about-me'] = array(
		'name'		=> __('Gnar: About Me', 'gnar'),
		'id'		=> 'gnar-about-me',
		'dir'		=> get_template_directory() . '/includes/layout/about-me/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/about-me/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-about-minimal'] = array(
		'name'		=> __('Gnar: About Minimal', 'gnar'),
		'id'		=> 'gnar-about-minimal',
		'dir'		=> get_template_directory() . '/includes/layout/about-minimal/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/about-minimal/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-home-shop'] = array(
		'name'		=> __('Gnar: Home Shop', 'gnar'),
		'id'		=> 'gnar-home-shop',
		'dir'		=> get_template_directory() . '/includes/layout/home-shop/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/home-shop/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-about-stretch'] = array(
		'name'		=> __('Gnar: About Stretch', 'gnar'),
		'id'		=> 'gnar-about-stretch',
		'dir'		=> get_template_directory() . '/includes/layout/about-stretch/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/about-stretch/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-contact-fancy'] = array(
		'name'		=> __('Gnar: Contact Fancy', 'gnar'),
		'id'		=> 'gnar-contact-fancy',
		'dir'		=> get_template_directory() . '/includes/layout/contact-fancy/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/contact-fancy/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-contact-minimal'] = array(
		'name'		=> __('Gnar: Contact Minimal', 'gnar'),
		'id'		=> 'gnar-contact-minimal',
		'dir'		=> get_template_directory() . '/includes/layout/contact-minimal/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/contact-minimal/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-contact-simple'] = array(
		'name'		=> __('Gnar: Contact Simple', 'gnar'),
		'id'		=> 'gnar-contact-simple',
		'dir'		=> get_template_directory() . '/includes/layout/contact-simple/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/contact-simple/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-contact-standard'] = array(
		'name'		=> __('Gnar: Contact Standard', 'gnar'),
		'id'		=> 'gnar-contact-standard',
		'dir'		=> get_template_directory() . '/includes/layout/contact-standard/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/contact-standard/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-contact-stretch'] = array(
		'name'		=> __('Gnar: Contact Stretch', 'gnar'),
		'id'		=> 'gnar-contact-stretch',
		'dir'		=> get_template_directory() . '/includes/layout/contact-stretch/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/contact-stretch/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-help'] = array(
		'name'		=> __('Gnar: Help / FAQ', 'gnar'),
		'id'		=> 'gnar-help',
		'dir'		=> get_template_directory() . '/includes/layout/help/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/help/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-pricing'] = array(
		'name'		=> __('Gnar: Pricing', 'gnar'),
		'id'		=> 'gnar-pricing',
		'dir'		=> get_template_directory() . '/includes/layout/pricing/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/pricing/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-services-agency'] = array(
		'name'		=> __('Gnar: Services Agency', 'gnar'),
		'id'		=> 'gnar-services-agency',
		'dir'		=> get_template_directory() . '/includes/layout/services-agency/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/services-agency/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-services-basic'] = array(
		'name'		=> __('Gnar: Services Basic', 'gnar'),
		'id'		=> 'gnar-services-basic',
		'dir'		=> get_template_directory() . '/includes/layout/services-basic/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/services-basic/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-services-images'] = array(
		'name'		=> __('Gnar: Services Images', 'gnar'),
		'id'		=> 'gnar-services-images',
		'dir'		=> get_template_directory() . '/includes/layout/services-images/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/services-images/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-services-minimal'] = array(
		'name'		=> __('Gnar: Services Minimal', 'gnar'),
		'id'		=> 'gnar-services-minimal',
		'dir'		=> get_template_directory() . '/includes/layout/services-minimal/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/services-minimal/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	$layouts['gnar-services-stretch'] = array(
		'name'		=> __('Gnar: Services Stretch', 'gnar'),
		'id'		=> 'gnar-services-stretch',
		'dir'		=> get_template_directory() . '/includes/layout/services-stretch/',
		'uri'		=> get_template_directory_uri() . '/includes/layout/services-stretch/',
		'assets'	=> get_template_directory_uri() . '/includes/layout/assets/'
	);

	return $layouts;
}
add_filter('themeblvd_sample_layouts', 'gnar_sample_layouts');

/**
 * Add elements to layout builder.
 *
 * @since 1.0.0
 */
function gnar_elements() {

	themeblvd_add_builder_element( apply_filters('gnar_image_box_element_args', array(
		'id'		=> 'gnar_featured_post',
		'name'		=> __('Gnar: Featured Post', 'gnar'),
		'callback'	=> 'gnar_featured_post',
		'support'	=> array(
			'popout' => 'force'
		),
		'options'	=> array(
			'post_id' => array(
				'id' 		=> 'post_id',
				'name'		=> __('Post or Page ID', 'gnar'),
				'desc'		=> __('Insert a post or page ID to pull the content from.', 'gnar'),
				'type'		=> 'text',
				'icon'		=> 'post_id'
			),
			'label' => array(
				'id' 		=> 'label',
				'name'		=> __('Label', 'gnar'),
				'desc'		=> __('Enter a label, that\'ll be displayed above the post.', 'gnar'),
				'std'		=> 'Featured',
				'type'		=> 'text'
			),
			'color' => array(
				'id' 		=> 'color',
				'name'		=> __('Color', 'gnar' ),
				'desc'		=> __('Select a background color for the content.', 'gnar' ),
				'type'		=> 'color',
				'std'		=> '#e64d43'
			)
		)
	)));

	themeblvd_add_builder_element( apply_filters('gnar_image_box_element_args', array(
		'id'		=> 'gnar_image_box',
		'name'		=> __('Gnar: Image Box', 'gnar'),
		'callback'	=> 'gnar_image_box',
		'support'	=> array(
			'popout' => true
		),
		'options'	=> array(
			'image' => array(
				'id' 		=> 'image',
				'name' 		=> __('Background Image', 'gnar'),
				'desc'		=> __('Select a background image for the info box.', 'theme-blvd-layout-builder'),
				'type'		=> 'upload',
				'advanced'	=> true
		    ),
			'title' => array(
				'id' 		=> 'title',
				'name' 		=> __('Title', 'gnar'),
				'desc'		=> __('Enter a brief line of text for the title.', 'gnar'),
				'type'		=> 'text',
				'editor'	=> true,
				'code'		=> 'html'
		    ),
			'info' => array(
				'id' 		=> 'info',
				'name' 		=> __('Information', 'gnar'),
				'desc'		=> __('Enter the text to be revealed beneath the title, when the info box is hovered over.', 'gnar'),
				'type'		=> 'textarea',
				'editor'	=> true,
				'code'		=> 'html'
		    ),
			'subgroup_start_1' => array(
				'id'		=> 'subgroup_start_1',
		    	'type'		=> 'subgroup_start',
		    	'class'		=> 'show-hide'
		    ),
			'button' => array(
				'id' 		=> 'button',
				'name'		=> __('Button', 'gnar' ),
				'desc'		=> __('Show button below information?', 'gnar'),
				'type'		=> 'checkbox',
				'class'		=> 'trigger'
			),
			'subgroup_start_2' => array(
				'id'		=> 'subgroup_start_2',
		    	'type'		=> 'subgroup_start',
		    	'class'		=> 'hide receiver show-hide-toggle'
		    ),
			'button_color' => array(
				'id' 		=> 'button_color',
				'name'		=> __('Button Color', 'gnar'),
				'desc'		=> __('Select what color you\'d like to use for this button.', 'gnar'),
				'type'		=> 'select',
				'std'		=> 'custom',
				'class'		=> 'trigger',
				'options'	=> themeblvd_colors()
			),
			'button_custom' => array(
				'id' 		=> 'button_custom',
				'name'		=> __('Custom Button Color', 'gnar'),
				'desc'		=> __('Configure a custom style for the button.', 'gnar'),
				'std'		=> array(
					'bg' 				=> '#1b1b1b',
					'bg_hover'			=> '#ffffff',
					'border' 			=> '#ffffff',
					'text'				=> '#ffffff',
					'text_hover'		=> '#161616',
					'include_bg'		=> 0,
					'include_border'	=> 1
				),
				'type'		=> 'button',
				'class'		=> 'hide receiver receiver-custom'
			),
			'subgroup_end_2' => array(
				'id'		=> 'subgroup_end_2',
		    	'type'		=> 'subgroup_end'
		    ),
		    'button_text' => array(
				'id' 		=> 'button_text',
				'name'		=> __('Button Text', 'gnar'),
				'desc'		=> __('Enter the text for the button.', 'gnar'),
				'std'		=> 'Learn More',
				'type'		=> 'text',
				'class'		=> 'hide receiver'
			),
			'button_url' => array(
				'id' 		=> 'button_url',
				'name'		=> __('Link URL', 'gnar'),
				'desc'		=> __('Enter the full URL where you want the button\'s link to go.', 'gnar'),
				'std'		=> '',
				'type'		=> 'text',
				'class'		=> 'hide receiver'
			),
			'button_target' => array(
				'id' 		=> 'button_target',
				'name'		=> __('Link Target', 'gnar'),
				'desc'		=> __('Select how you want the button to open the webpage.', 'gnar'),
				'type'		=> 'select',
				'class'		=> 'hide receiver',
				'options'	=> array(
			        '_self' 	=> __('Same Window', 'gnar'),
			        '_blank' 	=> __('New Window', 'gnar'),
			        'lightbox' 	=> __('Lightbox Popup', 'gnar')
				)
			),
			'button_icon_before' => array(
				'id' 		=> 'button_icon_before',
				'name'		=> __('Icon Before Button Text (optional)', 'gnar'),
				'desc'		=> __('Icon before text of button. This can be any FontAwesome vector icon ID.', 'gnar'),
				'type'		=> 'text',
				'icon'		=> 'vector',
				'class'		=> 'hide receiver'
			),
			'button_icon_after' => array(
				'id' 		=> 'button_icon_after',
				'name'		=> __('Icon After Button Text (optional)', 'gnar'),
				'desc'		=> __('Icon after text of button. This can be any FontAwesome vector icon ID.', 'gnar'),
				'type'		=> 'text',
				'icon'		=> 'vector',
				'class'		=> 'hide receiver'
			),
			'subgroup_end_1' => array(
				'id'		=> 'subgroup_end_1',
		    	'type'		=> 'subgroup_end'
		    )
		)
	)));

}
add_action('after_setup_theme', 'gnar_elements');

/**
 * Get Featured Post element for this theme,
 * added to the layout builder.
 *
 * @since 1.0.0
 */
function gnar_get_featured_post( $args ) {

	$args = wp_parse_args( $args, array(
        'post_id'	=> 0,
		'label'		=> '',
		'color'		=> '#e64d43'
    ));

	$class = 'tb-featured-post tb-parallax';

	if ( $args['label'] ) {
		$class .= ' has-label';
	}

	$output = sprintf('<div class="%s">', $class);

	if ( $args['post_id'] ) {

		$q = new WP_Query( array(
			'post_type'	=> 'any',
			'post__in'	=> array( $args['post_id'] )
		));

		while ( $q->have_posts() ) {

			$q->the_post();

			themeblvd_set_att('color', $args['color']);
			themeblvd_set_att('label', $args['label']);

			$output .= themeblvd_get_bg_parallax(array(
				'bg_type'	=> 'image',
				'bg_color'	=> '#000000',
				'src'		=> wp_get_attachment_url( get_post_thumbnail_id() )
			));

			ob_start();
			get_template_part('content', 'featured-post');
			$output .= ob_get_clean();

		}

		wp_reset_postdata();

	}

	$output .= '</div><!-- .tb-featured-post (end) -->';

	return apply_filters('gnar_featured_post', $output);

}

/**
 * Callback function for Featured Post element
 * added to the layout builder.
 *
 * @since 1.0.0
 */
function gnar_featured_post( $id, $args ) {
	echo gnar_get_featured_post( $args );
}

/**
 * Get Image Box element for this theme,
 * added to the layout builder.
 *
 * @since 1.0.0
 */
function gnar_get_image_box( $args ) {

	$args = wp_parse_args( $args, array(
        'image'					=> array(),
		'title'					=> '',
		'info'					=> '',
		'button'				=> true,
		'button_color'			=> 'custom',
		'button_custom'			=> array(
			'bg'					=> '#1b1b1b',
            'bg_hover'				=> '#ffffff',
            'border'				=> '#ffffff',
            'text'					=> '#ffffff',
            'text_hover'			=> '#161616',
            'include_bg'			=> 0,
            'include_border'		=> 1
		),
		'button_text'			=> '',
		'button_url'			=> '',
		'button_target'			=> '_self',
		'button_icon_before'	=> '',
		'button_icon_after'		=> ''
    ));

	$output = '';

	$class = 'tb-image-box';

	if ( $args['title'] ) {
		$class .= ' has-title';
	}

	if ( $args['info'] ) {
		$class .= ' has-info';
	}

	if ( $args['button'] ) {
		$class .= ' has-button';
	}

	$output .= sprintf('<figure class="%s">', $class);

	if ( $args['image'] ) {

		$output .= '<img src="' . $args['image']['src'] . '"';

		if ( ! empty($args['image']['title']) ) {
			$output .= ' alt="' . $args['image']['title'] . '"';
		}

		if ( ! empty($args['image']['width']) ) {
			$output .= ' width="' . $args['image']['width'] . '"';
		}

		if ( ! empty($args['image']['height']) ) {
			$output .= ' height="' . $args['image']['height'] . '"';
		}

		$output .= ' />';

	}

	if ( $args['title'] || $args['info'] || $args['button'] ) {

		$output .= '<figcaption>';

		if ( $args['title'] ) {
			$output .= sprintf('<h5>%s</h5>', $args['title']);
		}

		$output .= '<div class="info">';

		if ( $args['title'] ) {
			$output .= sprintf('<h5>%s</h5>', $args['title']);
		}

		if ( $args['info'] ) {
			$output .= themeblvd_get_content($args['info']);
		}

		if ( $args['button'] ) {

			// Custom button styling
	        $addon = '';

	        if ( $args['button_color'] == 'custom' ) {

	            if ( $args['button_custom']['include_bg'] ) {
	                $bg = $args['button_custom']['bg'];
	            } else {
	                $bg = 'transparent';
	            }

	            if ( $args['button_custom']['include_border'] ) {
	                $border = $args['button_custom']['border'];
	            } else {
	                $border = 'transparent';
	            }

	            $addon = sprintf( 'style="background-color: %1$s; border-color: %2$s; color: %3$s;" data-bg="%1$s" data-bg-hover="%4$s" data-text="%3$s" data-text-hover="%5$s"', $bg, $border, $args['button_custom']['text'], $args['button_custom']['bg_hover'], $args['button_custom']['text_hover'] );

	        }

			$output .= themeblvd_button( $args['button_text'], $args['button_url'], $args['button_color'], $args['button_target'], 'small', '', '', $args['button_icon_before'], $args['button_icon_after'], $addon );
		}

		$output .= '</div><!-- .info (end) -->';

		$output .= '</figcaption>';

	}

	$output .= '</figure>';

	return apply_filters('gnar_image_box', $output);

}

/**
 * Callback function for Image Box element
 * added to the layout builder.
 *
 * @since 1.0.0
 */
function gnar_image_box( $id, $args ) {
	echo gnar_get_image_box( $args );
}

/**
 * CSS files
 *
 * @since 1.0.0
 */
function gnar_css() {

	// For plugins not inserting their scripts/stylesheets
	// correctly in the admin.
	if ( is_admin() ) {
		return;
	}

	// Theme version
	$theme = wp_get_theme( get_template() );
	$ver = $theme->get( 'Version' );
	$stylesheet_ver = $ver;

	if ( get_template() !== get_stylesheet() ) {

		$theme = wp_get_theme( get_stylesheet() );
		$stylesheet_ver = $theme->get( 'Version' );

	}

	// Get stylesheet API
	$handler = Theme_Blvd_Stylesheet_Handler::get_instance();

	// Main theme styles
	if ( is_rtl() ) {
		wp_enqueue_style( 'gnar', esc_url( get_template_directory_uri() . '/assets/css/theme-rtl.min.css' ), $handler->get_framework_deps(), $ver );
	} else {
		wp_enqueue_style( 'gnar', esc_url( get_template_directory_uri() . '/assets/css/theme.min.css' ), $handler->get_framework_deps(), $ver );
	}

	// Dark styles
	if ( themeblvd_supports('display', 'dark') ) {
		wp_enqueue_style( 'gnar-dark', esc_url( get_template_directory_uri() . '/assets/css/dark.min.css' ), $handler->get_framework_deps(), $ver );
	}

	// IE Stylesheet
	wp_enqueue_style( 'themeblvd-ie', esc_url( get_template_directory_uri() . '/assets/css/ie.css' ), array(), $ver );
	$GLOBALS['wp_styles']->add_data( 'themeblvd-ie', 'conditional', 'IE' ); // Add IE conditional

	// Primary style.css (mainly for child theme devs)
	wp_enqueue_style( 'themeblvd-theme', esc_url( get_stylesheet_uri() ), $handler->get_framework_deps(), $stylesheet_ver );

	// Level 3 client API-added styles
	$handler->print_styles(3);

	// Remove fontawesome from instagram-feed plugin, if exists
	wp_dequeue_style('sb_instagram_icons');

}
add_action('wp_enqueue_scripts', 'gnar_css', 20);

/**
 * CSS files
 *
 * @since 1.0.0
 */
function gnar_inline_css() {

	$print = '';

	/*------------------------------------------------------------*/
	/* 1. General
	/*------------------------------------------------------------*/

	// Primary Button Color
	$print .= "/* Primary Buttons */\n";
	$print .= ".btn:not(.tb-custom-button),\n";
	$print .= "input[type=\"submit\"],\n";
	$print .= "input[type=\"reset\"],\n";
	$print .= "input[type=\"button\"],\n";
	$print .= ".button,\n";
	$print .= "button,\n";
	$print .= ".primary,\n";
	$print .= ".bg-primary,\n";
	$print .= ".btn-primary,\n";
	$print .= ".pagination .btn-group .btn.active,\n";
	$print .= "a.alt,\n";
	$print .= "button.alt,\n";
	$print .= "input.alt,\n";
	$print .= ".label-primary,\n";
	$print .= ".panel-primary > .panel-heading,\n";
	$print .= ".tb-image-box,\n";
	$print .= ".tb-testimonial.standard .testimonial-text,\n";
	$print .= ".tb-filter-nav > ul > li.active a,\n";
	$print .= ".tb-filter-nav > ul > li.active a:hover,\n";
	$print .= ".tb-filter-nav > ul > li.active a:focus {\n";
	$print .= sprintf("\tbackground-color: %s;\n", themeblvd_get_option('btn_color') );
	$print .= "}\n";

	$print .= ".has-notch-primary:before {\n";
	$print .= sprintf("\tborder-top-color: %s;\n", themeblvd_get_option('btn_color') );
	$print .= "}\n";

	if ( is_rtl() ) {
		$print .= ".tb-testimonial.standard .arrow {\n";
		$print .= sprintf("\tborder-left-color: %s;\n", themeblvd_get_option('btn_color') );
		$print .= "}\n";
	} else {
		$print .= ".tb-testimonial.standard .arrow {\n";
		$print .= sprintf("\tborder-right-color: %s;\n", themeblvd_get_option('btn_color') );
		$print .= "}\n";
	}

	// Highlight Color
	$print .= "\n/* Highlight */\n";

	$print .= ".highlight,\n";

	if ( themeblvd_supports('plugins', 'wpml') && themeblvd_installed('wpml') ) {
		$print .= ".gnar-lang-selector a:hover,\n";
		$print .= ".gnar-lang-selector a:focus,\n";
	}

	if ( themeblvd_supports('plugins', 'woocommerce') && themeblvd_installed('woocommerce') ) {
		$print .= ".woocommerce-tabs .tabs > li > a:hover,\n";
		$print .= ".woocommerce-tabs .tabs > li > a:focus,\n";
		$print .= ".woocommerce-tabs .tabs > li.active > a,\n";
	}

	$print .= ".tb-mobile-menu .sub-menu a.menu-btn:hover,\n";
	$print .= ".tb-mobile-menu .sub-menu a.menu-btn:focus,\n";
	$print .= ".tb-tags a:hover,\n";
	$print .= ".tb-tags a:focus,\n";
	$print .= ".btn-share:hover,\n";
	$print .= ".btn-share:focus,\n";
	$print .= ".featured-quote > a:hover,\n";
	$print .= ".featured-quote > a:focus,\n";
	$print .= ".tb-thumb-link:after,\n";
	$print .= ".post_showcase .showcase-item.has-title .featured-item.showcase .tb-thumb-link:after,\n";
	$print .= ".post_showcase .showcase-item.has-title .featured-item.showcase.tb-thumb-link:after,\n";
	$print .= ".tb-filter-nav > ul > li > a:hover,\n";
	$print .= ".tb-filter-nav > ul > li > a:focus,\n";
	$print .= ".text-light .tb-filter-nav > ul > li > a:hover,\n";
	$print .= ".text-light .tb-filter-nav > ul > li > a:focus,\n";
	$print .= ".tb-tag-cloud .tagcloud a:hover,\n";
	$print .= ".btn-default:hover,\n";
	$print .= ".btn-default:focus,\n";
	$print .= ".btn-default:active,\n";
	$print .= ".btn-default.active:hover,\n";
	$print .= "input[type=\"submit\"]:hover,\n";
	$print .= "input[type=\"submit\"]:focus,\n";
	$print .= "input[type=\"submit\"]:active,\n";
	$print .= "input[type=\"reset\"]:hover,\n";
	$print .= "input[type=\"reset\"]:focus,\n";
	$print .= "input[type=\"reset\"]:active,\n";
	$print .= "input[type=\"button\"]:hover,\n";
	$print .= "input[type=\"button\"]:focus,\n";
	$print .= "input[type=\"button\"]:active,\n";
	$print .= ".button:hover,\n";
	$print .= ".button:focus,\n";
	$print .= ".button:active,\n";
	$print .= "button:hover,\n";
	$print .= "button:focus,\n";
	$print .= "button:active,\n";
	$print .= ".pagination .btn-group .btn:hover,\n";
	$print .= ".primary:hover,\n";
	$print .= ".primary:focus,\n";
	$print .= "a.bg-primary:hover,\n";
	$print .= ".btn-primary:hover,\n";
	$print .= ".btn-primary:focus,\n";
	$print .= ".btn-primary:active,\n";
	$print .= ".btn-primary.active,\n";
	$print .= "a.alt:hover,\n";
	$print .= "a.alt:focus,\n";
	$print .= "button.alt:hover,\n";
	$print .= "button.alt:focus,\n";
	$print .= "input.alt:hover,\n";
	$print .= "input.alt:focus,\n";
	$print .= ".home-quick-facts > .element-content:before,\n"; // "home-quick-facts" is for compat, with those that created layout before v1.0.4
	$print .= ".home-quick-facts .element-columns .col:first-child .element-content:before,\n"; // "home-quick-facts" is for compat, with those that created layout before v1.0.4
	$print .= ".home-quick-fact-boxes > .element-content:before,\n";
	$print .= ".home-quick-fact-boxes > .element-columns:before,\n";
	$print .= ".tb-team-member .member-image:before {\n";
	$print .= sprintf( "\tbackground-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "}\n";

	$print .= ".tooltip-inner {\n";
	$print .= sprintf( "background-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "}\n";

	$print .= ".has-notch-highlight:before,\n";
	$print .= ".tb-testimonial.standard .testimonial-text,\n";
	$print .= ".tooltip.top .tooltip-arrow {\n";
	$print .= sprintf( "\tborder-top-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "}\n";

	$print .= ".tb-floating-search .tb-search,\n";
	$print .= ".tooltip.bottom .tooltip-arrow {\n";
	$print .= sprintf( "\tborder-bottom-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "}\n";

	$print .= ".home-quick-facts .element-columns .col:first-child,\n";
	$print .= ".home-quick-fact-boxes .element-columns .col:first-child {\n";
	$print .= sprintf( "\tborder-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "}\n";

	$print .= "@media (min-width: 768px) {\n";
	$print .= "\t.tb-image-box:hover {\n";
	$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "\t}\n";
	$print .= "}\n";

	$print .= "@media (max-width: 767px) {\n";
	$print .= "\t.tb-image-box figcaption .info {\n";
	$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('highlight') );
	$print .= "\t}\n";
	$print .= "}\n";


	/*------------------------------------------------------------*/
	/* 2. Header
	/*------------------------------------------------------------*/

	$style = themeblvd_get_option('header_style', null, 'edgy');

	$print .= "\n/* Header */\n";

	$print .= ".header-bg,\n";

	if ( $style == 'modern' ) {
		$print .= ".gnar-search-panel-on .site-menu-toggle.modern,\n";
	}

	$print .= ".tb-primary-menu.sf-menu ul.non-mega-sub-menu,\n";
	$print .= ".tb-primary-menu.sf-menu .sf-mega {\n";
	$print .= sprintf( "\tbackground-color: %s;\n", themeblvd_get_option('header_bg_color') );
	$print .= "}\n";

	$print .= ".header-nav .tb-primary-menu > li.active > a:after,\n";
	$print .= ".header-nav .tb-primary-menu > li.menu-item-has-children.sfHover:not(.highlight) > a:after {\n";
	$print .= sprintf( "\tborder-top-color: %s;\n", themeblvd_get_option('header_bg_color') );
	$print .= "}\n";

	// Logo Background Color
	if ( $style == 'edgy' || $style == 'bold' ) {

		$print .= "@media (min-width: 992px) {\n";

		if ( $style == 'edgy' ) {
			$print .= "\t.site-header.edgy > .wrap .header-logo:after,\n";
			$print .= "\t.site-header.edgy > .wrap .header-logo:before,\n";
		}

		$print .= sprintf("\t.site-header.%s > .wrap .header-logo {\n", $style);
		$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('header_logo_color') );
		$print .= "\t}\n";
		$print .= "}\n";

	}

	// Menu Toggle Color
	if ( $style == 'edgy' || $style == 'bold' ) {

		$print .= "@media (min-width: 992px) {\n";

		$print .= sprintf( "\t.site-menu-toggle.%s {\n", $style );
		$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('header_toggle_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s:after {\n", $style );
		$print .= sprintf( "\t\tborder-color: %s transparent transparent;\n", themeblvd_get_option('header_toggle_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s .hamburger span {\n", $style );
		$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('header_bg_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s .hamburger span:after {\n", $style );
		$print .= sprintf( "\t\tborder-color: %s transparent transparent;\n", themeblvd_get_option('header_bg_color') );
		$print .= "\t}\n";

		$print .= "}\n";

	}

	// Main Menu Arrows
	if ( ! themeblvd_get_option('menu_arrows') ) {
		$print .= "\n/* Main Menu */\n";
		$print .= ".header-nav .tb-primary-menu > li > a > .sf-sub-indicator {\n";
		$print .= "\tdisplay: none;\n";
		$print .= "}\n\n";
	}

	/*------------------------------------------------------------*/
	/* 3. Mobile Header
	/*------------------------------------------------------------*/

	$print .= "\n/* Mobile Header */\n";
	$print .= "@media (max-width: 991px) {\n";

	$print .= "\t.site-header {\n";
	$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('mobile_header_bg_color') );
	$print .= "\t}\n";

	$print .= "\t.site-mobile-panel {\n";
	$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('mobile_menu_color') );
	$print .= "\t}\n";

	// Menu Toggle Color
	if ( $style == 'edgy' || $style == 'bold' ) {

		$print .= sprintf( "\t.site-menu-toggle.%s {\n", $style );
		$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('mobile_header_toggle_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s:after {\n", $style );
		$print .= sprintf( "\t\tborder-color: %s transparent transparent;\n", themeblvd_get_option('mobile_header_toggle_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s .hamburger span {\n", $style );
		$print .= sprintf( "\t\tbackground-color: %s;\n", themeblvd_get_option('mobile_header_bg_color') );
		$print .= "\t}\n";

		$print .= sprintf( "\t.site-menu-toggle.%s .hamburger span:after {\n", $style );
		$print .= sprintf( "\t\tborder-color: %s transparent transparent;\n", themeblvd_get_option('mobile_header_bg_color') );
		$print .= "\t}\n";

	}

	// Non-sticky header for mobile
	if ( ! themeblvd_get_option('mobile_header_fixed') ) {
		$print .= "\t.site-header,\n";
		$print .= "\t.site-menu-toggle {\n";
		$print .= "\t\tposition: absolute;\n";
		$print .= "\t}\n";
	}

	$print .= "}\n";

	/*------------------------------------------------------------*/
	/* 4. Footer
	/*------------------------------------------------------------*/

	// Footer
	$print .= "\n/* Footer */\n";
	$print .= sprintf( ".site-footer.%s {\n", themeblvd_get_option('footer_bg_brightness') );
	$print .= sprintf( "\tbackground-color: %s;\n", themeblvd_get_option('footer_bg_color') );
	$print .= "}\n";
	$print .= ".site-footer .footer-sub-content {\n";
	$print .= sprintf( "\tbackground-color: %s;\n", themeblvd_get_option('copyright_bg_color') );
	$print .= "}\n";

	/*------------------------------------------------------------*/
	/* 5. Search Panel
	/*------------------------------------------------------------*/

	$print .= "\n/* Search Panel */\n";
	$print .= ".tb-floating-search {\n";
	$print .= sprintf( "\tbackground-color: %s;\n", themeblvd_get_option('search_panel_bg_color') );
	$print .= "}\n";

	/*------------------------------------------------------------*/
	/* 6. Typography
	/*------------------------------------------------------------*/

	$print .= "\n/* Typography */\n";

	// Primary Font
	$font = themeblvd_get_option('font_body');

	if ( $font ) {

		$print .= "html,\n";
		$print .= "body {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-size: %s;\n", themeblvd_get_font_size($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";
	}

	// Header Font
	$font = themeblvd_get_option('font_header');

	if ( $font ) {

		$print .= "h1,\n";
		$print .= "h2,\n";
		$print .= "h3,\n";
		$print .= "h4,\n";

		if ( themeblvd_installed('gravityforms') && themeblvd_supports('plugins', 'gravityforms') ) {
			$print .= ".tb-gforms-compat .gform_wrapper .gsection .gfield_label,\n";
			$print .= ".tb-gforms-compat .gform_wrapper h2.gsection_title,\n";
			$print .= ".tb-gforms-compat .gform_wrapper h3.gform_title,\n";
		}

		$print .= ".has-dropcap > .entry-content > p:first-child:first-letter {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_header_sp') );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";
	}

	// Small Header Font
	$font = themeblvd_get_option('font_header_sm');

	if ( $font ) {

		$print .= "h5,\n";
		$print .= "h6,\n";
		$print .= ".widget-title,\n";
		$print .= ".related-posts-title,\n";
		$print .= "#comments-title,\n";
		$print .= "#respond .comment-reply-title,\n";
		$print .= ".tb-author-box .info-box-title,\n";
		$print .= ".woocommerce-tabs .panel h2,\n";
		$print .= ".products.related > h2,\n";
		$print .= ".products.upsells > h2,\n";
		$print .= "#bbpress-forums fieldset.bbp-form legend,\n";
		$print .= ".modal-title,\n";
		$print .= ".sf-menu .mega-section-header,\n";
		$print .= ".tb-pricing-table .title,\n";
		$print .= ".tb-icon-box .icon-box-title {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_header_sm_sp') );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";
	}

	// Quote Font
	$font = themeblvd_get_option('font_quote');

	if ( $font ) {

		$print .= "blockquote,\n";
		$print .= ".epic-thumb blockquote,\n";
		$print .= ".entry-content blockquote,\n";
		$print .= ".testimonial-text.entry-content {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_quote_sp') );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";
	}

	// Meta Font
	$font = themeblvd_get_option('font_meta');

	if ( $font ) {

		$print .= ".entry-header .entry-meta,\n";
		$print .= ".post_grid .entry-meta,\n";
		$print .= ".tb-post-slider .entry-meta,\n";
		$print .= ".tweeple-feed .tweet-meta,\n";
		$print .= "#comments .comment-body .comment-metadata,\n";
		$print .= "blockquote cite {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_meta_sp') );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";
	}

	// Featured Image Title Font
	$font = themeblvd_get_option('font_epic');

	if ( $font ) {

		$print .= ".epic-thumb .entry-title,\n";
		$print .= ".tb-jumbotron .text-large {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";

		$print .= ".epic-thumb .entry-title,\n";
		$print .= ".epic-thumb blockquote {\n";
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_epic_sp') ); // we don't want letter-spacing on .text-large of hero unit because there's an option
		$print .= "}\n";

	}

	// Main Menu Font
	$font = themeblvd_get_option('font_menu');

	if ( $font ) {

		$print .= ".tb-primary-menu > li > .menu-btn,\n";
		$print .= ".tb-sticky-menu .tb-primary-menu > li > .menu-btn,\n";
		$print .= ".tb-mobile-menu > li > .menu-btn {\n";

		$print .= sprintf("\tfont-family: %s;\n", themeblvd_get_font_face($font) );
		$print .= sprintf("\tfont-size: %s;\n", themeblvd_get_font_size($font) );
		$print .= sprintf("\tfont-style: %s;\n", themeblvd_get_font_style($font) );
		$print .= sprintf("\tfont-weight: %s;\n", themeblvd_get_font_weight($font) );
		$print .= sprintf("\tletter-spacing: %s;\n", themeblvd_get_option('font_menu_sp') );
		$print .= sprintf("\ttext-transform: %s;\n", themeblvd_get_text_transform($font) );

		$print .= "}\n";

	}

	// Links
	$print .= "a {\n";
	$print .= sprintf("\tcolor: %s;\n", themeblvd_get_option('link_color'));
	$print .= "}\n";

	$print .= "a:hover,\n";
	$print .= "a:active,\n";
	$print .= "a:focus {\n";
	$print .= sprintf("\tcolor: %s;\n", themeblvd_get_option('link_hover_color'));
	$print .= "}\n";

	$print .= ".site-footer a {\n";
	$print .= sprintf("\tcolor: %s;\n", themeblvd_get_option('footer_link_color'));
	$print .= "}\n";

	$print .= ".site-footer a:hover,\n";
	$print .= ".site-footer a:active,\n";
	$print .= ".site-footer a:focus {\n";
	$print .= sprintf("\tcolor: %s;\n", themeblvd_get_option('footer_link_hover_color'));
	$print .= "}\n";

	/*------------------------------------------------------------*/
	/* 7. Custom CSS
	/*------------------------------------------------------------*/

	if ( $custom = themeblvd_get_option('custom_styles') ) {
		$print .= "\n/* =Custom CSS\n";
		$print .= "-----------------------------------------------*/\n\n";
		$print .= $custom;
	}

	/*------------------------------------------------------------*/
	/* 8. Finalize
	/*------------------------------------------------------------*/

	// Sanitize
	$print = wp_kses( $print, array() );
	$print = htmlspecialchars_decode( $print );

	// Final output
	if ( $print ) {

		$handle = 'gnar';

		if ( themeblvd_supports('display', 'dark') ) {
			$handle = $handle . '-dark';
		}

		wp_add_inline_style( $handle, apply_filters('gnar_css_output', $print) );
	}

}
add_action('wp_enqueue_scripts', 'gnar_inline_css', 25);

/**
 * Scripts
 *
 * @since 1.0.0
 */
function gnar_scripts() {

	global $themeblvd_framework_scripts;

	$theme = wp_get_theme( get_template() );
	$ver = $theme->get('Version');

	wp_enqueue_script( 'themeblvd_theme', esc_url( get_template_directory_uri() . '/assets/js/theme.min.js' ), $themeblvd_framework_scripts, $ver, themeblvd_supports('assets', 'in_footer') );

}
add_action('wp_enqueue_scripts', 'gnar_scripts');

/**
 * Include Google fonts, if needed
 *
 * @since 1.0.0
 */
function gnar_include_fonts() {
	themeblvd_include_fonts(
		themeblvd_get_option('font_body'),
		themeblvd_get_option('font_header'),
		themeblvd_get_option('font_header_sm'),
		themeblvd_get_option('font_quote'),
		themeblvd_get_option('font_meta'),
		themeblvd_get_option('font_epic'),
		themeblvd_get_option('font_menu')
	);
}
add_action('wp_head', 'gnar_include_fonts', 5);

/**
 * Body classes
 *
 * @since 1.0.0
 */
function gnar_body_class( $class ) {

	global $post;

	if ( themeblvd_get_option('img_popout') ) {
		$class[] = 'tb-img-popout';
	}

	if ( function_exists('themeblvd_show_breadcrumbs') && themeblvd_show_breadcrumbs() ) {
		$class[] = 'has-breadcrumbs';
	}

	if ( themeblvd_get_option('header_logo_placement') == 'left' ) {
		$class[] = 'logo-left';
	} else {
		$class[] = 'logo-right';
	}

	if ( themeblvd_get_option('layout_style') == 'boxed' ) {
		$class[] = 'gnar-boxed';
		$class[] = 'tb-boxed'; // for framework JS
	}

	if ( themeblvd_get_option('menu_visible') ) {
		$class[] = 'menu-visible';
	}

	return $class;
}
add_filter('body_class', 'gnar_body_class');

/**
 * Add post classes
 *
 * @since 1.0.0
 */
function gnar_post_class( $class ) {

	global $post;

	if ( in_array('single', $class) && in_array('type-post', $class) ) {

		$dropcap = get_post_meta($post->ID, 'tb_dropcap', true);

		if ( ! $dropcap || $dropcap == 'default' ) {
			$dropcap = themeblvd_get_option('dropcap');
		} else if ( $dropcap == 'no' ) {
			$dropcap = '0';
		}

		if ( $dropcap ) {
			$class[] = 'has-dropcap';
		}
	}

	return $class;
}
add_action('post_class', 'gnar_post_class');

/**
 * Remove default framework header callbacks
 *
 * @since 1.0.0
 */
remove_action('themeblvd_header_before', 'themeblvd_header_before_default');
remove_action('themeblvd_header_top', 'themeblvd_header_top_default');
remove_action('themeblvd_header_content', 'themeblvd_header_content_default');
remove_action('themeblvd_header_menu', 'themeblvd_header_menu_default');

/**
 * Add CSS classes to header
 *
 * @since 1.0.0
 */
function gnar_header_class( $class ) {

	$class[] = themeblvd_get_option('header_style', null, 'edgy');
	$class[] = themeblvd_get_option('header_bg_brightness', null, 'dark');
	$class[] = 'mobile-' . themeblvd_get_option('mobile_header_bg_brightness', null, 'dark');

	if ( themeblvd_do_lang_selector() ) {
		$class[] = 'has-lang-selector';
	}

	if ( themeblvd_do_cart() ) {
		$class[] = 'has-cart-button';
	}

	return $class;
}
add_filter('themeblvd_header_class', 'gnar_header_class');

/**
 * Add search and menu panels.
 *
 * @since 1.0.0
 */
function gnar_before() {

	if ( ! themeblvd_config('top') || is_page_template('template_blank.php') ) {
		return;
	}

	$style = themeblvd_get_option('header_style', null, 'edgy');
	$class = $style;

	if ( $style == 'modern' ) {
		$class .= ' '.themeblvd_get_option('header_bg_brightness', null, 'dark');
		$class .= ' mobile-'.themeblvd_get_option('mobile_header_bg_brightness', null, 'dark');
	}

	if ( themeblvd_config('suck_up') ) {
		$class .= ' transparent';
	}
	?>

	<a href="#" class="site-menu-toggle <?php echo $class; ?>">
		<span class="hamburger">
			<span class="top"></span>
			<span class="middle"></span>
			<span class="bottom"></span>
		</span>
	</a>

	<?php
	/**
	 * @hooked NULL
	 */
	do_action( 'themeblvd_header_menu_before' );
	?>

	<div class="site-menu-panel <?php echo themeblvd_get_option('header_style', null, 'edgy'); ?> <?php echo themeblvd_get_option('header_bg_brightness', null, 'light') ?>">
		<div class="wrap">
			<nav id="access" class="header-nav <?php echo themeblvd_get_option('header_bg_brightness', null, 'dark') ?>">
				<div class="wrap clearfix">

					<?php if ( themeblvd_get_option('menu_visible') ) : ?>
						<?php gnar_toolbar(); ?>
					<?php endif; ?>

					<?php wp_nav_menu( themeblvd_get_wp_nav_menu_args('primary') ); ?>

					<?php
					/**
					 * @hooked gnar_header_menu_addon - 10
					 */
					do_action('themeblvd_header_menu_addon');
					?>
				</div><!-- .wrap (end) -->
			</nav><!-- #access (end) -->
			<div class="header-bg"></div>
		</div><!-- .wrap (end) -->
	</div><!-- .menu-panel (end) -->

	<?php
	/**
	 * @hooked NULL
	 */
	do_action( 'themeblvd_header_menu_after' );

}
add_action('themeblvd_before', 'gnar_before');

/**
 * Add social icons to menu panel
 *
 * @since 1.0.0
 */
function gnar_header_menu_addon() {
	echo themeblvd_get_contact_bar( null, array('style' => 'custom') );
}
add_action('themeblvd_header_menu_addon', 'gnar_header_menu_addon');

/**
 * Add to theme header
 *
 * @since 1.0.0
 */
function gnar_header_content() {

	/**
	 * @hooked themeblvd_header_logo_default - 10
	 * @hooked gnar_header_logo_mobile - 20
	 */
	do_action('themeblvd_header_logo');
	?>

	<?php gnar_toolbar(); ?>

	<div class="header-bg"></div>

	<?php
}
add_action('themeblvd_header_content', 'gnar_header_content');

/**
 * Top nav menu of icons.
 *
 * @since 1.0.1
 */
function gnar_toolbar() {
	?>

	<?php if ( themeblvd_get_option('searchform') == 'show' || themeblvd_do_cart() || themeblvd_do_lang_selector() ) : ?>
		<ul class="header-top-nav list-unstyled">

			<?php if ( themeblvd_do_cart() ) : ?>
				<li class="top-cart"><?php themeblvd_cart_popup_trigger(); ?></li>
			<?php endif; ?>

			<?php if ( themeblvd_do_lang_selector() ) : ?>
				<li class="top-lang">
					<a href="#" class="gnar-lang-trigger" title="<?php echo themeblvd_get_local('language'); ?>" data-toggle="modal" data-target="#floating-lang-switcher">
						<i class="fa fa-globe"></i>
					</a>
				</li>
			<?php endif; ?>

			<?php if ( themeblvd_get_option('searchform') == 'show' ) : ?>
				<li class="top-search">
					<a href="#" class="tb-search-trigger gnar-search-trigger" title="<?php echo themeblvd_get_local('search'); ?>">
						<i class="fa fa-search"></i>
					</a>
				</li>
			<?php endif; ?>

		</ul>
	<?php endif; ?>

	<?php
}

/**
 * Get modal window for WPML language switcher.
 *
 * @since 1.0.0
 */
function gnar_get_lang_popup() {

	$output  = '<div id="floating-lang-switcher" class="gnar-lang-popup modal fade">';
	$output .= '<div class="modal-dialog modal-sm">';
	$output .= '<div class="modal-content">';
	$output .= '<div class="modal-header">';
	$output .= '<button type="button" class="close" data-dismiss="modal" aria-label="'.themeblvd_get_local('close').'"><span aria-hidden="true">&times;</span></button>';
	$output .= '<h4 class="modal-title">'.themeblvd_get_local('language').'</h4>';
	$output .= '</div>';
	$output .= '<div class="modal-body clearfix">';

	if ( function_exists('icl_get_languages') ) {

		$langs = icl_get_languages('skip_missing=1');

		if ( $langs ) {

			$output .= '<ul class="gnar-lang-selector list-unstyled">';

			foreach ( $langs as $lang ) {

				$class = 'lang-'.$lang['language_code'];

				if ( $lang['active'] ) {
					$class .= ' active';
				}

				$output .= '<li class="'.$class.'">';

				if ( $lang['active'] ) {
					$output .= sprintf('<span title="%1$s">%1$s</span>', $lang['translated_name'] );
				} else {
					$output .= sprintf('<a href="%1$s" title="%2$s">%2$s</a>', $lang['url'], $lang['translated_name'] );
				}

				$output .= '</li>';

			}

			$output .= '</ul>';
		}
	}

	$output .= '</div><!-- .modal-body (end) -->';
	$output .= '</div><!-- .modal-content (end) -->';
	$output .= '</div><!-- .modal-dialog (end) -->';
	$output .= '</div><!-- .tb-wpml-switcher (end) -->';

	return apply_filters('gnar_lang_selector', $output);
}

/**
 * Output modal window for WPML language switcher.
 *
 * @since 1.0.0
 */
function gnar_lang_popup() {
	if ( themeblvd_do_lang_selector() ) {
		echo gnar_get_lang_popup();
	}
}
add_action( 'themeblvd_after', 'gnar_lang_popup' );

/**
 * Add brightness class to floating search
 *
 * @since 1.0.0
 */
function gnar_floating_search( $output ) {
	return str_replace('tb-floating-search', 'tb-floating-search '.themeblvd_get_option('search_panel_brightness'), $output);
}
add_filter('themeblvd_floating_search', 'gnar_floating_search');

/**
 * Remove the "Ads Above Header" widget area location
 *
 * @since 1.0.0
 */
function gnar_sidebar_locations( $locations ) {
	unset($locations['ad_above_header']);
	return $locations;
}
add_filter('themeblvd_sidebar_locations', 'gnar_sidebar_locations');

/**
 * Filter comment_form() arguments from framework
 *
 * @since 1.0.0
 */
function gnar_comment_form( $args ) {
	$args['comment_notes_after'] = null;
	return $args;
}
add_filter('themeblvd_comment_form', 'gnar_comment_form');

/**
 * Disable/enable time ago, depending on theme
 * option checkbox
 *
 * @since 1.0.0
 */
function gnar_meta_args( $args ) {

	if ( themeblvd_get_option('timeago') ) {
		$args['time'] = 'ago';
	} else {
		$args['time'] = 'standard';
	}

	return $args;
}
add_filter('themeblvd_blog_meta_args', 'gnar_meta_args');
add_filter('themeblvd_grid_meta_args', 'gnar_meta_args');
add_filter('themeblvd_mini_list_meta_args', 'gnar_meta_args');
add_filter('themeblvd_small_grid_meta_args', 'gnar_meta_args');
add_filter('themeblvd_small_list_meta_args', 'gnar_meta_args');
add_filter('themeblvd_search_meta_args', 'gnar_meta_args');

/**
 * Add footer classes
 *
 * @since 1.0.0
 */
function gnar_footer_class( $class ) {
	$class[] = themeblvd_get_option('footer_bg_brightness', null, 'dark');
	return $class;
}
add_filter('themeblvd_footer_class', 'gnar_footer_class');

/**
 * Remove framework default footer copyright area.
 *
 * @since 1.0.0
 */
remove_action('themeblvd_footer_sub_content', 'themeblvd_footer_sub_content_default');

/**
 * Add custom footer copyright area.
 *
 * @since 1.0.0
 */
function gnar_footer_sub_content() {

	$bg = themeblvd_get_option('copyright_bg_brightness', null, 'dark');

	echo '<div class="footer-sub-content '.$bg.'">';
	echo '<div class="wrap clearfix">';

	if ( themeblvd_get_option('social_footer') ) {

		$style = 'light'; // "light" means it's meant to display over dark BG

		if ( $bg == 'light' ) {
			$style = 'grey';
		}

		echo themeblvd_get_contact_bar(null, array('tooltip' => 'top', 'style' => $style));

	}

	echo '<div class="copyright">' . apply_filters( 'themeblvd_footer_copyright', themeblvd_get_content( themeblvd_get_option('footer_copyright') ) ) . '</div>';

	if ( has_nav_menu('footer') ) {
		echo '<div class="footer-nav">';
		wp_nav_menu( themeblvd_get_wp_nav_menu_args('footer') );
		echo '</div>';
	}

	echo '</div><!-- .wrap (end) -->';
	echo '</div><!-- .footer-sub-content (end) -->';
}
add_action('themeblvd_footer_sub_content', 'gnar_footer_sub_content');

/**
 * Increase the size of the Read More button
 * in the blog.
 *
 * @since 1.0.0
 */
function gnar_the_excerpt_more_args( $args ) {
	$args['size'] = 'large';
	return $args;
}
add_filter('themeblvd_the_excerpt_more_args', 'gnar_the_excerpt_more_args');

/**
 * Set height of header for when transparent
 * header is used.
 *
 * @since 1.0.0
 */
function gnar_top_height() {
	return 0;
}
add_filter('themeblvd_top_height', 'gnar_top_height');

/**
 * When scrolling to a section, set offset to
 * account for theme's custom sticky header.
 *
 * @since 1.0.0
 */
function gnar_scroll_to_section_offset() {
	return 64;
}
add_filter('themeblvd_scroll_to_section_offset', 'gnar_scroll_to_section_offset');

/**
 * Modify scroll-to-section button to show fa icon.
 *
 * @since 1.0.0
 */
function gnar_to_section( $output, $args ) {
	return sprintf('<a href="#%s" class="tb-scroll-to-section tb-scroll-to">%s</a>', esc_attr($args['to']), '<i class="fa fa-chevron-down"></i>');
}
add_filter('themeblvd_to_section', 'gnar_to_section', 10, 2);

/**
 * Add diagnoal shading to sections based on adding
 * the CSS classes "has-diag-shade".
 *
 * @since 1.0.0
 */
function gnar_section_top( $section_id, $layout_name, $data ) {

	$display = $data['display'];

	if ( strpos($display['classes'], 'has-diag-shade') !== false ) {
		if ( in_array($display['bg_type'], array('image', 'slideshow', 'video')) && ! empty($display['apply_bg_shade']) ) {
			echo '<svg class="bg-diag-shade" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 10" preserveAspectRatio="none">';
			printf( '<polygon points="0 0 100 0 0 10" fill="%s" />', esc_attr( themeblvd_get_rgb( $display['bg_shade_color'], $display['bg_shade_opacity'] ) ) );
			echo '</svg>';
		}
	}

}
add_action('themeblvd_section_top', 'gnar_section_top', 10, 3);

/**
 * Add custom hover effect to thumbnails
 */
function gnar_post_thumbnail( $html ) {
	return str_replace('</a>', '<span class="swipe"></span></a>', $html);
}
add_filter('themeblvd_post_thumbnail', 'gnar_post_thumbnail');
