brasofilo

Shortcode for Spoiled Slideshow

Apr 22nd, 2012
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3.  * WordPress shortcode for Spoiled Slideshow
  4.  * http://spoiledmilk.dk/demos/spoiled-slideshow/
  5.  * usage: [sspoiled imgs="http://aa.com/aa.jpg,http://bb.com/bb.jpg,http://cc.com/cc.jpg" width="600" height="300"]
  6.  * by brasofilo
  7.  */
  8.  
  9. function se49804_shortcode ($atts, $content = null) {
  10.     $imgs = explode( ',', $atts['imgs'] );
  11.     $width = $atts['width'];
  12.     $height = $atts['height'];
  13.     $imgList = '';
  14.     foreach($imgs as $img) {
  15.         $imgList .= "\t\t" . '<img src="'.$img.'" width="'.$width.'" height="'.$height.'" alt="" class="slide current" />' . "\r\n";
  16.     }
  17.     $html  = <<<HTML
  18.         <!--slideshow-->
  19.         <div class="slideshow">
  20.        
  21.             <div class="slides">
  22. $imgList
  23.             </div>
  24.            
  25.             <div class="controls">
  26.            
  27.                 <a href="#" class="previous">
  28.                     <span class="arrow">&larr;</span> Prev
  29.                 </a>
  30.                
  31.                 <div class="state"></div>
  32.                
  33.                 <a href="#" class="next">
  34.                     <span class="arrow">&rarr;</span> Next
  35.                 </a>
  36.                
  37.             </div>
  38.            
  39.         </div>
  40.         <!--end slideshow-->
  41. HTML;
  42.     return $html;
  43. }
  44. add_shortcode('sspoiled', 'se49804_shortcode');
RAW Paste Data