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 / table.php

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

91 lines 2.5 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_Table extends WPUPG_Template_Block {
4
5 public $rows;
6 public $columns;
7 public $heights;
8 public $widths;
9 public $responsive = true;
10
11 public $editorField = 'table';
12
13 public function __construct( $type = 'table' )
14 {
15 parent::__construct( $type );
16 $this->add_style( 'width', '100%' );
17 }
18
19 public function rows( $rows )
20 {
21 $this->rows = $rows;
22 return $this;
23 }
24
25 public function columns( $columns )
26 {
27 $this->columns = $columns;
28 return $this;
29 }
30
31 public function height( $heights )
32 {
33 $this->heights = $heights;
34 foreach( $heights as $row => $height )
35 {
36 $this->add_style( 'height', $height, 'row-' . $row );
37 }
38 return $this;
39 }
40
41 public function width( $widths )
42 {
43 $this->widths = $widths;
44 foreach( $widths as $column => $width )
45 {
46 $this->add_style( 'width', $width, 'col-' . $column );
47 }
48 return $this;
49 }
50
51 public function responsive( $responsive )
52 {
53 $this->responsive = $responsive;
54 return $this;
55 }
56
57 public function output( $post, $args = array() )
58 {
59 if( !$this->output_block( $post, $args ) ) return '';
60
61 $args['max_width'] = $this->max_width && $args['max_width'] > $this->max_width ? $this->max_width : $args['max_width'];
62 $args['max_height'] = $this->max_height && $args['max_height'] > $this->max_height ? $this->max_height : $args['max_height'];
63 $args['desktop'] = $args['desktop'] && $this->show_on_desktop;
64 $output = $this->before_output();
65
66 ob_start();
67 ?>
68 <table<?php echo $this->style(); ?>>
69 <tbody>
70 <?php for( $i = 0; $i < $this->rows; $i++ ) { ?>
71 <?php if( $this->show( $post, 'row-' . $i, $args ) ) { ?>
72 <tr>
73 <?php for( $j = 0; $j < $this->columns; $j++ ) { ?>
74 <?php if( $this->show( $post, 'col-' . $j, $args ) ) { ?>
75 <td<?php echo $this->style( array( 'td', 'row-' . $i, 'col-' . $j ) ); ?>>
76 <?php $this->output_children( $post, $i, $j, $args ); ?>
77 </td>
78 <?php } // end if show col ?>
79 <?php } // end for cols ?>
80 </tr>
81 <?php } // end if show row ?>
82 <?php } // end for rows ?>
83 </tbody>
84 </table>
85 <?php
86 $output .= ob_get_contents();
87 ob_end_clean();
88
89 return $this->after_output( $output, $post );
90 }
91 }