Skip to content

Commit

Permalink
Merge pull request #89 from Squazz/1.6
Browse files Browse the repository at this point in the history
Only loading JS & CSS when needed
  • Loading branch information
JLeuze committed Jan 30, 2015
2 parents 35e4914 + 39b3204 commit 311322c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
10 changes: 9 additions & 1 deletion includes/meteor-slideshow.php
Expand Up @@ -26,7 +26,9 @@

<?php // Check for slides

if ( $meteor_loop->have_posts() ) : ?>
if ( $meteor_loop->have_posts() ) :
// Enqueue slideshow style
wp_enqueue_style( 'meteor-slides' ); ?>

<div id="meteor-slideshow<?php echo $slideshow; ?>" class="meteor-slides <?php

Expand Down Expand Up @@ -73,6 +75,12 @@
<?php // Check for multiple slides

if ( $meteor_loop->post_count > 1 ) : ?>

<?php // Enqueue slideshow scripts
wp_enqueue_script( 'jquery-cycle' );
wp_enqueue_script( 'jquery-metadata' );
wp_enqueue_script( 'jquery-touchwipe' );
wp_enqueue_script( 'meteorslides-script' ); ?>

<?php // Adds Previous/Next and Paged navigation

Expand Down
20 changes: 10 additions & 10 deletions meteor-slides-plugin.php
Expand Up @@ -221,19 +221,19 @@ function meteorslides_css() {

if ( file_exists( get_stylesheet_directory()."/meteor-slides.css" ) ) {

wp_enqueue_style( 'meteor-slides', get_stylesheet_directory_uri() . '/meteor-slides.css', array(), '1.0' );
wp_register_style( 'meteor-slides', get_stylesheet_directory_uri() . '/meteor-slides.css', array(), '1.0' );

}

elseif ( file_exists( get_template_directory()."/meteor-slides.css" ) ) {

wp_enqueue_style( 'meteor-slides', get_template_directory_uri() . '/meteor-slides.css', array(), '1.0' );
wp_register_style( 'meteor-slides', get_template_directory_uri() . '/meteor-slides.css', array(), '1.0' );

}

else {

wp_enqueue_style( 'meteor-slides', plugins_url('/css/meteor-slides.css', __FILE__), array(), '1.0' );
wp_register_style( 'meteor-slides', plugins_url('/css/meteor-slides.css', __FILE__), array(), '1.0' );

}

Expand All @@ -249,26 +249,26 @@ function meteorslides_javascript() {

if( !is_admin() ) {

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-cycle', plugins_url( '/js/jquery.cycle.all.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'jquery-metadata', plugins_url( '/js/jquery.metadata.v2.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'jquery-touchwipe', plugins_url( '/js/jquery.touchwipe.1.1.1.js', __FILE__ ), array( 'jquery' ) );
//wp_register_script( 'jquery' );
wp_register_script( 'jquery-cycle', plugins_url( '/js/jquery.cycle.all.js', __FILE__ ), array( 'jquery' ), 1, true );
wp_register_script( 'jquery-metadata', plugins_url( '/js/jquery.metadata.v2.js', __FILE__ ), array( 'jquery' ), 1, true );
wp_register_script( 'jquery-touchwipe', plugins_url( '/js/jquery.touchwipe.1.1.1.js', __FILE__ ), array( 'jquery' ), 1, true );

if ( file_exists( get_stylesheet_directory()."/slideshow.js" ) ) {

wp_enqueue_script( 'meteorslides-script', get_stylesheet_directory_uri() . '/slideshow.js', array('jquery', 'jquery-cycle') );
wp_register_script( 'meteorslides-script', get_stylesheet_directory_uri() . '/slideshow.js', array('jquery', 'jquery-cycle'), 1, true );

}

elseif ( file_exists( get_template_directory()."/slideshow.js" ) ) {

wp_enqueue_script( 'meteorslides-script', get_template_directory_uri() . '/slideshow.js', array('jquery', 'jquery-cycle') );
wp_register_script( 'meteorslides-script', get_template_directory_uri() . '/slideshow.js', array('jquery', 'jquery-cycle'), 1, true );

}

else {

wp_enqueue_script( 'meteorslides-script', plugins_url( '/js/slideshow.js', __FILE__ ), array( 'jquery', 'jquery-cycle' ) );
wp_register_script( 'meteorslides-script', plugins_url( '/js/slideshow.js', __FILE__ ), array( 'jquery', 'jquery-cycle' ), 1, true );

}

Expand Down

0 comments on commit 311322c

Please sign in to comment.