Advertisement
Guest User

same file after my changes, comments on 71-78 line

a guest
Jul 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.45 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.  
  41.  
  42. <?php
  43. global $post;
  44. $post_id = $post->ID;
  45. $groupID = 8098;
  46. $custom_field_keys = get_post_custom_keys($groupID);
  47. $count = 0;
  48. $items = count($custom_field_keys);
  49. if($items){
  50.     $set_in_order = array();
  51.     foreach ( $custom_field_keys as $key => $fieldkey )
  52.     {
  53.         if (stristr($fieldkey,'field_'))
  54.         {
  55.  
  56.             $cstm_pst_mt = get_post_meta($groupID, $fieldkey, true);
  57.  
  58.             $set_in_order[$cstm_pst_mt['order_no']] = $cstm_pst_mt['key'];
  59.            
  60.         }
  61.     }
  62. }
  63.  
  64. ksort($set_in_order);
  65.  
  66. $items = count($set_in_order);
  67.  
  68.  
  69. if($items){
  70.  
  71. /*    here, I created a new array, which will consist of non-empty array items,
  72.         on which length we CAN make the closing table & div tags dependent
  73.     ($set_in_order_not_empty)
  74.  
  75.     so, we are just populating that array in this first foreach loop,
  76.     and we are outputing the table, rows and all the html in NEXT foreach loop, line 109-130
  77.     done over this $set_in_order_not_empty array, so that the length is consistent
  78.     and table & div tags get output correctly and in each case (lines 124 and 126) */
  79.  
  80.     $set_in_order_not_empty = array();
  81.     foreach ( $set_in_order as $key => $fieldkey )
  82.     {
  83.  
  84.         $field = get_field_object($fieldkey, $post_id);
  85.  
  86.  
  87.  
  88.         if($field['label'] != ''){
  89.             $other_label = $field['label'];    
  90.         }else{
  91.             $other_label = '';
  92.         }
  93.  
  94.         if(isset($field['value']) && is_array($field['value'])){
  95.             $other_value = implode(",", $field['value']);
  96.         }else{
  97.             $other_value = $field['value'];
  98.         }
  99.  
  100.  
  101.  
  102.         if($other_value != ''){ $set_in_order_not_empty[] = array("label" => $other_label, "value"=> $other_value); }
  103.  
  104.     }
  105.  
  106.  
  107.  //
  108.     ksort($set_in_order_not_empty);
  109.     foreach ( $set_in_order_not_empty as $key => $field )
  110.     {
  111.         if($key == 0){ ?>
  112.  
  113.             <div class="tour_discount_info faqsec">
  114.             <h3>FAQ</h3>
  115.             <table border="0">
  116.             <?php
  117.         }
  118.         echo '<tr><td>' . $field['label'] . '</td><td>' . $field['value']. '</td></tr>'; ?>
  119.         <?php
  120.  
  121.         if($key == count($set_in_order_not_empty) - 1){
  122.  
  123.             ?>
  124.             </table>
  125.  
  126.             </div>
  127.  
  128.             <?php
  129.         }
  130.     }
  131.  
  132.  
  133.     //
  134.  
  135. }
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement