| 1 |
<?php |
| 2 |
|
| 3 |
class WPUPG_Template_Rows extends WPUPG_Template_Block { |
| 4 |
|
| 5 |
public $rows; |
| 6 |
public $heights; |
| 7 |
|
| 8 |
public $editorField = 'rows'; |
| 9 |
|
| 10 |
public function __construct( $type = 'rows' ) |
| 11 |
{ |
| 12 |
parent::__construct( $type ); |
| 13 |
} |
| 14 |
|
| 15 |
public function rows( $rows ) |
| 16 |
{ |
| 17 |
$this->rows = $rows; |
| 18 |
return $this; |
| 19 |
} |
| 20 |
|
| 21 |
public function height( $heights ) |
| 22 |
{ |
| 23 |
$this->heights = $heights; |
| 24 |
foreach( $heights as $row => $height ) |
| 25 |
{ |
| 26 |
$this->add_style( 'height', $height, 'row-' . $row ); |
| 27 |
} |
| 28 |
return $this; |
| 29 |
} |
| 30 |
|
| 31 |
public function output( $post, $args = array() ) |
| 32 |
{ |
| 33 |
if( !$this->output_block( $post, $args ) ) return ''; |
| 34 |
|
| 35 |
$args['max_width'] = $this->max_width && $args['max_width'] > $this->max_width ? $this->max_width : $args['max_width']; |
| 36 |
$args['max_height'] = $this->max_height && $args['max_height'] > $this->max_height ? $this->max_height : $args['max_height']; |
| 37 |
$args['desktop'] = $args['desktop'] && $this->show_on_desktop; |
| 38 |
$output = $this->before_output(); |
| 39 |
|
| 40 |
ob_start(); |
| 41 |
?> |
| 42 |
<div<?php echo $this->style(); ?>> |
| 43 |
<?php for( $i = 0; $i < $this->rows; $i++ ) { ?> |
| 44 |
<?php if( $this->show( $post, 'row-' . $i, $args ) ) { ?> |
| 45 |
<div class="wpupg-rows-row"<?php echo $this->style( 'row-' . $i ); ?>> |
| 46 |
<?php $this->output_children( $post, $i, 0, $args ); ?> |
| 47 |
</div> |
| 48 |
<?php } // end if show row ?> |
| 49 |
<?php } // end for rows ?> |
| 50 |
</div> |
| 51 |
<?php |
| 52 |
$output .= ob_get_contents(); |
| 53 |
ob_end_clean(); |
| 54 |
|
| 55 |
return $this->after_output( $output, $post ); |
| 56 |
} |
| 57 |
} |