• 1.
    <?php
  • 2.
     
  • 3.
    add_shortcode('prima_slider', 'prima_slider_shortcode');
  • 4.
    function prima_slider_shortcode( $atts ) {
  • 5.
    	global $prima_shortcodes_scripts, $prima_shortcodes_js;
  • 6.
    	if ( !is_array($prima_shortcodes_js) ) $prima_shortcodes_js = array();
  • 7.
    	extract(shortcode_atts(array(
  • 8.
    		'id' 	=> '',
  • 9.
    		'width' 	=> null,
  • 10.
    		'height' 	=> null,
  • 11.
    		'animation' => 'fade',
  • 12.
    		'speed' 	=> '4000',
  • 13.
    		'duration' 	=> '600',
  • 14.
    		'direction' => 'no',
  • 15.
    		'control' 	=> 'no',
  • 16.
    	), $atts));
  • 17.
    	$box_id = rand(1000, 9999);
  • 18.
    	$content = prima_get_gallery( array( 
  • 19.
    		'post_id' => $id,
  • 20.
    		'width' => $width,
  • 21.
    		'height' => $height,
  • 22.
    		'link_to_meta' => 'link_url',
  • 23.
    		'before' => '<li>',
  • 24.
    		'after' => '</li>',
  • 25.
    		'before_container' => '<div id="slider-container-'.$box_id.'" class="flexslider-container clearfix"><div id="slider-'.$box_id.'" class="flexslider clearfix"><ul class="slides">',
  • 26.
    		'after_container' => '</ul></div></div>'
  • 27.
    	) );
  • 28.
    	$prima_shortcodes_scripts .= 'jQuery(window).load(function() {';
  • 29.
    	$prima_shortcodes_scripts .= 'jQuery("#slider-'.$box_id.'").flexslider({';
  • 30.
    	$prima_shortcodes_scripts .= 'pauseOnHover: "true",';
  • 31.
    	if ( $animation == 'slide' ) {
  • 32.
    		$prima_shortcodes_scripts .= 'animation: "slide",';
  • 33.
    		$prima_shortcodes_scripts .= 'controlsContainer: "#slider-container-'.$box_id.'",';
  • 34.
    	}
  • 35.
    	elseif ( $animation == 'fade' ) {
  • 36.
    		$prima_shortcodes_scripts .= 'animation: "fade",';
  • 37.
    	}
  • 38.
    	$prima_shortcodes_scripts .= 'slideshowSpeed: '.$speed.',';
  • 39.
    	$prima_shortcodes_scripts .= 'animationDuration: '.$duration.',';
  • 40.
    	$direction = $direction == 'yes' ? 'true' : 'false';
  • 41.
    	$prima_shortcodes_scripts .= 'directionNav: '.$direction.',';
  • 42.
    	$control = $control == 'yes' ? 'true' : 'false';
  • 43.
    	$prima_shortcodes_scripts .= 'controlNav: '.$control.',';
  • 44.
    	$prima_shortcodes_scripts .= 'slideDirection: "horizontal",';
  • 45.
    	$prima_shortcodes_scripts .= 'slideshow: true';
  • 46.
    	$prima_shortcodes_scripts .= '});';
  • 47.
    	$prima_shortcodes_scripts .= '});';
  • 48.
    	$prima_shortcodes_scripts .= "\n";
  • 49.
    	return $content;
  • 50.
    }
  • 51.
     
<?php add_shortcode('prima_slider', 'prima_slider_shortcode'); function prima_slider_shortcode( $atts ) { global $prima_shortcodes_scripts, $prima_shortcodes_js; if ( !is_array($prima_shortcodes_js) ) $prima_shortcodes_js = array(); extract(shortcode_atts(array( 'id' => '', 'width' => null, 'height' => null, 'animation' => 'fade', 'speed' => '4000', 'duration' => '600', 'direction' => 'no', 'control' => 'no', ), $atts)); $box_id = rand(1000, 9999); $content = prima_get_gallery( array( 'post_id' => $id, 'width' => $width, 'height' => $height, 'link_to_meta' => 'link_url', 'before' => '<li>', 'after' => '</li>', 'before_container' => '<div id="slider-container-'.$box_id.'" class="flexslider-container clearfix"><div id="slider-'.$box_id.'" class="flexslider clearfix"><ul class="slides">', 'after_container' => '</ul></div></div>' ) ); $prima_shortcodes_scripts .= 'jQuery(window).load(function() {'; $prima_shortcodes_scripts .= 'jQuery("#slider-'.$box_id.'").flexslider({'; $prima_shortcodes_scripts .= 'pauseOnHover: "true",'; if ( $animation == 'slide' ) { $prima_shortcodes_scripts .= 'animation: "slide",'; $prima_shortcodes_scripts .= 'controlsContainer: "#slider-container-'.$box_id.'",'; } elseif ( $animation == 'fade' ) { $prima_shortcodes_scripts .= 'animation: "fade",'; } $prima_shortcodes_scripts .= 'slideshowSpeed: '.$speed.','; $prima_shortcodes_scripts .= 'animationDuration: '.$duration.','; $direction = $direction == 'yes' ? 'true' : 'false'; $prima_shortcodes_scripts .= 'directionNav: '.$direction.','; $control = $control == 'yes' ? 'true' : 'false'; $prima_shortcodes_scripts .= 'controlNav: '.$control.','; $prima_shortcodes_scripts .= 'slideDirection: "horizontal",'; $prima_shortcodes_scripts .= 'slideshow: true'; $prima_shortcodes_scripts .= '});'; $prima_shortcodes_scripts .= '});'; $prima_shortcodes_scripts .= "\n"; return $content; }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter