Shoora
4/22/2019 - 9:29 AM

enqueue-scripts.php

<?php

function foundationpress_scripts() {
	// CSS
    wp_enqueue_style( 'Main Stylesheet',
        get_stylesheet_directory_uri() . '/assets/css/foundation.css' );


	// Common JS
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery',
        '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js', [], '2.1.0', true );

    wp_register_script( 'modernizr',
        get_stylesheet_directory_uri() . '/assets/js/vendor/modernizr.js', [], '2.8.3', true );

    wp_register_script('fastclick',
        get_stylesheet_directory_uri() . '/assets/js/vendor/fastclick.js', [], '1.0.6', true);

    wp_register_script( 'foundation',
        get_stylesheet_directory_uri() . '/assets/js/foundation.js', ['jquery'], '5.5.2', true );

	wp_register_script( 'typekit-library',
		'//use.typekit.net/upv2zan.js', [], '1.0.0', false );
	wp_register_script( 'typekit',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/typekit.js', ['jquery'], '5.5.2', false );

	wp_register_script('lazyloadxt',
		get_stylesheet_directory_uri() . '/assets/js/vendor/jquery.lazyloadxt.min.js', ['jquery'], false, true);

	wp_register_script('lazyloadxt-bg',
		get_stylesheet_directory_uri() . '/assets/js/vendor/jquery.lazyloadxt.bg.js', ['lazyloadxt'], false, true);

    $background_params = array(
        'color'         => get_option('offgrid_background_scheme_color'),
        'background'    => get_option('offgrid_background_scheme_background'),
        'front_page'    => is_front_page()
    );
    wp_localize_script( 'foundation', 'backgroundScheme', $background_params );

    wp_localize_script('foundation', 'ajax',
        ['url' => admin_url('admin-ajax.php')]);


	// Page Specific JS
    wp_register_script('offgrid-gallery',
        get_stylesheet_directory_uri() . '/assets/js/custom/libs/gallery.js', ['jquery'], false, true);

	wp_register_script('gallery-swipe',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/jquery.touchSwipe.min.js', ['offgrid-gallery'], false, true);

    wp_register_script('slick-slider',
        get_stylesheet_directory_uri() . '/assets/js/slick.min.js', ['jquery'], false, true);

	wp_register_script('sticky-social',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/stickySocial.js', ['foundation'], false, true);

	wp_register_script('totopscroll',
		get_stylesheet_directory_uri() . '/assets/js/custom/modules/to-top.js', [], '', true );

    wp_register_script('livefyre-head',
        '//cdn.livefyre.com/Livefyre.js', [], false, false);

    wp_register_script('livefyre',
        '//cdn.livefyre.com/Livefyre.js', [], false, true);

    // Omnitrue JS
    wp_register_script('omniture-dev',
        get_stylesheet_directory_uri() . '/assets/js/custom/libs/omnituredev.js', [], 'H.25.3', true);

    wp_register_script('omniture-prod',
        get_stylesheet_directory_uri() . '/assets/js/custom/libs/omnitureprod.js', [], 'H.25.3', true);

    wp_register_script('omniture-dev',
        get_stylesheet_directory_uri() . '/assets/js/custom/libs/omnituredev.js', [], 'H.25.3', true);

    wp_register_script('omniture-prod',
        get_stylesheet_directory_uri() . '/assets/js/custom/libs/omnitureprod.js', [], 'H.25.3', true);
	wp_register_script( 'omnitureg',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/omnitureglobal.js',[], 'H.25.3', true );

	wp_register_script( 'omnituree',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/omniture_events.js', [], 'H.25.3', true );

	wp_register_script( 'omniturec',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/omniture_s_code.js', [], 'H.25.3', true );

	wp_register_script( 'omniturea',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/omniture_addthisconfig.js', [], 'H.25.3', true );

	wp_register_script( 'videotracking',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/kaltura-utils.js', [], '', true );


	// Ads JS
	//wp_enqueue_script( 'nativoad',
		//'//s.ntv.io/serve/load.js?async=true', [], '', true );
	//
	wp_register_script( 'interstitial_rs',
		get_stylesheet_directory_uri() . '/assets/js/custom/libs/interstitial_receivemessage.js', [], '', true );

    wp_enqueue_script('jquery');

	if (get_post_type() == 'product') {
		wp_enqueue_script('slick-slider');
	}

    // Enqueue all registered scripts
    wp_enqueue_script('foundation');
    wp_enqueue_script('typekit-library');
    wp_enqueue_script('typekit');
    wp_enqueue_script('modernizr');
    wp_enqueue_script('fastclick');

	if (is_single()) {
		wp_enqueue_script('offgrid-gallery');
		wp_enqueue_script('gallery-swipe');
		wp_enqueue_script('sticky-social');
        wp_enqueue_script('livefyre');
		wp_enqueue_script('totopscroll');
	}

    if (is_page('media-wall') || is_404() ) {
        wp_enqueue_script('livefyre-head');
	}

    if (WP_ENV == 'production') {
        wp_enqueue_script('omnitureprod');
    } else {
        wp_enqueue_script('omnituredev');
    }

    wp_enqueue_script('omniturec');
    wp_enqueue_script('omnitureg');
    wp_enqueue_script('omnituree');
    wp_enqueue_script('omniturea');
    wp_enqueue_script('videotracking');
	wp_enqueue_script('lazyloadxt');
	wp_enqueue_script('lazyloadxt-bg');

    wp_enqueue_script('nativoad');
    wp_enqueue_script('interstitial_rs');
}
add_action( 'wp_enqueue_scripts', 'foundationpress_scripts' );