ID; $key = 'bliss_slideshow'; $slideshow = get_post_meta( $post_id, $key, true ); if($slideshow && $slideshow != '' && $slideshow != 'none'){ $trim = strlen('uses_slideshow_'); $id = substr($slideshow, $trim, 1 ); return (int) esc_attr($id); }else{ return false; } } function bliss_display_slideshow(){ $id = bliss_get_slideshow_id();// this function is defined in metaboxes.php if(!$id || $id == ''){ return ''; } // retrieve slide data from db. // see http://jquery.malsup.com/cycle2/api/ // for information about adding captions etc. // TODO: triggers via prev and next. Use the glyphicons to implement: // data-cycle-next=".next, .cycle-slideshow" data-cycle-prev=".prev" // but will require adding prev and next elements to the slider $string = '
'; $number_of_slides = 0; for($i = 1; $i <= 5; $i++){ $slide = of_get_option('slideshow_'.$id.'_slide_'.$i); if($slide){ $string .= sprintf('
slide
', esc_url($slide) ); $number_of_slides++; } } $string .= '
'; if($number_of_slides == 0){ // may occur if user has previously set, then removed the slideshow return false; } return $string; } // this is the function you actually call, to display a slideshow on the page. function bliss_slideshow(){ $slider = bliss_display_slideshow(); if($slider && $slider != ''){ printf('
%s
', $slider); $cycle_path = get_template_directory_uri() . '/js/jquery.cycle2.min.js'; wp_enqueue_script('cycle2', $cycle_path, array('jquery'), '2.1.4',true); // provide "swipe" functionality to slideshow for mobile/touchscreen users $swipe_path = get_template_directory_uri() . '/js/jquery.cycle2.swipe.min.js'; wp_enqueue_script('cycleswipe', $swipe_path, array('cycle2'), 'v20140128', true); // TODO: implement slideshow options, let the user select the animation type. // then only enqueue this next script if they're using the "tile" animation effect. $tile_path = get_template_directory_uri() . '/js/jquery.cycle2.tile.min.js'; wp_enqueue_script('cycletile', $tile_path, array('cycle2'), '20140128', true); } } ?>