RtThemesSupport

RTTheme 13 rt_shortcodes.php

Mar 25th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 36.24 KB | None | 0 0
  1. <?php
  2. /* RT-Theme Shortcodes */
  3.  
  4.  
  5. /*using shortcodes in widgets*/
  6.  
  7. add_filter( 'widget_text', 'shortcode_unautop');
  8. add_filter( 'widget_text', 'do_shortcode');
  9.  
  10. //shortcodes
  11.  
  12. /*
  13. * ------------------------------------------------- *
  14. *       Fix shortcodes
  15. * ------------------------------------------------- *
  16. */
  17.  
  18. function fixshortcode($content){
  19.  
  20.      //fix
  21.  
  22.     //remove invalid p
  23.     $content = preg_replace('#^<\/p>|<p>$#', '', trim($content));
  24.    
  25.     //fix line shortcode
  26.      $content = preg_replace('#<p>\n<div class="line top #', '<div class="line top ', trim($content));
  27.  
  28.      $content = preg_replace('#<p>\n<div class="line"></div>\n</p>#', '<div class="line"></div>', trim($content));
  29.      $content = preg_replace('#<p>\n<div class="line">#', '<div class="line">', trim($content));
  30.    
  31.     return $content;
  32. }
  33.  
  34.  
  35.  
  36.  
  37. /*
  38. * ------------------------------------------------- *
  39. *       twitter feeds      
  40. * ------------------------------------------------- *      
  41. */
  42.  
  43. //Social Media Holder
  44. function rt_twitter( $atts, $content = null ) {
  45.     //[twitter username="" count=""]
  46.     $username = $atts['username'];
  47.     $count = $atts['count'];
  48.     $rt_twitter = do_shortcode(strip_tags($content));
  49.     $rt_twitter.='<img src="'.get_template_directory_uri().'/images/social_media/twitter_32.png" class="title_icon" /><h4><a href="http://twitter.com/'.$username.'">'.__('Twitter Feeds','rt_theme').'</a></h4><div class="tweets"><script type="text/javascript">jQuery(document).ready(function(){if (jQuery(\'.tweets\').length>0){jQuery(\'.tweets\').tweet({count: '.$count.', username:"'.$username.'",loading_text: "..."});}});</script></div>';
  50.     return $rt_twitter;
  51. }
  52. add_shortcode('twitter', 'rt_twitter');
  53.  
  54.  
  55. /*
  56. * ------------------------------------------------- *
  57. *       flickr feeds       
  58. * ------------------------------------------------- *      
  59. */
  60.  
  61. //Social Media Holder
  62. function rt_flickr( $atts, $content = null ) {
  63.     //[flickr userid="" count=""]
  64.     $userid = $atts['userid'];
  65.     $count = $atts['count'];
  66.     $rt_flickr .= do_shortcode(strip_tags($content));
  67.     $rt_flickr.='<h4><a href="http://www.flickr.com/photos/'.$userid.'/"><img src="'.get_template_directory_uri().'/images/social_media/flickr_32.png" class="title_icon" />'.__('Flickr','rt_theme').'</a></h4><ul id="flickr" class="thumbs"></ul><script type="text/javascript">jQuery(document).ready(function(){if (jQuery(\'#flickr\').length>0){jQuery(\'#flickr\').jflickrfeed({limit: '.$count.',qstrings: {id: \''.$userid.'\' }, itemTemplate: \'<li><span class="border"><a href="{{image_b}}"><img src="{{image_s}}" alt="{{title}}" /></a></span></li>\'}); }});</script>';
  68.     return $rt_flickr;
  69. }
  70. add_shortcode('flickr', 'rt_flickr');
  71.  
  72.  
  73. /*
  74. * ------------------------------------------------- *
  75. *       Latest Posts       
  76. * ------------------------------------------------- *      
  77. */
  78.  
  79. function rt_posts( $atts, $content = null ) {
  80.     //[posts count="" categories=""]
  81.     $categories = $atts['categories'];
  82.     $count = $atts['count']; if(!$count) $count = 5;
  83.    
  84.    
  85.     $rt_posts .= do_shortcode(strip_tags($content));    
  86.     $postargs=array('post_type'=>'post','showposts'=>$count,'cat'=>$categories);    
  87.     $post_query = new WP_Query($postargs);
  88.    
  89.     $rt_posts .= '<ul class="popular_posts">';
  90.    
  91.     if ($post_query->have_posts()) : while ($post_query->have_posts()) : $post_query->the_post();
  92.                        
  93.         $post_title=get_the_title();
  94.         $link=get_permalink();
  95.         $date=get_the_time('d M Y');
  96.                        
  97.         $rt_posts .='<li>';
  98.        
  99.         if ( has_post_thumbnail() ) :
  100.             $rt_posts .='<span class="border alignleft thumb">'.get_the_post_thumbnail($post->ID,'sidebar-thumb').'</span>';
  101.         endif;
  102.        
  103.         $rt_posts .='<span class="date">'.$date.'</span><br />';
  104.         $rt_posts .='<a href="'.$link.'">'.$post_title.'</a>';
  105.         $rt_posts .='<div class="clear"></div></li>';
  106.                      
  107.     endwhile;endif;wp_reset_query();
  108.     $rt_posts .= '</ul>';
  109.      
  110.     return $rt_posts;
  111. }
  112.  
  113. add_shortcode('posts', 'rt_posts');
  114.  
  115.  
  116.  
  117. /*
  118. * ------------------------------------------------- *
  119. *       social media       
  120. * ------------------------------------------------- *      
  121. */
  122.  
  123. //Social Media Holder
  124. function rt_social_media( $atts, $content = null ) {
  125.     //[social_media]
  126.     $rt_photo_gallery='<div class="social_media_icons">';
  127.     $rt_photo_gallery .= do_shortcode(strip_tags($content));
  128.     $rt_photo_gallery.='<div class="clear"></div></div>';
  129.     return $rt_photo_gallery;
  130. }
  131.  
  132. //Social Media Icons
  133. function rt_social_media_links( $atts, $content = null ) {
  134.     //[media name="" url="" alt_text=""]
  135.    
  136.      //alt text
  137.      if($atts["alt_text"]):
  138.      $alt_text = $atts["alt_text"];
  139.      else:
  140.      $alt_text = $atts["name"];
  141.      endif;
  142.      
  143.     //clear p tag
  144.     $content = preg_replace('#^<\/p>|<p>$#', '', trim($content));    
  145.     return '<a href="'.trim($atts["url"]).'" class="j_ttip" title="'.trim($alt_text).'"><img src="'.get_template_directory_uri().'/images/social_media/'.trim($atts["name"]).'_16.png" alt="'.trim($atts["name"]).'" /></a>';
  146. }
  147.  
  148. add_shortcode('social_media', 'rt_social_media');
  149. add_shortcode('media', 'rt_social_media_links');
  150.  
  151.  
  152. /*
  153. * ------------------------------------------------- *
  154. *       logos      
  155. * ------------------------------------------------- *      
  156. */
  157.  
  158. //logo Holder
  159. function rt_logos( $atts, $content = null ) {
  160.     //[logos]
  161.     $rt_logos='<ul class="logos">';
  162.     $rt_logos .= do_shortcode(strip_tags($content));
  163.     $rt_logos.='</ul>';
  164.     return $rt_logos;
  165. }
  166.  
  167. //logos
  168. function rt_logo_links( $atts, $content = null ) {
  169.     //[logo image="" url="" alt_text=""]
  170.  
  171.     //clear p tag
  172.     $content = preg_replace('#^<\/p>|<p>$#', '', trim($content));
  173.      
  174.      //alt text
  175.      $alt_text = $atts["alt_text"];
  176.      $image_link=$atts["url"];
  177.      $image=$atts["image"];
  178.      
  179.      $logo="<li>";
  180.      
  181.      if($image_link) $logo .= '<a href="'.trim($atts["url"]).'" class="j_ttip" title="'.trim($alt_text).'" >';    
  182.      $logo .= '<img src="'.trim($atts["image"]).'" alt="'.trim($atts["alt_text"]).'" />';
  183.      if($image_link) $logo .= '</a>';
  184.  
  185.      return $logo;
  186. }
  187.  
  188. add_shortcode('logos', 'rt_logos');
  189. add_shortcode('logo', 'rt_logo_links');
  190.  
  191. /*
  192. * ------------------------------------------------- *
  193. *       highlights
  194. * ------------------------------------------------- *      
  195. */
  196. function rt_highlights( $atts, $content = null ) {
  197.     // [hlight red - yellow - black][/hlight]
  198.    
  199.     //class
  200.     if (isset($atts[0]) && trim($atts[0])){
  201.         $class=trim($atts[0]);     
  202.     }else{
  203.         $class="htext";
  204.     }
  205.  
  206.     //fix shortcode
  207.     $content = fixshortcode($content);  
  208.     $content = '<span class="'.$class.'">'.trim($content).'</span>';
  209.      
  210.     return $content;
  211. }
  212. add_shortcode('hlight', 'rt_highlights');
  213.  
  214.  
  215. /*
  216. * ------------------------------------------------- *
  217. *       pull qoutes    
  218. * ------------------------------------------------- *      
  219. */
  220. function rt_pull_quotes( $atts, $content = null ) {
  221.     // [pullquote align=""][/pullquote]
  222.    
  223.     //class
  224.     if (isset($atts["align"]) && trim($atts["align"])){
  225.         $align='align'.trim($atts["align"]);       
  226.     }
  227.  
  228.     //fix shortcode
  229.     $content = fixshortcode($content);  
  230.     $content = '<blockquote class="border pullquote '.$align.'">'.trim($content).'</blockquote>';
  231.      
  232.     return $content;
  233. }
  234. add_shortcode('pullquote', 'rt_pull_quotes');
  235.  
  236.  
  237. /*
  238. * ------------------------------------------------- *
  239. *       dropcaps       
  240. * ------------------------------------------------- *      
  241. */
  242. function rt_dropcaps( $atts, $content = null ) {
  243.     // [dropcap style=""][/dropcap]
  244.    
  245.     //class
  246.     if (isset($atts["style"]) && trim($atts["style"])){
  247.         $style=trim($atts["style"]);       
  248.     }
  249.  
  250.     //fix shortcode
  251.     $content = fixshortcode($content);  
  252.     $content = '<span class="dropcap '.$style.' cufon">'.trim($content).'</span>';
  253.      
  254.     return $content;
  255. }
  256. add_shortcode('dropcap', 'rt_dropcaps');
  257. /*
  258. * ------------------------------------------------- *
  259. *       lists      
  260. * ------------------------------------------------- *      
  261. */
  262. function rt_lined_list( $atts, $content = null ) {
  263.     // [list lined - red_arrow - silver_arrow -  blue_arrow - check - star][/list]
  264.    
  265.     //class
  266.     if (isset($atts[0]) && trim($atts[0])){
  267.         $class=trim($atts[0]);     
  268.     }
  269.  
  270.     //fix shortcode
  271.     $content = fixshortcode($content);  
  272.     $content = preg_replace('#<ul>#', '<ul class="'.$class.'">', trim($content));
  273.      
  274.     return $content;
  275. }
  276.  
  277. add_shortcode('list', 'rt_lined_list');
  278.  
  279.  
  280. /*
  281. * ------------------------------------------------- *
  282. *       PHOTO GALLERY      
  283. * ------------------------------------------------- *      
  284. */
  285. function rt_photo_gallery( $atts, $content = null ) {
  286.     //[photo_gallery]
  287.     $rt_photo_gallery='<div class="photo_gallery"><ul>';
  288.     $rt_photo_gallery .= do_shortcode(strip_tags($content));
  289.     $rt_photo_gallery.='</ul><div class="clear"></div></div>';
  290.     return $rt_photo_gallery;
  291. }
  292.  
  293. function rt_photo_gallery_lines( $atts, $content = null ) {
  294.     //[image url="" thumb_width="" thumb_height="" lightbox="" tooltip=""]
  295.  
  296.     //defaults
  297.     extract(shortcode_atts(array(  
  298.         "thumb_width"           => '130',
  299.         "thumb_height"          => '130',
  300.         "lightbox"=> "",
  301.         "title"=>"",
  302.         "tooltip"=>"",
  303.         "url"=>"",
  304.         "photo_link" =>""
  305.     ), $atts));
  306.    
  307.     $rt_photo_gallery_lines = "";
  308.  
  309.     //lightbox = default is true
  310.     if($lightbox=="" || $lightbox=="yes") $lightbox='rel="prettyPhoto[rt_theme_thumb]"';
  311.  
  312.     //tooltip - default is true
  313.     $title ='title="'.$title.'"';
  314.    
  315.  
  316.     $photo=trim($content);
  317.    
  318.     //link - default is image
  319.     if (!$photo_link) $photo_link=trim($content);
  320.  
  321.                      
  322.     // Resize Image
  323.     $imgURL     = ($photo);
  324.     $crop   = true;
  325.     if($imgURL) $image_thumb = @vt_resize( '', $imgURL, $thumb_width, $thumb_height, ''.$crop.'' );
  326.                    
  327.     $rt_photo_gallery_lines.='<li><span class="border"><a href="'.$photo_link.' " '.$title.'  '.$lightbox.' class="imgeffect plus"><img src="'.$image_thumb["url"].'" '.$tooltip.' /></a></span></li>';
  328.    
  329.     return $rt_photo_gallery_lines;
  330. }  
  331.  
  332. add_shortcode('photo_gallery', 'rt_photo_gallery');
  333. add_shortcode('image', 'rt_photo_gallery_lines');
  334.  
  335.  
  336.                        
  337. /*
  338. * ------------------------------------------------- *
  339. *   Sidebar Testimonial
  340. * ------------------------------------------------- *      
  341. */
  342. function rt_testimonial( $atts, $content = null ) {
  343. //[testimonial client_name=""][/testimonial]
  344.  
  345.     //clear p and br tags    
  346.     $content = preg_replace('#^<\/p>|<p>$#', '', trim($content));
  347.     $content = preg_replace('#^<p>|<\/p>$#', '', trim($content));
  348.     $content = preg_replace('#^<br />$#', '', trim($content));
  349.  
  350.  
  351.     //fix shortcode
  352.     $content = fixshortcode($content);    
  353.    
  354.     $rt_testimonial = '<blockquote class="testimonial"><p>';
  355.     $rt_testimonial .= $content;
  356.     $rt_testimonial .= '</p></blockquote>';
  357.    
  358.     if($atts["client_name"]):
  359.     $rt_testimonial .= '<div class="testimonial_name">'.$atts["client_name"].'</div>';
  360.     endif;
  361.    
  362.     return $rt_testimonial;
  363. }
  364.  
  365. add_shortcode('testimonial', 'rt_testimonial');
  366.  
  367. /*
  368. * ------------------------------------------------- *
  369. *   Auto Thumbnails & Lightboxes   
  370. * ------------------------------------------------- *      
  371. */
  372. function rt_auto_thumb( $atts, $content = null ) {
  373.     //[auto_thumb width="" height="" link="" lightbox="" align="" title="" alt="" iframe="" tooltip="" frame=""]
  374.     $rt_auto_thumb  = "";
  375.     $border_open = "";
  376.     $border_close = "";
  377.  
  378.     //clear p and br tags
  379.     $content = preg_replace('#^<\/p>|<p>$#', '', trim($content));
  380.     $content = preg_replace('#^<p>|<\/p>$#', '', trim($content));
  381.     $content = preg_replace('#^<br />$#', '', trim($content)); 
  382.      
  383.      
  384.     //lightbox
  385.     $lightbox=trim($atts["lightbox"]);
  386.     if($lightbox!="no") $lightbox="yes";
  387.     if($lightbox=="yes") $lightbox='rel="prettyPhoto[rt_theme_thumb]"';
  388.    
  389.     //link
  390.     $link= isset ($atts["link"]) ? trim($atts["link"]) : "";   
  391.        
  392.     //if it's not a video
  393.     if($link=="") $link=$content;
  394.    
  395.     /* icon */
  396.     if (preg_match("/(png|jpg|gif)/",  trim($link) )) {
  397.         $icon="plus";
  398.     } else {
  399.         $icon="play";
  400.     }
  401.  
  402.    
  403.     //other attiributes
  404.     $width=isset ($atts["width"]) ? trim($atts["width"]): "";  
  405.     $height=isset ($atts["height"]) ? trim($atts["height"]) : "";  
  406.  
  407.     $align=isset ($atts["align"]) ? trim($atts["align"]) : "";
  408.     if(!$align) $align='left';
  409.    
  410.     $alt=isset ($atts["alt"]) ?  trim($atts["alt"]) : "";
  411.     $title=isset ($atts["title"]) ?  trim($atts["title"]) : "";
  412.  
  413.      //frame
  414.     $frame=isset($atts["frame"]) ? trim($atts["frame"]) : "";
  415.     if($frame!="no" && !empty($frame)) $frame="yes";
  416.     if($frame=="yes"){
  417.        
  418.       if($align=="left"):  $border_open='<span class="border alignleft">';  $border_close='</span>'; endif;
  419.       if($align=="right"):  $border_open='<span class="border alignright">';  $border_close='</span>'; endif;
  420.       if($align=="center"):  $border_open='<span class="aligncenter"><span class="border">';  $border_close='</span></span>'; endif;
  421.      
  422.        $align="";
  423.      } 
  424.    
  425.     //tooltip
  426.     $tooltip=isset($atts["tooltip"]) ? trim($atts["tooltip"]) : "";
  427.     if($tooltip): $tooltip ='title="'.$title.'"'; $title ='title=""';
  428.     else: $title ='title="'.$title.'"';
  429.     endif;
  430.    
  431.     //iframe
  432.     $iframe = isset ($atts["iframe"]) ? trim($atts["iframe"]) : "";
  433.     if ($iframe && $iframe!="false") $iframe= "?iframe=true&width=100%&height=100%";
  434.     if (preg_match("/(mov|avi|swf|vimeo|youtube|screenr)/",  trim($link))): $iframe= ""; else: if($iframe && trim($atts["link"])) $icon="";endif;
  435.    
  436.     //fix the width for center align
  437.  
  438.     //result
  439.  
  440.     if (trim($content)):
  441.     // Resize Image
  442.     $imgURL     = ($content);
  443.     $crop   = true;
  444.     if($imgURL) $image_thumb = @vt_resize( '', $imgURL, $width, $height, ''.$crop.'' );
  445.    
  446.     $rt_auto_thumb.='<a href="'.$link.''.$iframe.' " '.$title.'  '.$lightbox.' class="imgeffect '.$icon.'"><img src="'. $image_thumb["url"] .'" alt="'.$alt.'"   class="align'.$align.'" /></a>';  
  447.     else:
  448.     $rt_auto_thumb.='<a href="'.$link.''.$iframe.' " title="'.trim($atts["title"]).'"  '.$lightbox.' >'.trim($atts["title"]).'</a>';
  449.     endif;
  450.     $rt_auto_thumb = $border_open . $rt_auto_thumb . $border_close;
  451.  
  452.    
  453.     return $rt_auto_thumb;
  454. }
  455.  
  456. add_shortcode('auto_thumb', 'rt_auto_thumb');
  457.  
  458.  
  459. /*
  460. * ------------------------------------------------- *
  461. *
  462. *
  463. *       COLUMNS
  464. *      
  465. * ------------------------------------------------- *      
  466. */
  467.  
  468.  
  469.  
  470. /*
  471. * ------------------------------------------------- *
  472. *       two column
  473. * ------------------------------------------------- *
  474. */
  475.  
  476. function rt_shortcode_two_column( $atts, $content = null ) {
  477.     //left side
  478.     $class = "";
  479.     $clear = "";
  480.     if (isset($atts[0]) && trim($atts[0])){
  481.         $class=trim($atts[0]);
  482.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  483.     }
  484.    
  485.    
  486.     $content  = apply_filters('the_content',$content);
  487.  
  488.     //fix shortcode
  489.     $content = fixshortcode($content);
  490.  
  491.     return '<div class="box two '.$class.'">' . $content . '</div>'.$clear;
  492.    
  493. }
  494.  
  495. add_shortcode('two_column', 'rt_shortcode_two_column');
  496.  
  497. /*
  498. * ------------------------------------------------- *
  499. *       three column
  500. * ------------------------------------------------- *
  501. */
  502.  
  503. function rt_shortcode_three_column( $atts, $content = null ) {
  504.     //left side
  505.     $class = "";
  506.     $clear = "";
  507.     if (isset($atts[0]) && trim($atts[0])){
  508.         $class=trim($atts[0]);
  509.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  510.     }
  511.  
  512.    
  513.     $content  = apply_filters('the_content',$content);
  514.  
  515.     //fix shortcode
  516.     $content = fixshortcode($content);  
  517.  
  518.     return '<div class="box three '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  519.    
  520. }
  521.  
  522. add_shortcode('three_column', 'rt_shortcode_three_column');
  523.  
  524.  
  525.  
  526. /*
  527. * ------------------------------------------------- *
  528. *       four column
  529. * ------------------------------------------------- *
  530. */
  531.  
  532. function rt_shortcode_four_column( $atts, $content = null ) {
  533.     //left side
  534.     $class = "";
  535.     $clear = "";   
  536.     if (isset($atts[0]) && trim($atts[0])){
  537.         $class=trim($atts[0]);
  538.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  539.     }
  540.    
  541.     $content  = apply_filters('the_content',$content);
  542.  
  543.     //fix shortcode
  544.     $content = fixshortcode($content);
  545.    
  546.     return '<div class="box four '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  547.    
  548. }
  549.  
  550. add_shortcode('four_column', 'rt_shortcode_four_column');
  551.  
  552.  
  553. /*
  554. * ------------------------------------------------- *
  555. *       five column
  556. * ------------------------------------------------- *
  557. */
  558.  
  559. function rt_shortcode_five_column( $atts, $content = null ) {
  560.     //left side
  561.     $class = "";
  562.     $clear = "";   
  563.     if (isset($atts[0]) && trim($atts[0])){
  564.         $class=trim($atts[0]);
  565.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  566.     }
  567.    
  568.     $content  = apply_filters('the_content',$content);
  569.  
  570.     //fix shortcode
  571.     $content = fixshortcode($content);
  572.    
  573.     return '<div class="box five '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  574.    
  575. }
  576.  
  577. add_shortcode('five_column', 'rt_shortcode_five_column');
  578.  
  579.  
  580. /*
  581. * ------------------------------------------------- *
  582. *       2:3 column
  583. * ------------------------------------------------- *
  584. */
  585.  
  586. function rt_shortcode_2_3_column( $atts, $content = null ) {
  587.     //left side
  588.     $class = "";
  589.     $clear = "";   
  590.     if (isset($atts[0]) && trim($atts[0])){
  591.         $class=trim($atts[0]);
  592.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  593.     }
  594.    
  595.     $content  = apply_filters('the_content',$content);
  596.  
  597.     //fix shortcode
  598.     $content = fixshortcode($content);
  599.    
  600.     return '<div class="box two-three '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  601.    
  602. }
  603.  
  604. add_shortcode('twothird_column', 'rt_shortcode_2_3_column');
  605.  
  606. /*
  607. * ------------------------------------------------- *
  608. *       3:4 column
  609. * ------------------------------------------------- *
  610. */
  611.  
  612. function rt_shortcode_3_4_column( $atts, $content = null ) {
  613.     //left side
  614.     $class = "";
  615.     $clear = "";   
  616.     if (isset($atts[0]) && trim($atts[0])){
  617.         $class=trim($atts[0]);
  618.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  619.     }
  620.    
  621.     $content  = apply_filters('the_content',$content);
  622.  
  623.     //fix shortcode
  624.     $content = fixshortcode($content);
  625.    
  626.     return '<div class="box three-four '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  627.    
  628. }
  629.  
  630. add_shortcode('threefourth_column', 'rt_shortcode_3_4_column');
  631.  
  632. /*
  633. * ------------------------------------------------- *
  634. *       4:5 column
  635. * ------------------------------------------------- *
  636. */
  637.  
  638. function rt_shortcode_4_5_column( $atts, $content = null ) {
  639.     //left side
  640.     $class = "";
  641.     $clear = "";   
  642.     if (isset($atts[0]) && trim($atts[0])){
  643.         $class=trim($atts[0]);
  644.         if (trim($atts[0])=="last") $clear='<div class="clear"></div>';
  645.     }
  646.    
  647.     $content  = apply_filters('the_content',$content);
  648.  
  649.     //fix shortcode
  650.     $content = fixshortcode($content);
  651.    
  652.     return '<div class="box four-five '.$class.'">' . do_shortcode($content) . '</div>'.$clear;
  653.    
  654. }
  655.  
  656. add_shortcode('fourfith_column', 'rt_shortcode_4_5_column');
  657.  
  658.  
  659. /*
  660. * ------------------------------------------------- *
  661. *       Lines
  662. * ------------------------------------------------- *
  663. */
  664.  
  665. function rt_shortcode_lines( $atts, $content = null ) {
  666.     //[line toplink="true"]
  667.      global $which_theme;
  668.     if (isset($atts["toplink"]) && trim($atts["toplink"])){
  669.         $line='<div class="line"><span class="top">['.trim($atts["toplink"]).']</span></div>';
  670.     }else{
  671.         $line = '<div class="line"></div>';
  672.     }
  673.    
  674.     return $line;
  675.    
  676. }
  677.  
  678. add_shortcode('line', 'rt_shortcode_lines');
  679.  
  680.  
  681.  
  682.  
  683.  
  684. /*
  685. * ------------------------------------------------- *
  686. *       Contact Form Pages
  687. * ------------------------------------------------- *
  688. */
  689. function rt_shortcode_contact_form( $atts, $content = null ) {
  690.  
  691. if(isset($atts['title'])) $contact_form= '<h3>'.$atts['title'].'</h3>';
  692. if(isset($atts['text'])) $contact_form.= '<p><i>'.$atts['text'].'</i></p>';
  693.  
  694. if(isset($atts['email'])){
  695.  
  696. $contact_form.= "".    
  697.     '<!-- contact form -->'.
  698.     '<div id="result"></div>'.
  699.     '<div id="contact_form">'.
  700.     '   <form class="showtextback" action="'.get_template_directory_uri().'/contact_form.php" name="contact_form" id="validate_form" method="post"><fieldset>'.
  701.     '       <ul>'.
  702.     '           <li><label for="name"></label><input id="name" type="text" title=" " name="name" value="'.__('Your Name: (*)','rt_theme').'" class="required" /> </li>'.
  703.     '           <li><label for="email"></label><input id="email" type="text" title="'.__('Please enter a valid email address','rt_theme').'" name="email" value="'.__('Your Email: (*)','rt_theme').'" class="required email"    /> </li>'.
  704.     '           <li><label for="phone"></label><input id="phone" type="text" title=" " name="phone" value="'.__('Phone Number','rt_theme').'"  /> </li>'.
  705.     '           <li><label for="company_name"></label><input id="company_name" title=" " type="text" name="company_name" value="'.__('Company Name','rt_theme').'" /> </li>'.
  706.     '           <li><label for="company_url"></label><input id="company_url" title="'.__('Please enter a valid URL.','rt_theme').'" type="text" name="company_url" value="'.__('Company URL','rt_theme').'" /> </li>'.
  707.     '           <li><label for="message"></label><textarea  id="message" title=" " name="message" rows="8" cols="40"    class="required">'.__('Your message (*)','rt_theme').'</textarea></li>'.
  708.     '           <li>'.
  709.     '           <input type="hidden" name="your_email" value="'.trim($atts['email']).'" />'.
  710.     '           <input type="hidden" name="your_web_site_name" value="'.get_bloginfo('name').'" />'.
  711.  
  712.     '           <input type="hidden" name="text_1" value="'.__('Thanks','rt_theme').'">'.  
  713.     '           <input type="hidden" name="text_2" value="'.__('Your email was successfully sent. We will be in touch soon.','rt_theme').'">'. 
  714.     '           <input type="hidden" name="text_3" value="'.__('There was an error submitting the form.','rt_theme').'">'. 
  715.     '           <input type="hidden" name="text_4" value="'.__('Please enter a valid email address!','rt_theme').'">'. 
  716.     '           <input type="submit" class="button" value="'.__('Send','rt_theme').'"  /><span class="loading"></span></li>'.
  717.     '       </ul>'.
  718.     '   </fieldset></form>'.
  719.     '</div>'.
  720.     '<!-- /contact form -->';
  721.  
  722.    
  723.    
  724. }else{
  725.     $contact_form="ERROR: This shortcode is not contains an email attribute!";
  726. }
  727.  
  728. return $contact_form;
  729. }
  730.  
  731. add_shortcode('contact_form', 'rt_shortcode_contact_form');
  732.  
  733.  
  734.  
  735. /*
  736. * ------------------------------------------------- *
  737. *       Contact Form Footer
  738. * ------------------------------------------------- *
  739. */
  740. function rt_shortcode_contact_form_footer( $atts, $content = null ) {
  741.  
  742. $contact_form = "";
  743.  
  744. if(isset($atts['text'])) $contact_form.= '<p><i>'.$atts['text'].'</i></p>';
  745.  
  746. if(isset($atts['email'])){
  747.  
  748. $contact_form.= "".    
  749.     '<!-- contact form -->'.
  750.     '<div id="result_footer"></div>'.
  751.     '<div id="contact_form_footer">'.
  752.     '   <form class="showtextback" action="'.get_bloginfo('template_directory').'/contact_form_footer.php"   id="validate_form_footer" method="post"><fieldset>'.
  753.     '       <ul>'.
  754.     '           <li><label for="name"></label><input id="name" type="text" title="*" name="name" value="'.__('Your name: (*)','rt_theme').'" class="required" /> </li>'.
  755.     '           <li><label for="email"></label><input id="email" type="text" title="*" name="email" value="'.__('Your Email: (*)','rt_theme').'" class="required email"  /> </li>'.
  756.      '          <li><label for="message"></label><textarea  id="message" title="*" name="message" rows="8" cols="40" class="required">'.__('Your message: (*)','rt_theme').'</textarea></li>'.
  757.     '           <li>'.
  758.     '           <input type="hidden" name="your_email" value="'.trim($atts['email']).'" />'.
  759.     '           <input type="hidden" name="your_web_site_name" value="'.get_bloginfo('name').'" />'.
  760.  
  761.     '           <input type="hidden" name="text_1" value="'.__('Thanks','rt_theme').'">'.  
  762.     '           <input type="hidden" name="text_2" value="'.__('Your email was successfully sent. We will be in touch soon.','rt_theme').'">'. 
  763.     '           <input type="hidden" name="text_3" value="'.__('There was an error submitting the form.','rt_theme').'">'. 
  764.     '           <input type="hidden" name="text_4" value="'.__('Please enter a valid email address!','rt_theme').'">'.
  765.    
  766.     '           <input type="submit" class="submitbutton" value="'.__('Send','rt_theme').'"  /><span class="loading"></span></li>'.
  767.     '       </ul>'.
  768.     '   </fieldset></form>'.
  769.     '</div>'.
  770.     '<!-- /contact form -->';
  771. }else{
  772.     $contact_form="ERROR: This shortcode is not contains an email attribute!";
  773. }
  774.  
  775. return $contact_form;
  776. }
  777.  
  778. add_shortcode('contact_form_footer', 'rt_shortcode_contact_form_footer');
  779.  
  780.  
  781. /*
  782. * ------------------------------------------------- *
  783. *       Image Slider
  784. * ------------------------------------------------- *
  785. */
  786.        
  787.  
  788.  
  789. function rt_shortcode_slider( $atts, $content = null ) {
  790.     //[slider][/slider]
  791.  
  792.     //fix content
  793.     $content = preg_replace('#<br \/>#', "",trim($content));
  794.     $content = preg_replace('#<p>#', "",trim($content));
  795.     $content = preg_replace('#<\/p>#', "",trim($content));
  796.    
  797.     $content = wpautop(do_shortcode($content));
  798.     $content = fixshortcode($content);
  799.    
  800.     return '<div class="photo_gallery_cycle"><span class="aligncenter"><span class="border"><ul>' . trim($content) . '</ul></span></span><div class="pager"></div><div class="clear"></div></div>';
  801. }
  802.  
  803. function rt_shortcode_slider_slides( $atts, $content = null ) {
  804.  
  805.     //[slide image_width="" image_height="" link="" alt_text="" auto_resize=""]
  806.  
  807.  
  808.     //fix content
  809.     $content = preg_replace('#<br \/>#', "",trim($content));
  810.     $content = preg_replace('#<p>#', "",trim($content));
  811.     $content = preg_replace('#<\/p>#', "",trim($content)); 
  812.    
  813.     //dimensions
  814.     $image_width=trim($atts["image_width"]);
  815.     $image_height=trim($atts["image_height"]);
  816.     $link=trim($atts["link"]);
  817.     $alt_text=trim($atts["alt_text"]);
  818.     $auto_resize=trim($atts["auto_resize"]);
  819.  
  820.     if($link){
  821.         $link1='<a href="'.$link.'">';
  822.         $link2='</a>';
  823.     }
  824.    
  825.    
  826.     $slide='<li>'; 
  827.    
  828.     if($auto_resize=="true"){
  829.         // Resize Image
  830.         $imgURL     = ($content);
  831.         $crop   = true;
  832.         if($imgURL) $image_thumb = @vt_resize( '', $imgURL, $image_width, $image_height, ''.$crop.'' );    
  833.         $slide.=$link1.'<img src="'.$image_thumb["url"].'" width="'.$image_width.'" height="'.$image_height.'" alt="'.$alt_text.'" />'.$link2;
  834.     }else{
  835.         $slide.=$link1.'<img src="'.$content.'" width="'.$image_width.'" height="'.$image_height.'" alt="'.$alt_text.'" />'.$link2;
  836.     }
  837.     $slide.='</li>';
  838.    
  839.     return $slide;
  840. }
  841.  
  842.  
  843.  
  844.  
  845.  
  846. add_shortcode('slider', 'rt_shortcode_slider');
  847. add_shortcode('slide', 'rt_shortcode_slider_slides');
  848.  
  849.  
  850.  
  851.  
  852. /*
  853. * ------------------------------------------------- *
  854. *       Image Slider width thumbnail scroller
  855. * ------------------------------------------------- *
  856. */
  857.        
  858.  
  859.  
  860. function rt_shortcode_thubm_slider( $atts, $content = null ) {
  861.     //[slider][/slider]
  862.  
  863.     //fix content
  864.     $content = preg_replace('#<br \/>#', "",trim($content));
  865.     $content = preg_replace('#<p>#', "",trim($content));
  866.     $content = preg_replace('#<\/p>#', "",trim($content));
  867.    
  868.     $content = wpautop(do_shortcode($content));
  869.     $content = fixshortcode($content);
  870.    
  871.     return '<div class="scrollable_border"><div id="image_wrap" class="aligncenter"><img src="images/pixel.gif" class="aligncenter" /></div><div class="clear"></div><a class="prev browse _left"></a><div class="scrollable"><div class="items big_image">' . trim($content) . '</div></div><a class="next browse _right"></a></div>';
  872. }
  873.  
  874. function rt_shortcode_thubm_slider_slides( $atts, $content = null ) {
  875.  
  876.     //[thumb_slide link=""]
  877.  
  878.  
  879.     //fix content
  880.     $content = preg_replace('#<br \/>#', "",trim($content));
  881.     $content = preg_replace('#<p>#', "",trim($content));
  882.     $content = preg_replace('#<\/p>#', "",trim($content)); 
  883.    
  884.     //dimensions
  885.     $image_width=80;
  886.     $image_height=80;
  887.  
  888.    
  889.     $slide='<div>';
  890.    
  891.     //max image width
  892.     if(is_page_template( 'full_width_page.php' ))://full width page
  893.     $max_width = 920;
  894.     else:
  895.     $max_width = 660;
  896.     endif;
  897.  
  898.         // Resize Image
  899.         $imgURL     = ($content);
  900.         $crop   = true;
  901.         if($imgURL) {
  902.             $image_thumb = @vt_resize( '', $imgURL, $image_width, $image_height, ''.$crop.'' );
  903.             $image_thumb_2 = @vt_resize( '', $imgURL, $max_width, 0, ''.$crop.'' );        
  904.         }
  905.        
  906.     $slide.='<img src="'.$image_thumb["url"].'" alt="'.$image_thumb_2["url"].'" />';
  907.  
  908.     $slide.='</div>';
  909.    
  910.     return $slide;
  911. }
  912.  
  913.  
  914.  
  915. add_shortcode('thumb_slider', 'rt_shortcode_thubm_slider');
  916. add_shortcode('thumb_slide', 'rt_shortcode_thubm_slider_slides');
  917.  
  918.  
  919.  
  920. /*
  921. * ------------------------------------------------- *
  922. *       buttons
  923. * ------------------------------------------------- *
  924. */
  925.  
  926. function rt_shortcode_buttons( $atts, $content = null ) {
  927.     //[button size="" link="" title="" align=""][/button]
  928.    
  929.     //parameters
  930.    
  931.     $size=trim($atts["size"]);
  932.     if(!$size || $size=="big")  $size="banner_button";
  933.     else $size="small_button";
  934.    
  935.     $link=trim($atts["link"]);
  936.     if(!$link)  $link="#";
  937.    
  938.     $align='align'.trim($atts["align"]);
  939.    
  940.     $title=trim($atts["title"]);
  941.  
  942.     //fix shortcode
  943.     $content = fixshortcode($content);
  944.     $content = preg_replace('#<br \/>#', "",trim($content));
  945.     $content = preg_replace('#<p>#', "",trim($content));
  946.     $content = preg_replace('#<\/p>#', "",trim($content));
  947.  
  948.  
  949.     return '<a href="'.$link.'" title="'.$title.'" class="'.$size.' '.$align.'">' . wpautop(do_shortcode($content)) . '</a>';
  950. }
  951.  
  952. add_shortcode('button', 'rt_shortcode_buttons');
  953.  
  954.  
  955.  
  956. /*
  957. * ------------------------------------------------- *
  958. *       Tabular Content
  959. * ------------------------------------------------- *
  960. */
  961.  
  962. function rt_shortcode_tabs( $atts, $content = null ) {
  963.     //[tabs tab1="" tab2="" tab3=""][/tabs]
  964.  
  965.     //fix shortcode
  966.     $content  = apply_filters('the_content',$content); 
  967.     $content = fixshortcode($content);
  968.     $content = preg_replace('#<br \/>#', "",trim($content));
  969.     $content = preg_replace('#<p>#', "",trim($content));
  970.     $content = preg_replace('#<\/p>#', "",trim($content));
  971.    
  972.     $tabs ="";
  973.     $tab_name ="";
  974.     for($i=1;$i<10;$i++){
  975.         $tab_name =  isset($atts['tab'.$i]) ? $atts['tab'.$i] : "";
  976.         if($tab_name){
  977.             $tabs .=   '<li><a href="#">'.$tab_name.'</a></li>';
  978.         }
  979.     }
  980.  
  981.     return '<div class="taps_wrap"><ul class="tabs">'.$tabs.'</ul>'.apply_filters('the_content',$content).'</div>';
  982. }
  983.  
  984. function rt_shortcode_tab( $atts, $content = null ) {
  985.     //[tab][/tab]
  986.  
  987.    
  988.     //fix shortcode
  989.     $content  = apply_filters('the_content',$content); 
  990.     $content = fixshortcode($content);
  991.     $content = preg_replace('#<br \/>#', "",trim($content));
  992.     $content = preg_replace('#<p>#', "",trim($content));
  993.     $content = preg_replace('#<\/p>#', "",trim($content));
  994.  
  995.     return ' <div class="pane">' . $content . '</div>';
  996. }
  997.  
  998. add_shortcode('tabs', 'rt_shortcode_tabs');
  999. add_shortcode('tab', 'rt_shortcode_tab');
  1000.  
  1001. /*
  1002. * ------------------------------------------------- *
  1003. *       Accordions
  1004. * ------------------------------------------------- *
  1005. */
  1006.  
  1007. function rt_shortcode_accordion( $atts, $content = null ) {
  1008.     //[accordion align=""][/accordion]
  1009.         extract(shortcode_atts(array(
  1010.         'align' => '',
  1011.     ), $atts));
  1012.    
  1013.     //align
  1014.     //$align = isset($align) ? $atts['align'] : "";
  1015.     if($align) $align =  'small _'.$align;
  1016.    
  1017.     //fix shortcode
  1018.     $content  = apply_filters('the_content',$content); 
  1019.     $content = fixshortcode($content);
  1020.     $content = preg_replace('#<br \/>#', "",trim($content));
  1021.     $content = preg_replace('#<p>#', "",trim($content));
  1022.     $content = preg_replace('#<\/p>#', "",trim($content));
  1023.    
  1024.     return '<div class="accordion '.$align.'">'.apply_filters('the_content',$content).'</div>';
  1025. }
  1026.  
  1027. function rt_shortcode_accordion_panel( $atts, $content = null ) {
  1028.     //[pane title=""][/pane]
  1029.    
  1030.     $pane_title=$atts['title'];
  1031.    
  1032.     //fix shortcode
  1033.     $content  = apply_filters('the_content',$content); 
  1034.     $content = fixshortcode($content);
  1035.     $content = preg_replace('#<br \/>#', "",trim($content));
  1036.     $content = preg_replace('#<p>#', "",trim($content));
  1037.     $content = preg_replace('#<\/p>#', "",trim($content));
  1038.  
  1039.     return '<h3>'.$pane_title.'</h3><div class="pane">' . $content . '<div class="clear"></div></div>';
  1040. }
  1041.  
  1042. add_shortcode('accordion', 'rt_shortcode_accordion');
  1043. add_shortcode('pane', 'rt_shortcode_accordion_panel');
  1044.  
  1045.  
  1046. /*
  1047. * ------------------------------------------------- *
  1048. *       frames
  1049. * ------------------------------------------------- *
  1050. */
  1051.  
  1052. function rt_shortcode_frame( $atts, $content = null ) {
  1053.     //[frame align=""][/frame]
  1054.  
  1055.     //align
  1056.     $align = $atts['align'];
  1057.  
  1058.    
  1059.     //fix shortcode
  1060.     $content = wpautop(do_shortcode($content));
  1061.     $content = fixshortcode($content);
  1062.     $content = preg_replace('#<br \/>#', "",trim($content));
  1063.     $content = preg_replace('#<p>#', "",trim($content));
  1064.     $content = preg_replace('#<\/p>#', "",trim($content));
  1065.    
  1066.     if($align) $align =  'small align'.$align;
  1067.     if(!$align) $align =  'fullborder';
  1068.    
  1069.     return $before.'<span class="border '.$align.'">'.$content.'</span>'.$end;
  1070. }
  1071.  
  1072. add_shortcode('frame', 'rt_shortcode_frame');
  1073.  
  1074.  
  1075.  
  1076. /*
  1077. * ------------------------------------------------- *
  1078. *       Info Box
  1079. * ------------------------------------------------- *
  1080. */
  1081.  
  1082. function rt_shortcode_infobox( $atts, $content = null ) {
  1083.     //[infobox title="" align=""][/infobox]
  1084.  
  1085.     //align
  1086.     $align = $atts['align'];
  1087.     if($align) $align =  'small _'.$align;
  1088.    
  1089.     //Title
  1090.     $title=$atts['title'];
  1091.    
  1092.    
  1093.     //fix shortcode
  1094.     $content  = apply_filters('the_content',$content); 
  1095.     $content = fixshortcode($content);
  1096.     $content = preg_replace('#<br \/>#', "",trim($content));
  1097.     $content = preg_replace('#<p>#', "",trim($content));
  1098.     $content = preg_replace('#<\/p>#', "",trim($content));
  1099.    
  1100.     return '<div class="info_box '.$align.'"><div class="info_box_title"><h3>'.$title.'</h3></div><div class="info_box_content">'.$content.'<div class="clear"></div></div></div>';
  1101. }
  1102.  
  1103. add_shortcode('infobox', 'rt_shortcode_infobox');
  1104.  
  1105.  
  1106.  
  1107. /*
  1108. * ------------------------------------------------- *
  1109. *       Info Table
  1110. * ------------------------------------------------- *
  1111. */
  1112.  
  1113. function rt_shortcode_info_table( $atts, $content = null ) {
  1114.     //[infotable][/infotable]
  1115.  
  1116.     //fix shortcode
  1117.     $content  = apply_filters('the_content',$content); 
  1118.     $content = fixshortcode($content);
  1119.     $content = preg_replace('#<br \/>#', "",trim($content));
  1120.     $content = preg_replace('#<p>#', "",trim($content));
  1121.     $content = preg_replace('#<\/p>#', "",trim($content));
  1122.  
  1123.     return '<table class="product_data">' . $content . '</table>';
  1124. }
  1125.  
  1126. function rt_shortcode_info_table_rows( $atts, $content = null ) {
  1127.     //[row label="" value=""]
  1128.  
  1129.     //parameters
  1130.     $label=trim($atts["label"]);
  1131.     $value=trim($atts["value"]);
  1132.    
  1133.     //fix shortcode
  1134.     $content = fixshortcode($content);
  1135.     $content = preg_replace('#<br \/>#', "",trim($content));
  1136.     $content = preg_replace('#<p>#', "",trim($content));
  1137.     $content = preg_replace('#<\/p>#', "",trim($content));
  1138.  
  1139.     return '<tr><td class="left">' . $label . '</td><td>:</td><td>' . $value . '</td></tr>';
  1140. }
  1141.  
  1142. add_shortcode('infotable', 'rt_shortcode_info_table');
  1143. add_shortcode('row', 'rt_shortcode_info_table_rows');
  1144.  
  1145.  
  1146.  
  1147. /*
  1148. * ------------------------------------------------- *
  1149. *       show shortcode :)
  1150. * ------------------------------------------------- *
  1151. */
  1152.  
  1153. function rt_shortcode_show_shortcode( $atts, $content = null ) {
  1154.  
  1155.     //convert html [] spacial chars  
  1156.  
  1157.     //fix shortcode
  1158.     $content = fixshortcode($content);
  1159.     $content = preg_replace('#<br \/>#', "",trim($content));
  1160.     $content = preg_replace('#<p>#', "",trim($content));
  1161.     $content = preg_replace('#<\/p>#', "",trim($content));
  1162.     $content = preg_replace('#\[\/braket_close\]#', "[/show_shortcode]",trim($content));
  1163.  
  1164.    
  1165.     return '<code>' . htmlspecialchars($content) . '</code>';
  1166. }
  1167.  
  1168. add_shortcode('show_shortcode', 'rt_shortcode_show_shortcode');
  1169.  
  1170.  
  1171.  
  1172. /*
  1173. * ------------------------------------------------- *
  1174. *       RT-Theme editor shortcodes button
  1175. * ------------------------------------------------- *
  1176. */
  1177.  
  1178.  
  1179. /// add the shorcode button
  1180. function rt_theme_shortcode_button() {
  1181.     if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
  1182.         return;
  1183.  
  1184.     // Add only in Rich Editor mode
  1185.     if ( get_user_option('rich_editing') == 'true') {
  1186.         add_filter("mce_external_plugins", "rt_theme_add_shortcode_tinymce_plugin");
  1187.         add_filter('mce_buttons', 'rt_theme_register_shortcode_button');
  1188.     }
  1189. }
  1190.  
  1191. function rt_theme_register_shortcode_button($buttons) {
  1192.     array_push($buttons, "|", "rt_themeshortcode");
  1193.     return $buttons;
  1194. }
  1195.  
  1196. // load the js file
  1197. function rt_theme_add_shortcode_tinymce_plugin($plugin_array) {
  1198.    $plugin_array['rt_themeshortcode'] = get_template_directory_uri() . '/rttheme_options/shortcodes.js';
  1199.    return $plugin_array;
  1200. }
  1201.  
  1202. //refresh the editor
  1203. function refresh_editor($ver) {
  1204.   $ver += 3;
  1205.   return $ver;
  1206. }
  1207.  
  1208. // init process for button control
  1209. add_filter( 'tiny_mce_version', 'refresh_editor');
  1210. add_action( 'init', 'rt_theme_shortcode_button' );
  1211.  
  1212.  
  1213. ?>
Advertisement
Add Comment
Please, Sign In to add comment