Advertisement
mymarkjeff

Aware online - PDF bundles

Apr 12th, 2022
847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.79 KB | None | 0 0
  1. function growth_mindsets(){
  2.     ob_start();
  3.    
  4.     $user = 'user_'.get_current_user_id();
  5.    
  6.      
  7.    
  8.     if( get_field('growth_guides', $user ) ){
  9.  
  10.         $values = get_field('growth_guides', $user);
  11.         $field = get_field_object('growth_guides', $user);
  12.         $choices = $field['choices'];
  13.        
  14.        
  15.        
  16.         $group = get_field('cognitive_empowerment');
  17.        
  18.      
  19.        
  20.         /*if( have_rows('cognitive_empowerment',$user)){
  21.            
  22.             while( have_rows('cognitive_empowerment',$user) ){ the_row();
  23.                
  24.                 $guide = get_sub_field('legacy');
  25.                
  26.                 $guide_list = array();
  27.                 foreach($guide as $guides){
  28.                    
  29.                    $guide_list[] = $guides;
  30.                    
  31.                 }
  32.                 echo '<pre>';
  33.                 print_r($guide_list);
  34.                 echo '</pre>';
  35.             }
  36.            
  37.         } */
  38.        
  39.         foreach ($choices as $choice_value => $choice_label) {
  40.            
  41.             foreach ($values as $value) {
  42.                  
  43.                 if ($value['value'] == $choice_value) {
  44.  
  45.                     echo '<div style="margin-bottom:20px">';
  46.    
  47.                     echo '<b>'.$choice_label .':</b> ';
  48.                      
  49.                     $no_content = 'No data';
  50.                     $guide_list = array();
  51.                     $type = array('legacy','emerging');
  52.                     $count = 0;
  53.                    
  54.                     if( have_rows($choice_value, $user) ){
  55.                        
  56.                         while( have_rows($choice_value, $user) ){
  57.                            
  58.                             the_row();
  59.                            
  60.                             for($x=0 ; $x < 2 ; $x++){
  61.                                
  62.                                 $guide = get_sub_field($type[$x]);
  63.                    
  64.                                 foreach($guide as $guides){
  65.                                    
  66.                                     $guide_list[] = $guides['label'];
  67.                        
  68.                                 }
  69.                             }
  70.                            
  71.                         }
  72.                        
  73.                         echo '<pre>';
  74.                         print_r($guide_list);
  75.                         echo '</pre>';
  76.                        
  77.                     }
  78.  
  79.                    
  80.                     if( have_rows($choice_value)) {
  81.                        
  82.                        while ( have_rows($choice_value)) {
  83.  
  84.                             the_row();
  85.                            
  86.                            
  87.                             for( $n = 0 ; $n < 2 ; $n++){
  88.                                
  89.                                 echo '<br><i>'.ucwords($type[$n]).'</i></br>';
  90.                                
  91.                                 if( have_rows($type[$n])){
  92.                                    
  93.                                     while ( have_rows($type[$n])){
  94.                                        
  95.                                         the_row();
  96.                                        
  97.                                         $name = get_sub_field('pdf_name');
  98.                                         echo '<div style="border:1px solid #eee; padding:10px; margin-bottom:10px">';
  99.                                         if(array_search($name , $guide_list) !== false ){
  100.                                            
  101.                                              echo '<li><a target="_blank" href="'.get_sub_field('pdf_files').'">'.get_sub_field('pdf_name').'</a></li>';
  102.                                            
  103.                                         }
  104.                                        
  105.                                         echo $name.'<br></div>';
  106.                                        
  107.                                         $count++;
  108.                                     }
  109.                                    
  110.                                 }else{
  111.                                    
  112.                                      $no_content =  '<li>No PDFs yet</li>';
  113.                                      echo $no_content;
  114.                                    
  115.                                 }
  116.                                
  117.                             }
  118.                            
  119.                        }
  120.                        
  121.                    }else{
  122.                        
  123.                        echo $no_content ;
  124.                        
  125.                    }
  126.                    
  127.                    echo '</div>';
  128.                    
  129.                 }
  130.                
  131.             }
  132.  
  133.         }
  134.  
  135.     }
  136.  
  137.     return ob_get_clean();
  138.    
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement