PluginProbe
WP Ultimate Post Grid / 2.6.0
WP Ultimate Post Grid v2.6.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / addons / custom-templates / templates / layout / columns.php

columns.php in WP Ultimate Post Grid 2.6.0, at addons/custom-templates/templates/layout/columns.php

103 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPUPG_Template_Columns extends WPUPG_Template_Block {
4
5 public $columns;
6 public $widths;
7 public $responsive = false;
8 public $mobile_reverse = false;
9
10 public $editorField = 'columns';
11
12 public function __construct( $type = 'columns' )
13 {
14 parent::__construct( $type );
15
16 $this->add_style( 'vertical-align', 'top', 'td' );
17 }
18
19 public function columns( $columns )
20 {
21 $this->columns = $columns;
22 return $this;
23 }
24
25 public function width( $widths )
26 {
27 $this->widths = $widths;
28 foreach( $widths as $column => $width )
29 {
30 $this->add_style( 'width', $width, 'col-' . $column );
31 }
32 return $this;
33 }
34
35 public function responsive( $responsive )
36 {
37 $this->responsive = $responsive;
38 return $this;
39 }
40
41 public function mobile_reverse( $mobile_reverse )
42 {
43 $this->mobile_reverse = $mobile_reverse;
44 return $this;
45 }
46
47 public function output( $post, $args = array() )
48 {
49 if( !$this->output_block( $post, $args ) ) return '';
50
51 $args['max_width'] = $this->max_width && $args['max_width'] > $this->max_width ? $this->max_width : $args['max_width'];
52 $args['max_height'] = $this->max_height && $args['max_height'] > $this->max_height ? $this->max_height : $args['max_height'];
53 $show_on_desktop = $args['desktop'] && $this->show_on_desktop;
54 $output = $this->before_output();
55
56 ob_start();
57 ?>
58 <?php if( $this->responsive ) { $args['desktop'] = false; ?>
59 <div class="wpupg-responsive-mobile">
60 <div<?php echo $this->style(); ?>>
61 <?php if( $this->mobile_reverse ) { ?>
62 <?php for( $j = $this->columns-1; $j >= 0; $j-- ) { ?>
63 <?php if( $this->show( $post, 'col-' . $j, $args ) ) { ?>
64 <div class="wpupg-rows-row">
65 <?php $this->output_children( $post, 0, $j, $args ); ?>
66 </div>
67 <?php } // end if show col ?>
68 <?php } // end for cols ?>
69 <?php } else { ?>
70 <?php for( $j = 0; $j < $this->columns; $j++ ) { ?>
71 <?php if( $this->show( $post, 'col-' . $j, $args ) ) { ?>
72 <div class="wpupg-rows-row">
73 <?php $this->output_children( $post, 0, $j, $args ); ?>
74 </div>
75 <?php } // end if show col ?>
76 <?php } // end for cols ?>
77 <?php } // end responsive reverse ?>
78 </div>
79 </div>
80 <div class="wpupg-responsive-desktop">
81 <?php } ?>
82 <?php $args['desktop'] = $show_on_desktop; ?>
83 <table<?php echo $this->style(); ?>>
84 <tbody>
85 <tr>
86 <?php for( $j = 0; $j < $this->columns; $j++ ) { ?>
87 <?php if( $this->show( $post, 'col-' . $j, $args ) ) { ?>
88 <td<?php echo $this->style( array( 'td', 'col-' . $j ) ); ?>>
89 <?php $this->output_children( $post, 0, $j, $args ); ?>
90 </td>
91 <?php } // end if show col ?>
92 <?php } // end for cols ?>
93 </tr>
94 </tbody>
95 </table>
96 <?php if( $this->responsive ) echo '</div>'; ?>
97 <?php
98 $output .= ob_get_contents();
99 ob_end_clean();
100
101 return $this->after_output( $output, $post );
102 }
103 }