/var/www/(Del)hsihk.com/wp-content/themes/flatsome/inc/shortcodes/banner_grid.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
// [ux_banner_grid]
add_shortcode('ux_banner_grid''bannergridShortcodeNew');
function 
bannergridShortCodeNew($atts$content null) {
    
extractshortcode_atts( array(
    
'width' => '',
    
'height' => '600px',
    
'grid' => '',
    
'padding' => '15px'
    
), $atts ) );
    
$shortcode_id rand();
    
ob_start();
  
?>
  <?php if($padding && $grid){ $padding_w $padding/2?>
          <style>
          #banner_grid_<?php echo $shortcode_id?> .ux_banner-grid{margin-left: -<?php echo $padding_w?>px !important; margin-right: -<?php echo $padding_w ?>px !important;}
          #banner_grid_<?php echo $shortcode_id?> .ux_banner-grid .columns{margin-bottom: <?php echo $padding?>!important} 
          #banner_grid_<?php echo $shortcode_id?> .ux_banner-grid .columns > .column-inner{padding-left: <?php echo $padding_w?>px !important; padding-right: <?php echo $padding_w ?>px !important;}
          </style>
  <?php ?>
  <div id="banner_grid_<?php echo $shortcode_id ?>">
    <div class="row">
      <div class="large-12 columns">
        <div class="row collapse ux_banner-grid ux_banner-grid-new">
             <?php
             
if($grid){
              
$pattern get_shortcode_regex();
              if (
preg_match_all'/'$pattern .'/s'$content$matches )
                  && 
array_key_exists2$matches )
                  && 
in_array'ux_banner'$matches[2] ) )
              {
                  
$tall_height $height;
                  
$less_tall_height $height-($height/3)-($padding/2).'px';
                  
$small_height = ($height/2)-($padding/2).'px';
                  
$smallest_height = ($height/3)-($padding/1.5).'px';
                  
$g_total '';
                  
$id '1';

                  if(
$grid == '1'){
                    
$g_total '5';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $tall_height,'span2' => 'large-3 small-6',
                      
'height3' => $small_height,'span3' => 'large-3 small-6',
                      
'height4' => $small_height,'span4' => 'large-3 small-6',
                      
'height5' => $small_height,'span5' => 'large-3 small-6',
                      );
                  }
                  if(
$grid == '2'){
                    
$g_total '4';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-12 small-12',
                      
'height2' => $smallest_height,'span2' => 'large-4 small-12',
                      
'height3' => $smallest_height,'span3' => 'large-4 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-4 small-12',
                      );
                  }

                  if(
$grid == '3'){
                    
$g_total '3';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $small_height,'span2' => 'large-6 small-6',
                      
'height3' => $small_height,'span3' => 'large-3 small-6',
                      );
                  }

                  if(
$grid == '4'){
                    
$g_total '1';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-3 small-6',
                     
                      );
                  }

                  if(
$grid == '5'){
                    
$g_total '1';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-4 small-6',
                     
                      );
                  }

                  if(
$grid == '6'){
                    
$g_total '3';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-9 small-12',
                      
'height2' => $small_height,'span2' => 'large-3 small-6',
                      
'height3' => $small_height,'span3' => 'large-3 small-6',
                      );
                  }


                  if(
$grid == '7'){
                    
$g_total '3';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-3 small-6',
                      
'height2' => $tall_height,'span2' => 'large-6 small-12',
                      
'height3' => $small_height,'span3' => 'large-3 small-6',
                      );
                  }

                if(
$grid == '8'){
                    
$g_total '3';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-3 small-6',
                      
'height2' => $tall_height,'span2' => 'large-6 small-12',
                      
'height3' => $tall_height,'span3' => 'large-3 small-6',
                      );
                  }

                if(
$grid == '9'){
                    
$g_total '2';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $small_height,'span2' => 'large-3 small-6',
                      );
                  }

                if(
$grid == '10'){
                    
$g_total '5';
                    
$g = array(
                      
'height1' => $tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $smallest_height,'span2' => 'large-6 small-12',
                      
'height3' => $smallest_height,'span3' => 'large-3 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-3 small-12',
                      
'height5' => $smallest_height,'span5' => 'large-6 small-12',
                      );
                  }

                 if(
$grid == '11'){
                    
$g_total '5';
                    
$g = array(
                      
'height1' => $less_tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $less_tall_height,'span2' => 'large-3 small-12',
                      
'height3' => $tall_height,'span3' => 'large-3 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-3 small-12',
                      
'height5' => $smallest_height,'span5' => 'large-6 small-12',
                      );
                  }

                  if(
$grid == '12'){
                    
$g_total '6';
                    
$g = array(
                      
'height1' => $smallest_height,'span1' => 'large-8 small-12',
                      
'height2' => $smallest_height,'span2' => 'large-4 small-12',
                      
'height3' => $smallest_height,'span3' => 'large-4 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-8 small-12',
                      
'height5' => $smallest_height,'span5' => 'large-8 small-12',
                      
'height6' => $smallest_height,'span6' => 'large-4 small-12',
                      );
                  }


                  if(
$grid == '13'){
                    
$g_total '6';
                    
$g = array(
                      
'height1' => $less_tall_height,'span1' => 'large-6 small-12',
                      
'height2' => $small_height,'span2' => 'large-3 small-12',
                      
'height3' => $tall_height,'span3' => 'large-3 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-6 small-12',
                      
'height5' => $small_height,'span5' => 'large-3 small-12',
                      
'height6' => $smallest_height,'span6' => 'large-6 small-12',
                      );
                  }

                  if(
$grid == '14'){
                    
$g_total '6';
                    
$g = array(
                      
'height1' => $smallest_height,'span1' => 'large-9 small-12',
                      
'height2' => $tall_height,'span2' => 'large-3 small-12',
                      
'height3' => $less_tall_height,'span3' => 'large-3 small-12',
                      
'height4' => $smallest_height,'span4' => 'large-3 small-12',
                      
'height5' => $smallest_height,'span5' => 'large-3 small-12',
                      
'height6' => $smallest_height,'span6' => 'large-6 small-12',
                      );
                   }

                  
// Build grid
                  
foreach ($matches[0] as $shortcode) {
                     
$grid_class '';
                     if(
$g['height'.$id] < '200px'){$grid_class 'grid-small-height';}
                     else if(
$g['height'.$id] < '300px'){$grid_class 'grid-medium-height';}

                     echo 
'<div class="columns ux-grid-column '.$grid_class.' '.$g['span'.$id].'"  style="height:'.$g['height'.$id].'"><div class="column-inner">';
                     echo 
fixShortcode($shortcode);
                     echo 
'</div></div>';
                     if(
$id $g_total) {$id++;}
                  }
                
              }} else {
                 echo 
fixShortcode$content );
              }
                 
              
?>
        </div>
      </div>
    </div>
    <script>
  jQuery(document).ready(function ($) {
      var $container = $("#banner_grid_<?php echo $shortcode_id ?> .ux_banner-grid");
      $container.packery({
        itemSelector: ".columns",
        gutter: 0
      });
   });
  </script>
  </div><!-- #banner-grid -->
  
  <?php
  $content 
ob_get_contents();
  
ob_end_clean();
  return 
$content;


add_shortcode('ux_banner_grid''bannergridShortcode');