Advertisement
BackuPs-nl

rt17 add target to products attachments

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