jQuery(document).ready(function($) { "; _sf_js_init_foundation_code(); echo " }); //end no conflict wrapper "; } add_action('wp_footer', '_sf_js_init_foundation'); endif; //! _sf_js_init_foundation /** *Infinite Scroll * Method from: http://wptheming.com/2012/03/infinite-scroll-to-wordpress-theme/ */ //first test to see if we need infinite scroll: if ( (get_theme_mod( '_sf_inf-scroll' ) == '' ) && (! get_theme_mod( '_sf_masonry' ) == '' ) ) : if (! function_exists('_sf_scripts_infScroll') ) : function _sf_scripts_infScroll() { wp_register_script( 'infinite_scroll', get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'), false, false ); wp_enqueue_script('infinite_scroll'); } add_action( 'wp_enqueue_scripts', '_sf_scripts_infScroll' ); endif; //! _sf_scripts exists_infScroll if (! function_exists('_sf_js_init_infScroll_code') ) : function _sf_js_init_infScroll_code() { ?> var infinite_scroll = { loading: { img: "/images/ajax-loader.gif", msgText: "", finishedMsg: "" }, "nextSelector":"#nav-below .nav-previous a", "navSelector":"#nav-below", "itemSelector":"article", "contentSelector":"#content" }; jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll ); '; _sf_js_init_infScroll_code(); echo ' '; } add_action('wp_footer', '_sf_js_init_infScroll', 10); endif; //! _sf_js_init_infScroll endif; //we need infscroll /** *masonry */ //first check if masonry is being used, if so do all the things we need, if not fuck it. if ( get_theme_mod( '_sf_masonry' ) == '' ) : if (! function_exists('_sf_scripts_masonry') ) : function _sf_scripts_masonry() { wp_enqueue_script('masonry', get_template_directory_uri().'/js/jquery.masonry.min.js'); } add_action( 'wp_enqueue_scripts', '_sf_scripts_masonry' ); endif; //! _sf_scripts_masonry exists if (! function_exists('_sf_js_init_masonry_code') ) : function _sf_js_init_masonry_code() { //get the theme_mod that tells us how many wide we want to go. If it isn't set return 4 so we don't get an error and it goes 4 wide, because I said so and you didn't. $howmany = get_theme_mod('masonry_how_many', 4); echo " $('#masonry-loop').masonry({ itemSelector: '.masonry-entry', // set columnWidth a fraction of the container width columnWidth: function( containerWidth ) { "; echo " return containerWidth / ".$howmany."; } }); "; } endif; // if ! _sf_js_init_masonry_code exists if (! function_exists('_sf_js_init_masonry') ) : function _sf_js_init_masonry() { echo " "; } if ( ! is_singular() && (get_theme_mod( '_sf_inf-scroll' ) == '' ) && (get_theme_mod( '_sf_masonry' ) !== '' ) ) { add_action('wp_footer', '_sf_js_init_masonry'); } endif; //! _sf_js_init_masonry endif; //do we need masonry? // /** * Ajax Menus * method from: http://wptheming.com/2011/12/ajax-themes/ */ if (! function_exists('_sf_scripts_ajaxMenus') ) : function _sf_scripts_ajaxMenus() { if ( get_theme_mod( '_sf_ajax' ) == '' ) : wp_deregister_script('historyjs'); wp_register_script( 'historyjs', get_template_directory_uri(). '/js/jquery.history.js', array( 'jquery' ), '1.7.1' ); wp_enqueue_script( 'historyjs' ); endif; // get_theme_mod( '_sf_ajax' ) == '' } add_action( 'wp_enqueue_scripts', '_sf_scripts_ajaxMenus' ); endif; //! _sf_scripts exists if (! function_exists('_sf_js_init_ajaxMenus') ) : function _sf_js_init_ajaxMenus() { echo' '; } add_action('wp_footer', '_sf_js_init_ajaxMenus'); endif; //! _sf_js_init_ajaxMenus /** * Backstretch */ //get urls of background images. Doing this first to test if they have a value in the big if statement that is about to happen. $body_img_url = get_theme_mod('body_bg_img'); $header_img_url = get_theme_mod('header_bg_img'); $content_img_url = get_theme_mod('content_bg_img'); if ( //if we're using full screen background image, and one is set (which btw may be the default one.) get_theme_mod( 'body_bg_choice' ) == '' //or we're using a background image for the header and and one is set || ! get_theme_mod( 'header_bg_choice' ) == '' && ! $header_img_url == '' //or we're using a background image for the content area and and one is set || ! get_theme_mod( 'content_bg_choice' ) == '' && ! $content_img_url == '' ) : if (! function_exists('_sf_scripts_backstretch') ) : function _sf_scripts_backstretch() { wp_enqueue_script('backstretch', get_template_directory_uri().'/js/jquery.backstretch.min.js'); } add_action( 'wp_enqueue_scripts', '_sf_scripts_backstretch' ); endif; //! _sf_scripts exists if (! function_exists('_sf_js_init_backstretch') ) : function _sf_js_init_backstretch($use = '') { if ( get_theme_mod('body_bg_img') == '' ) { $body_img_url = get_template_directory_uri().'/images/bg.jpg'; } else { $body_img_url = get_theme_mod('body_bg_img'); } $header_img_url = get_theme_mod('header_bg_img'); $content_img_url = get_theme_mod('content_bg_img'); //$use = 'reinit' in the ajax menu callback, so we don't get style tags in the middle of that. if (! $use == 'reinit') { echo ''; } } add_action('wp_footer', '_sf_js_init_backstretch'); endif; //! _sf_js_init_backstretch endif; //the big one. if (! function_exists('_sf_style') ) : function _sf_style() { wp_enqueue_style( '_sf-style', get_stylesheet_uri() ); } add_action( 'wp_enqueue_scripts', '_sf_style' ); endif; //! _sf_style exists endif; // ! is_admin /** * Other scripts */ //extra description/ insturctions in themes.php if (! function_exists('_sf_extraDesc') ): function _sf_extraDesc($hook) { if( 'themes.php' != $hook ) return; wp_enqueue_script( 'extra-desc', get_template_directory_uri().'/js/extra-desc.js' ); } add_action( 'admin_enqueue_scripts', '_sf_extraDesc' ); endif; //! _sf_extraDesc exists