Last active
September 1, 2016 11:15
-
-
Save nickdavis/372dd6cdd3030eaab98386ca7b92784b to your computer and use it in GitHub Desktop.
Don't do backstretch on the Kickstart Pro homepage (not tested, assumes you're coding a custom solution instead)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'wp_enqueue_scripts', 'kickstart_enqueue_backstretch_scripts' ); | |
| // Enqueue Backstretch script and prepare images for loading | |
| function kickstart_enqueue_backstretch_scripts() { | |
| // Don't do any backstretching on the homepage (CUSTOM) | |
| if ( is_front_page() ) { | |
| return; | |
| } | |
| // Load scripts only if custom background or featured image is being used | |
| // If we're on a page with no featured image or background image, leave | |
| if ( is_page() && ! has_post_thumbnail() && ! get_background_image() ) { | |
| return; | |
| } | |
| // If we're not on a page and there's no background image, leave | |
| if ( ! is_page() && ! get_background_image() ) { | |
| return; | |
| } | |
| wp_enqueue_script( 'kickstart-backstretch', get_stylesheet_directory_uri() . '/js/backstretch.js', array( 'jquery' ), '2.0.4' ); | |
| wp_enqueue_script( 'kickstart-backstretch-set', get_stylesheet_directory_uri() . '/js/backstretch-set.js' , array( 'kickstart-backstretch' ), CHILD_THEME_VERSION ); | |
| wp_localize_script( 'kickstart-backstretch-set', 'KickstartBackStretchImg', array( 'src' => str_replace( 'http:', '', get_background_image() ) ) ); | |
| if ( is_home() ) { | |
| wp_localize_script( 'kickstart-backstretch-set', 'KickstartBackStretchImg', array( 'src' => str_replace( 'http:', '', get_background_image() ) ) ); | |
| } | |
| else if ( has_post_thumbnail() ) { | |
| $image = array( 'src' => has_post_thumbnail() ? genesis_get_image( array( 'format' => 'url' ) ) : '' ); | |
| wp_localize_script( 'kickstart-backstretch-set', 'KickstartBackStretchImg', $image ); | |
| } | |
| else { | |
| wp_localize_script( 'milton-backstretch-set', 'KickstartBackStretchImg', array( 'src' => str_replace( 'http:', '', get_background_image() ) ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment