Advertisement
Guest User

her flawed child/st-templates/tours/elements/program.php

a guest
Jul 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.34 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @package WordPress
  4.  * @subpackage Traveler
  5.  * @since 1.0
  6.  *
  7.  * Tours program
  8.  *
  9.  * Created by ShineTheme
  10.  *
  11.  */
  12. $list_day  = get_post_meta(get_the_ID() , 'tours_program',true);
  13. if(!empty($list_day)):
  14.     ?>
  15.     <div id="accordion_tours" class="panel-group">
  16.         <?php
  17.         $i=0;
  18.         foreach($list_day as $k=>$v):
  19.             $id=rand();
  20.             ?>
  21.             <div class="panel panel-default">
  22.                 <div class="panel-heading">
  23.                     <h4 class="panel-title">
  24.                         <a href="#collapse-<?php echo esc_html($id) ?>" data-parent="#accordion_tours" data-toggle="collapse" class="title_program">
  25.                             <?php echo balanceTags($v['title']) ?>
  26.                         </a>
  27.                     </h4>
  28.                 </div>
  29.                 <div id="collapse-<?php echo esc_html($id) ?>" class="panel-collapse collapse <?php if($i==0)echo 'in'; ?>">
  30.                     <div class="panel-body">
  31.                         <?php echo nl2br($v['desc']) ?>
  32.                     </div>
  33.                 </div>
  34.             </div>
  35.             <?php $i++; endforeach; ?>
  36.     </div>
  37. <?php endif; ?>
  38.  
  39.  
  40. <?php
  41. global $post;
  42. $post_id = $post->ID;
  43. $groupID = 8098;
  44. $custom_field_keys = get_post_custom_keys($groupID);
  45. $count = 0;
  46. $items = count($custom_field_keys);
  47. if($items){
  48.     $set_in_order = array();
  49.     foreach ( $custom_field_keys as $key => $fieldkey )
  50.     {
  51.         if (stristr($fieldkey,'field_'))
  52.         {
  53.  
  54.             $cstm_pst_mt = get_post_meta($groupID, $fieldkey, true);
  55.  
  56.             $set_in_order[$cstm_pst_mt['order_no']] = $cstm_pst_mt['key'];
  57.            
  58.         }
  59.     }
  60. }
  61.  
  62. ksort($set_in_order);
  63.  
  64. $items = count($set_in_order);
  65.  
  66. if($items){
  67.     foreach ( $set_in_order as $key => $fieldkey )
  68.     {
  69.  
  70.         $field = get_field_object($fieldkey, $post_id);
  71.  
  72.         if($field['label'] != ''){
  73.             $other_label = $field['label'];    
  74.         }else{
  75.             $other_label = '';
  76.         }
  77.  
  78.         if(isset($field['value']) && is_array($field['value'])){
  79.             $other_value = implode(",", $field['value']);
  80.         }else{
  81.             $other_value = $field['value'];
  82.         }
  83.  
  84.         if($other_value != ''){
  85.             if($key == 0){ ?>
  86.                 <div class="tour_discount_info faqsec">    
  87.                 <h4>FAQ</h4>
  88.                 <table border="0">
  89.                 <?php
  90.             }
  91.          echo '<tr><td>' . $other_label . '</td><td>' . $other_value. '</td></tr>'; ?>
  92.             <?php
  93.             if($key == $items-1){ ?>
  94.                
  95. <!--                here, she made closing of the tags dependent on $key variable being equal to last
  96.                 item in $items array. But that was an error, because she is using just a subset of
  97.                 $items array - subset consisting of items for which $other_value is not empty.
  98.                
  99.                 But if there exists a field, and its value is empty, the condition is not fulfilled,
  100.                 the closing html tags for table and div (here on line 103 and 105) never get output,
  101.                 and so html gets broken, footer ending up  inside the table for custom fields.-->
  102.                
  103.                 </table>
  104.                
  105.                 </div>
  106.                 <?php
  107.             }
  108.         }
  109.     }
  110. }
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement