Advertisement
Guest User

Untitled

a guest
Sep 6th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.56 KB | None | 0 0
  1. <?php
  2. add_action('tmpl_detail_page_custom_fields_collection','detail_fields_colletion');
  3. /*
  4. Name : detail_fields_colletion
  5. Desc : Return the collection for detail/single page
  6. */
  7. function detail_fields_colletion()
  8. {
  9.     global $wpdb,$post,$detail_post_type;
  10.     $detail_post_type = $post->post_type;
  11.     if(isset($_REQUEST['pid']) && $_REQUEST['pid'])
  12.     {
  13.         $cus_post_type = get_post_type($_REQUEST['pid']);
  14.         $PostTypeObject = get_post_type_object($cus_post_type);
  15.         $PostTypeLabelName = $PostTypeObject->labels->name;
  16.         $single_pos_id = $_REQUEST['pid'];
  17.     }
  18.     else
  19.     {   $cus_post_type = get_post_type($post->ID);
  20.         $PostTypeObject = get_post_type_object($cus_post_type);
  21.         $PostTypeLabelName = $PostTypeObject->labels->name;
  22.         $single_pos_id = $post->ID;
  23.     }
  24.     $heading_type = fetch_heading_per_post_type($cus_post_type);
  25.     remove_all_actions('posts_where');
  26.     $post_query = null;
  27.     if(count($heading_type) > 0)
  28.       {
  29.         foreach($heading_type as $_heading_type)
  30.          {
  31.             $args =
  32.             array( 'post_type' => 'custom_fields',
  33.             'posts_per_page' => -1  ,
  34.             'post_status' => array('publish'),
  35.             'meta_query' => array(
  36.                'relation' => 'AND',
  37.                 array(
  38.                     'key' => 'post_type_'.$cus_post_type.'',
  39.                     'value' => $cus_post_type,
  40.                     'compare' => '=',
  41.                     'type'=> 'text'
  42.                 ),
  43.                 array(
  44.                     'key' => 'show_on_page',
  45.                     'value' =>  array('user_side','both_side'),
  46.                     'compare' => 'IN'
  47.                 ),
  48.                 array(
  49.                     'key' => 'is_active',
  50.                     'value' =>  '1',
  51.                     'compare' => '='
  52.                 ),
  53.                 array(
  54.                     'key' => 'heading_type',
  55.                     'value' =>  $_heading_type,
  56.                     'compare' => '='
  57.                 ),
  58.                 array(
  59.                     'key' => 'show_on_detail',
  60.                     'value' =>  '1',
  61.                     'compare' => '='
  62.                 )
  63.             ),
  64.                 'meta_key' => 'sort_order',
  65.                 'orderby' => 'meta_value_num',
  66.                 'meta_value_num'=>'sort_order',
  67.                 'order' => 'ASC'               
  68.             );
  69.         $post_query = new WP_Query($args);
  70.        
  71.         $post_meta_info = $post_query;
  72.         $suc_post = get_post($single_pos_id);
  73.        
  74.                 if($post_meta_info->have_posts())
  75.                   {
  76.                     echo "<div class='grid02 rc_rightcol clearfix'>";
  77.                     echo "<ul class='list'>";                  
  78.                       $i=0;
  79.                     while ($post_meta_info->have_posts()) : $post_meta_info->the_post();
  80.                         $field_type = get_post_meta($post->ID,"ctype",true);
  81.                        
  82.                         if($i==0)
  83.                         {
  84.                             if($post->post_name!='post_excerpt' && $post->post_name!='post_content' && $post->post_name!='post_title' && $post->post_name!='post_images' && $post->post_name!='post_category')
  85.                             {
  86.                                 if($_heading_type == "[#taxonomy_name#]"){
  87.                                     echo "<li><h2>";_e(ucfirst($PostTypeLabelName),DOMAIN);echo ' '; _e("Information",DOMAIN);echo "</h2></li>";
  88.                                 }else{
  89.                                     echo "<li><h2>".$_heading_type."</h2></li>";  
  90.                                 }  
  91.                             }
  92.                             $i++;
  93.                         }
  94.                
  95.                             if(get_post_meta($single_pos_id,$post->post_name,true))
  96.                               {
  97.                                 if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox')
  98.                                   {
  99.                                     $_value = "";
  100.                                     foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value)
  101.                                      {
  102.                                         $_value .= $value.",";
  103.                                      }
  104.                                      echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".substr($_value,0,-1)."</p></li>";
  105.                                   }else if($field_type =='radio' || $field_type =='select'){
  106.                                    
  107.                                         $options = explode(',',get_post_meta($post->ID,"option_values",true));
  108.                                         $options_title = explode(',',get_post_meta($post->ID,"option_title",true));
  109.                            
  110.                                         for($i=0; $i<= count($options); $i++){
  111.                                              $val = $options[$i];
  112.                                             if(trim($val) == trim(get_post_meta($single_pos_id,$post->post_name,true))){
  113.                                                 $val_label = $options_title[$i];
  114.                                                
  115.                                             }
  116.                                         }
  117.                                        
  118.                                         if($val_label ==''){ $val_label = get_post_meta($single_pos_id,$post->post_name,true); } // if title not set then display the value
  119.                                            
  120.                                         echo "<li><p>".$post->post_title." : </p> <p> ".$val_label."</p></li>";
  121.  
  122.                                  
  123.                                   }
  124.                                 else
  125.                                  {
  126.                                      if(get_post_meta($post->ID,'ctype',true) == 'upload')
  127.                                      {
  128.                                         echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> Click here to download File <a href=".get_post_meta($single_pos_id,$post->post_name,true).">Download</a></p></li>";
  129.                                      }
  130.                                      else
  131.                                      {
  132.                                          echo "<li class='".$post->post_name."'><p>".$post->post_title." : </p> <p> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>";
  133.                                      }
  134.                                  }
  135.                               }                        
  136.                             if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!='')
  137.                              {
  138.                                 $suc_post_excerpt = $suc_post->post_excerpt;
  139.                                 ?>
  140.                                      <li>
  141.                                      <div class="row">
  142.                                         <div class="twelve columns">
  143.                                              <div class="title_space">
  144.                                                  <div class="title-container">
  145.                                                      <h1><?php _e('Post Excerpt',DOMAIN);?></h1>
  146.                                                      <div class="clearfix"></div>
  147.                                                  </div>
  148.                                                  <?php echo $suc_post_excerpt;?>
  149.                                              </div>
  150.                                          </div>
  151.                                      </div>
  152.                                      </li>
  153.                                 <?php
  154.                              }
  155.        
  156.                             if(get_post_meta($post->ID,"ctype",true) == 'geo_map')
  157.                              {
  158.                                 $add_str = get_post_meta($single_pos_id,'address',true);
  159.                                 $geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true);
  160.                                 $geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true);
  161.                                 $map_view = get_post_meta($single_pos_id,'map_view',true);                             
  162.                              }       
  163.                     endwhile;wp_reset_query();
  164.                     echo "</ul>";
  165.                     echo "</div>";
  166.                   }    
  167.            }
  168.       }
  169.      else
  170.       {    
  171.         $args =
  172.         array( 'post_type' => 'custom_fields',
  173.         'posts_per_page' => -1  ,
  174.         'post_status' => array('publish'),
  175.         'meta_query' => array(
  176.            'relation' => 'AND',
  177.             array(
  178.                 'key' => 'post_type_'.$cus_post_type.'',
  179.                 'value' => $cus_post_type,
  180.                 'compare' => '=',
  181.                 'type'=> 'text'
  182.             ),
  183.             array(
  184.                 'key' => 'is_active',
  185.                 'value' =>  '1',
  186.                 'compare' => '='
  187.             ),
  188.             array(
  189.                 'key' => 'show_on_detail',
  190.                 'value' =>  '1',
  191.                 'compare' => '='
  192.             )
  193.         ),
  194.             'meta_key' => 'sort_order',
  195.             'orderby' => 'meta_value',
  196.             'order' => 'ASC'
  197.         );             
  198.         $post_query = new WP_Query($args);
  199.         $post_meta_info = $post_query;
  200.         $suc_post = get_post($single_pos_id);              
  201.         if($post_meta_info->have_posts())
  202.         {  
  203.             $i=0;
  204.             /*Display the post_detail gheading only one time also with if any custom field create. */
  205.             while ($post_meta_info->have_posts()) : $post_meta_info->the_post();   
  206.                 if($i==0)
  207.                 if($post->post_name != 'post_excerpt' && $post->post_name != 'post_content' && $post->post_name != 'post_title' && $post->post_name != 'post_images' && $post->post_name != 'post_category')
  208.                 {
  209.                     echo '<div class="title-container clearfix">'; 
  210.                     //echo '<h1>'.POST_DETAIL.'</h1>';
  211.                     $CustomFieldHeading = apply_filters('CustomFieldsHeadingTitle',POST_DETAIL);
  212.                    
  213.                     if(function_exists('icl_register_string')){
  214.                         icl_register_string(DOMAIN,$CustomFieldHeading,$CustomFieldHeading);
  215.                     }
  216.                    
  217.                     if(function_exists('icl_t')){
  218.                         $CustomFieldHeading1 = icl_t(DOMAIN,$CustomFieldHeading,$CustomFieldHeading);
  219.                     }else{
  220.                         $CustomFieldHeading1 = __($CustomFieldHeading,DOMAIN);
  221.                     }
  222.                     echo '<h3>'.$CustomFieldHeading1.'</h3>';
  223.                
  224.                     echo '</div>';
  225.                     $i++;
  226.                 }          
  227.             endwhile;wp_reset_query();  //Finish this while loop for display POST_DETAIL           
  228.               ?>              
  229.         <?php echo "<div class='grid02 rc_rightcol clearfix'>";
  230.                 echo "<ul class='list'>";
  231.                 if($_heading_type!="")         
  232.                     echo "<h3>".$_heading_type."</h3>";
  233.            
  234.             while ($post_meta_info->have_posts()) : $post_meta_info->the_post();               
  235.                     if(get_post_meta($single_pos_id,$post->post_name,true))
  236.                       {
  237.                         if(get_post_meta($post->ID,"ctype",true) == 'multicheckbox')
  238.                           {
  239.                             foreach(get_post_meta($single_pos_id,$post->post_name,true) as $value)
  240.                              {
  241.                                 $_value .= $value.",";
  242.                              }
  243.                              echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".substr($_value,0,-1)."</p></li>";
  244.                           }
  245.                         else
  246.                          {
  247.                              echo "<li><p class='tevolution_field_title'>".$post->post_title.": </p> <p class='tevolution_field_value'> ".get_post_meta($single_pos_id,$post->post_name,true)."</p></li>";
  248.                          }
  249.                       }                        
  250.                     if($post->post_name == 'post_excerpt' && $suc_post->post_excerpt!="")
  251.                      {
  252.                         $suc_post_excerpt = $suc_post->post_excerpt;
  253.                         ?>
  254.                            <li>
  255.                            <div class="row">
  256.                               <div class="twelve columns">
  257.                                    <div class="title_space">
  258.                                        <div class="title-container">
  259.                                            <h1><?php _e('Post Excerpt');?></h1>
  260.                                            <div class="clearfix"></div>
  261.                                        </div>
  262.                                        <?php echo $suc_post_excerpt;?>
  263.                                    </div>
  264.                                </div>
  265.                            </div>
  266.                            </li>
  267.                   <?php
  268.                      }
  269.  
  270.                     if(get_post_meta($post->ID,"ctype",true) == 'geo_map')
  271.                      {
  272.                         $add_str = get_post_meta($single_pos_id,'address',true);
  273.                         $geo_latitude = get_post_meta($single_pos_id,'geo_latitude',true);
  274.                         $geo_longitude = get_post_meta($single_pos_id,'geo_longitude',true);                               
  275.                      }
  276.  
  277.             endwhile;wp_reset_query();
  278.             echo "</ul>";
  279.             echo "</div>";
  280.           }
  281.       }
  282.         if(isset($suc_post_con)):
  283.         do_action('templ_before_post_content');/*Add action for before the post content. */?>
  284.              <div class="row">
  285.                 <div class="twelve columns">
  286.                      <div class="title_space">
  287.                          <div class="title-container">
  288.                              <h1><?php _e('Post Description', DOMAIN);?></h1>
  289.                           </div>
  290.                          <?php echo $suc_post_con;?>
  291.                      </div>
  292.                  </div>
  293.              </div>
  294.         <?php do_action('templ_after_post_content'); /*Add Action for after the post content. */
  295.         endif;     
  296.             $tmpdata = get_option('templatic_settings');   
  297.             $show_map='';
  298.             if(isset($tmpdata['map_detail_page']) && $tmpdata['map_detail_page']=='yes')
  299.                 $show_map=$tmpdata['map_detail_page'];
  300.             if(isset($add_str) && $add_str != '')
  301.             {
  302.             ?>
  303.                 <div class="row">
  304.                     <div class="title_space">
  305.                         <div class="title-container">
  306.                             <h1><?php _e('Map',DOMAIN); ?></h1>
  307.                         </div>
  308.                         <p><strong><?php _e('Location : '); echo $add_str;?></strong></p>
  309.                     </div>
  310.  
  311.                        <?php if($geo_latitude && $geo_longitude ):?>
  312.                                                                      <!-- Location Map-->
  313.                         <div id="location_map">
  314.                               <div class="google_map" id="detail_google_map_id">
  315.                                 <?php include_once ('google_map_detail.php');?>
  316.                               </div>                                 <!-- google map #end -->
  317.                         </div>
  318.                    
  319.                     <?php endif;?>
  320.                 </div>
  321.             <?php }
  322.  
  323. }
  324. /* EOF */
  325. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement