RtThemesSupport

rt17 add target to product attachment

Nov 1st, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.64 KB | None | 0 0
  1. <?php
  2. #
  3. # rt-theme product detail page
  4. #
  5.  
  6. //flush rewrite rules
  7. add_action('init', 'flush_rewrite_rules');
  8.  
  9. //taxonomy
  10. $taxonomy = 'product_categories';
  11.  
  12. //page link
  13. $link_page = get_permalink(get_option('rttheme_product_list'));
  14.  
  15. //category link
  16. $terms = get_the_terms($post->ID, $taxonomy);
  17. $i=0;
  18. if($terms){
  19.     foreach ($terms as $taxindex => $taxitem) {
  20.     if($i==0){
  21.         $link_cat=get_term_link($taxitem->slug,$taxonomy);
  22.         $term_slug = $taxitem->slug;
  23.         $term_id = $taxitem->term_id;
  24.         }
  25.     $i++;
  26.     }
  27. }
  28.  
  29. get_header();
  30. ?>
  31.  
  32.  
  33. <?php
  34. #
  35. # page layout - sidebar
  36. #
  37. $sidebar    =   (get_post_meta($post->ID, THEMESLUG.'custom_sidebar_position', true)) ? get_post_meta($post->ID, THEMESLUG.'custom_sidebar_position', true) : get_option(THEMESLUG."_sidebar_position_product");
  38.  
  39. #
  40. # content width
  41. #
  42. $content_width = ($sidebar=="full") ? 960 : 710;
  43.  
  44. #
  45. #   call sub page header
  46. #
  47. get_template_part( 'sub_page_header', 'sub_page_header_file' );
  48.  
  49. #
  50. #   call the sub content holder 1st part
  51. #
  52. sub_page_layout("subheader",$sidebar);
  53. ?>
  54.  
  55.     <?php
  56.     if (have_posts()) : while (have_posts()) : the_post();
  57.  
  58.  
  59.  
  60.  
  61.         // featured images
  62.         $rt_gallery_images          = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_images", true );
  63.         $rt_gallery_image_titles    = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_titles", true );
  64.         $rt_gallery_image_descs     = get_post_meta( $post->ID, THEMESLUG . "rt_gallery_image_descs", true );
  65.    
  66.         //values
  67.         $rt_attached_documents      = get_post_meta($post->ID, THEMESLUG.'attached_documents', true);
  68.         $content                    = apply_filters('the_content',(get_the_content()));
  69.         $title                      = get_the_title();
  70.         $permalink                  = get_permalink();
  71.         $order_button               = get_post_meta($post->ID, THEMESLUG.'order_button', true);
  72.         $order_button_text          = get_post_meta($post->ID, THEMESLUG.'order_button_text', true);
  73.         $order_button_link          = get_post_meta($post->ID, THEMESLUG.'order_button_link', true);
  74.         $related_products           = get_post_meta($post->ID, THEMESLUG.'related_products[]', true);
  75.         $short_desc                 = get_post_meta($post->ID, THEMESLUG.'short_description', true);
  76.         $password_protected         = ( post_password_required($post) ) ? true : false ;// Password Protected
  77.    
  78.  
  79.         //next and previous links
  80.         if(get_option(THEMESLUG.'_hide_product_navigation')){
  81.             $prev                   = mod_get_adjacent_post(true,true,'', $taxonomy,'date');
  82.             $next                   = mod_get_adjacent_post(true,false,'', $taxonomy,'date');
  83.             $prev_post_link_url     = ($prev) ? get_permalink( $prev->ID ) : "";
  84.             $next_post_link_url     = ($next) ? get_permalink( $next->ID ) : "";
  85.             $next_post_link         = ($next_post_link_url) ? '<a href="'.$next_post_link_url.'" title="" class="p_next"><span>'.__( 'Next →', 'rt_theme').'</span></a>' : false ;
  86.             $prev_post_link         = ($prev_post_link_url) ? '<a href="'.$prev_post_link_url.'" title="" class="p_prev"><span>'.__( '← Previous', 'rt_theme').'</span></a>': false ;              
  87.             $add_class              = ($prev_post_link==false) ? "single" : ""; // if previous link is empty add class to fix white border
  88.             $before_sidebar         = ($next_post_link || $prev_post_link) ? '<div class="post-navigations  margin-b20 '.$add_class.'">'.$prev_post_link. '' .$next_post_link.'</div>' : "";
  89.         }
  90.  
  91.         //free tabs count
  92.         $tab_count=3;
  93.         for($i=0; $i<$tab_count+1; $i++){
  94.             if (trim(get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true)))  $tabbed_page="yes";
  95.         }
  96.     ?>
  97.  
  98.     <!-- product title  -->  
  99.     <div class="box one box-shadow margin-b30">  
  100.         <div class="head_text nomargin">
  101.             <div class="arrow"></div><!-- arrow -->
  102.             <h2 class="product"><?php the_title(); ?></h2>
  103.         </div>
  104.     </div>  
  105.     <!-- / product title  -->
  106.  
  107.     <!-- product images -->
  108.  
  109.         <?php if (is_array($rt_gallery_images)  && !$password_protected ):
  110.                
  111.         //is crop active       
  112.         $crop = (get_option(THEMESLUG.'_single_product_image_crop')) ? true : false ;
  113.  
  114.  
  115.         //Thumbnail dimensions
  116.         $w = (get_option(THEMESLUG.'_single_product_image_width')) ? get_option(THEMESLUG.'_single_product_image_width') : 147; // image max width
  117.         $h = ($crop) ? (get_option(THEMESLUG.'_single_product_image_height')) ? get_option(THEMESLUG.'_single_product_image_height') : 147 : 10000; // image max height
  118.         ?>
  119.        
  120.             <?php if(count($rt_gallery_images)>1):?>
  121.                 <!-- product image slider -->
  122.    
  123.                     <?php  
  124.                     //Product Photos
  125.                     $imagesHTML = "";
  126.                     $maxHeight  = 0;
  127.  
  128.  
  129.                         for ($i=0; $i < (count($rt_gallery_images)); $i++) {
  130.  
  131.                             //resize the photo  
  132.                             $photo_url      = find_image_org_path(trim($rt_gallery_images[$i]));
  133.                             $image_thumb        = @vt_resize( '', trim(trim($rt_gallery_images[$i])), $w, $h, $crop );                                                 
  134.                             $maxHeight      = ($image_thumb['height']>$maxHeight) ? $image_thumb['height'] : $maxHeight ;
  135.                              
  136.                             $imagesHTML .=  '<li><a class="imgeffect magnifier" href="'.$photo_url.'" data-gal="prettyPhoto[rt_theme_products]" title="'.$rt_gallery_image_descs[$i].'"><img src="'.$image_thumb['url'].'" width="'.$w.'" alt="'.$rt_gallery_image_titles[$i].'" /></a></li>';
  137.  
  138.                         }
  139.  
  140.                     ?>
  141.                    
  142.                 <div class="carousel box-shadow" style="height:<?php echo $maxHeight+42;?>px;overflow:hidden;"><ul id="product_thumbnails" class="jcarousel-skin-rt"><?php echo $imagesHTML;?></ul></div>
  143.                 <div class="space margin-t10 margin-b20"></div>
  144.             <?php endif;?>
  145.         <?php endif;?>
  146.     <!-- / product images -->  
  147.    
  148.  
  149.     <!-- PRODUCT TABS -->
  150.  
  151.     <!-- TABS WRAP -->             
  152.        
  153.         <?php if(@$tabbed_page):?>
  154.         <div class="taps_wrap box-shadow">
  155.             <!-- the tabs -->
  156.             <ul class="tabs">
  157.                 <?php if($content):?><li><a href="#"><?php _e('General Details','rt_theme');?></a></li><?php endif;?>
  158.                 <?php
  159.                 #
  160.                 #   Free Tabs
  161.                 #  
  162.                 for($i=0; $i<$tab_count+1; $i++){
  163.                     if ( trim( get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true ) )  && !$password_protected ){
  164.                         echo '<li><a href="#">'.get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true).'</a></li>';
  165.                     }
  166.                 }
  167.                
  168.                 #
  169.                 #   Attached Documents
  170.                 #      
  171.                 if( $rt_attached_documents  && !$password_protected ){
  172.                     echo '<li><a href="#">'.__('Attached Documents','rt_theme').'</a></li>';
  173.                 }
  174.                 ?>
  175.        
  176.             </ul>
  177.         <?php endif;?>
  178.        
  179.         <?php if($content):?>                              
  180.         <!-- General Details -->
  181.        
  182.         <?php if(@$tabbed_page):?><div class="pane"><?php else:?><div class="box one box-shadow margin-b30"><?php endif;?>
  183.             <div>
  184.             <?php if(is_array($rt_gallery_images) && count($rt_gallery_images)==1): // only 1 image for this product ?>
  185.                 <?php
  186.                 //resize the photo  
  187.                 $photo_url      = (is_array($rt_gallery_images)) ? find_image_org_path($rt_gallery_images[0]) : "";
  188.                 $image_thumb        = @vt_resize( '', trim($photo_url), 300, 600, false );     
  189.                 ?>
  190.                 <a href="<?php echo $photo_url;?>" title="" data-gal="prettyPhoto[rt_theme_products]" class="imgeffect magnifier alignleft" ><img src="<?php echo $image_thumb['url'];?>" alt="" /></a>
  191.             <?php endif;?>
  192.            
  193.             <?php echo $content;?>
  194.             </div>
  195.             <div class="clear"></div>
  196.         </div>
  197.         <?php endif;?>
  198.  
  199.         <?php
  200.         #
  201.         #   Free Tabs' Content
  202.         #  
  203.         for($i=0; $i<$tab_count+1; $i++){
  204.             if ( trim( get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_title', true) )  && !$password_protected ){
  205.                 echo '<div class="pane">';
  206.                 echo (apply_filters('the_content',get_post_meta($post->ID, THEMESLUG.'free_tab_'.$i.'_content', true)));
  207.                 echo '<div class="clear"></div></div>';
  208.             }
  209.         }
  210.         ?>
  211.  
  212.         <?php if($rt_attached_documents && !$password_protected):?>
  213.                
  214.             <?php if(@!$tabbed_page):?><div class="line"></div><?php endif;?>
  215.             <div class="pane">
  216.                 <!-- document icons -->
  217.                 <div class="doc_icons">
  218.                    
  219.                     <?php
  220.  
  221.                     if(trim($rt_attached_documents)):
  222.                         $rt_attached_documents  = trim(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $rt_attached_documents));  
  223.                         $rt_attached_documents  = explode("\n", $rt_attached_documents);
  224.                     endif;
  225.                    
  226.                     if(is_array($rt_attached_documents)){
  227.                        
  228.                         echo "<ul>";
  229.  
  230.                         foreach($rt_attached_documents as $a_file){
  231.                             if(strrpos($a_file,"|")) {
  232.                                 $fileTarget="";
  233.                                 $a_file = explode("|", $a_file);
  234.                                 $fileTarget = trim ($a_file[2]);
  235.                                 $fileURL = trim( $a_file[1] );
  236.                                 $fileName = trim( $a_file[0] );
  237.                             }else{
  238.                                 $fileURL = trim( $a_file );
  239.                                 $fileName  = "";
  240.                                 $fileTarget ="";
  241.                             }
  242.  
  243.                             echo "<li>";
  244.  
  245.                             if(strpos($fileURL, ".doc")){
  246.                                 echo '<a href="'.$fileURL.'" title="'.__('Download Word File','rt_theme').'" target="'.$fileTarget.'"><img src="'.THEMEURI.'/images/assets/icons/Word.png" alt="'.__('Download Word File','rt_theme').'" class="png" /></a>';
  247.                             }
  248.  
  249.                             elseif(strpos($fileURL, ".xls")){
  250.                                 echo '<a href="'.$fileURL.'" title="'.__('Download Excel File','rt_theme').'" target="'.$fileTarget.'"><img src="'.THEMEURI.'/images/assets/icons/File_Excel.png" alt="'.__('Download Excel File','rt_theme').'" class="png" /></a>';
  251.                             }
  252.  
  253.                             elseif(strpos($fileURL, ".pdf")){
  254.                                 echo '<a href="'.$fileURL.'" title="'.__('Download PDF File','rt_theme').'" target="'.$fileTarget.'"><img src="'.THEMEURI.'/images/assets/icons/File_Pdf.png" alt="'.__('Download PDF File','rt_theme').'" class="png" /></a>';
  255.                             }                          
  256.  
  257.                             elseif(strpos($fileURL, ".ppt")){
  258.                                 echo '<a href="'.$fileURL.'" title="'.__('Download PowerPoint File','rt_theme').'" target="'.$fileTarget.'"><img src="'.THEMEURI.'/images/assets/icons/File_PowerPoint.png" alt="'.__('Download PowerPoint File','rt_theme').'" class="png" /></a>';
  259.                             }                          
  260.  
  261.                             else{
  262.                                 echo '<a href="'.$fileURL.'" title="'.__('Download File','rt_theme').'" target="'.$fileTarget.'"><img src="'.THEMEURI.'/images/assets/icons/File.png" alt="'.__('Download File','rt_theme').'" class="png" /></a>';
  263.                             }
  264.                            
  265.                             //file name
  266.                             if( $fileName ) echo "<strong>" .$fileName ."</strong>";
  267.  
  268.                             echo "</li>";
  269.                            
  270.                         }
  271.  
  272.                         echo "</ul>";
  273.                     }
  274.                     ?>
  275.  
  276.                 </div>
  277.                 <!-- document icons -->
  278.             </div>
  279.         <?php endif;?>
  280.                
  281.                
  282.         <?php if(@$tabbed_page):?>        
  283.         </div><div class="clear"></div>
  284.         <?php endif;?>
  285.  
  286.     <!-- / PRODUCT TABS -->
  287.  
  288.             <?php
  289.                     if($sidebar=="full"){
  290.                         echo $before_sidebar;
  291.                     }
  292.             ?>
  293.  
  294.  
  295.     <div class="space v_10"></div>
  296.     <!-- / content -->     
  297.  
  298.    
  299.     <?php if(comments_open()):?>
  300.  
  301.    
  302.     <div class="box one box-shadow">
  303.         <div class='entry commententry'>
  304.             <?php comments_template(); ?>
  305.         </div>
  306.     </div>
  307.     <div class="space margin-t10 margin-b20"></div>
  308.     <?php endif;?>
  309.  
  310.  
  311.     <!-- RELATED PRODUCTS -->
  312.         <?php
  313.         if(is_array($related_products)){
  314.         ?>
  315.                         <!-- title -->
  316.                 <div class="box one box-shadow margin-b30">
  317.                         <!-- page title -->
  318.                         <div class="head_text nomargin">
  319.                             <div class="arrow"></div><!-- arrow -->
  320.                             <h4 class="product"><?php echo __("Related Products",'rt_theme');?></h4>
  321.                         </div>
  322.                         <!-- /page title -->
  323.                 </div>
  324.                
  325.         <?php
  326.             //taxonomy
  327.             $args=array(
  328.                 'post_type'           => 'products',
  329.                 'post_status'         => 'publish',
  330.                 'orderby'             => 'menu_order',
  331.                 'ignore_sticky_posts' => 1,
  332.                 'posts_per_page'      => 1000,
  333.                 'post__in'            => $related_products
  334.             );
  335.  
  336.             //item width - column count
  337.             $item_width = get_option(THEMESLUG."_related_product_layout");
  338.             get_template_part( 'product_loop', 'product_categories' );
  339.         echo '<div class="space margin-b30"></div>';
  340.         }
  341.         ?>
  342.  
  343.     <!-- / RELATED PRODUCTS -->
  344.  
  345.     <?php endwhile;?>
  346.    
  347.     <?php else: ?>
  348.         <p><?php _e( 'Sorry, no page found.', 'rt_theme'); ?></p>
  349.     <?php endif; ?>
  350.    
  351.    
  352. <?php
  353. #
  354. #   call the sub content holder 2nd part
  355. #
  356. sub_page_layout("subfooter",$sidebar);
  357.  
  358. get_footer();
  359. ?>
Advertisement
Add Comment
Please, Sign In to add comment