wordpress - wp_enqueue_scripts jquery to footer.php -


i have script in footer.php , add footer.php using wp_enqueue_scripts.

<script type="text/javascript"> jquery(window).load(function(){  <?php if ( is_home() ) {      if ( option::get('featured_posts_show') == 'on' ) {          ?>if ( jquery('#slider li').length > 0 ) {             jquery('#slider').flexslider({                 controlnav: false,                 directionnav: false,                 animationloop: true,                 animation: '<?php echo option::get('slideshow_effect') == 'slide' ? 'slide' : 'fade'; ?>',                 usecss: true,                 smoothheight: false,                 touch: false,                 slideshow: <?php echo option::get('slideshow_auto') == 'on' ? 'true' : 'false'; ?>,                 <?php if ( option::get('slideshow_auto') == 'on' ) echo 'slideshowspeed: ' . option::get('slideshow_speed') . ','; ?>                 pauseonaction: true,                 animationspeed: 600,                 start: function(slider){                     jquery('#slider_nav .item').click(function(){                         var id = getpostidclass(this);                         if ( id <= 0 ) return;                          var index = slider.slides.index( slider.slides.filter('.' + id) );                          slider.direction = (index > slider.currentslide) ? 'next' : 'prev';                         slider.flexanimate(index, slider.pauseonaction);                     });                 },                 before: function(slider){                     var id = getpostidclass( slider.slides.eq(slider.animatingto) );                     if ( id <= 0 ) return;                      jquery('#slider_nav .item').removeclass('current');                     jquery('#slider_nav .item.' + id).addclass('current');                      if ( jquery('#slider_nav .row').length > 1 ) {                         var navslider = jquery('#slider_nav').data('flexslider'),                             currpage = navslider.slides.index( navslider.slides.find('.item.' + id).parent('.row') );                         navslider.direction = (currpage > navslider.currentslide) ? 'next' : 'prev';                         navslider.flexanimate(currpage, navslider.pauseonaction);                     }                 }             });              jquery('#slider_nav .item').wrapinchunks('<div class="row" />', 4);              jquery('#slider_nav').flexslider({                 selector: '.tiles > .row',                 direction: 'vertical',                 controlnav: true,                 directionnav: false,                 animationloop: false,                 animation: 'slide',                 usecss: true,                 smoothheight: false,                 touch: false,                 slideshow: false,                 pauseonaction: true,                 animationspeed: 600             });         }<?php      }      if ( option::get('carousel_posts_show') == 'on' ) {          ?>if ( jquery('#carousel .item').length > 0 ) {             jquery('#carousel .item').wrapinchunks('<div class="row" />', 3);             jquery('#carousel .row').append('<div class="clear" />');              if ( jquery('#carousel .item').length > 3 ) {                 jquery('#carousel_wrap').append('<div id="carousel_nav"><div class="prev">prev</div><div class="next">next</div></div>');                  jquery('#carousel .row').each(function(){                     var max = math.max.apply(null, jquery('h4.title',this).map(function(){return jquery(this).height()}).get());                     jquery('h4.title', this).css('min-height', max);                 });                 jquery('#carousel').height(jquery('#carousel .row').height());                  jquery('#carousel').serialscroll({                     axis: 'y',                     cycle: false,                     constant: false,                     force: true,                     items: '.row',                     prev: '#carousel_nav .prev',                     next: '#carousel_nav .next',                     onbefore: function(e,elem,$pane,$items,pos){                         $pane.height(jquery(elem).height());                     }                 });             }         }<?php      }  } ?>  }); </script> 

i haven't managed yet add it, because of php part inside script. don't know how separate javascript php , add right way footer.php.

anyone?

remove php code script , put script in 1 file suppose name custom-script.js

then add js wp_enqueue_script in theme functions.php file

function my_scripts_method() {     if ( is_home() ) {         if ( option::get('featured_posts_show') == 'on' ) {         wp_enqueue_script('custom-script',get_stylesheet_directory_uri() . '/js/custom_script.js',  array( 'jquery' ), '', true );         }     } }  add_action( 'wp_enqueue_scripts', 'my_scripts_method' ); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -