| 1 |
<?php |
| 2 |
|
| 3 |
class WPUPG_Template_Container extends WPUPG_Template_Block { |
| 4 |
|
| 5 |
public $editorField = 'container'; |
| 6 |
|
| 7 |
public function __construct( $type = 'container' ) |
| 8 |
{ |
| 9 |
parent::__construct( $type ); |
| 10 |
|
| 11 |
// This is always the starting point of the template |
| 12 |
$this->parent = -1; |
| 13 |
$this->row = 0; |
| 14 |
$this->column = 0; |
| 15 |
$this->order = 0; |
| 16 |
} |
| 17 |
|
| 18 |
public function output( $post, $args = array() ) |
| 19 |
{ |
| 20 |
if( !$this->output_block( $post, $args ) ) return ''; |
| 21 |
|
| 22 |
$this->add_style( 'position', '' ); // Make sure position is handled by Isotope |
| 23 |
|
| 24 |
// Default arguments |
| 25 |
$args['desktop'] = true; |
| 26 |
$args['max_width'] = 9999; |
| 27 |
$args['max_height'] = 9999; |
| 28 |
|
| 29 |
$args['max_width'] = $this->max_width && $args['max_width'] > $this->max_width ? $this->max_width : $args['max_width']; |
| 30 |
$args['max_height'] = $this->max_height && $args['max_height'] > $this->max_height ? $this->max_height : $args['max_height']; |
| 31 |
|
| 32 |
if( isset( $args['classes'] ) ) { |
| 33 |
$this->classes = $args['classes']; |
| 34 |
} |
| 35 |
|
| 36 |
$custom_link = trim( get_post_meta( $post->ID, 'wpupg_custom_link', true ) ); |
| 37 |
$image = get_post_thumbnail_id( $post->ID ); |
| 38 |
$image_url = $image ? wp_get_attachment_url( $image ) : ''; |
| 39 |
|
| 40 |
$output = $this->before_output(); |
| 41 |
|
| 42 |
ob_start(); |
| 43 |
?> |
| 44 |
<div id="wpupg-container-post-<?php echo $post->ID; ?>" data-id="<?php echo $post->ID; ?>" data-permalink="<?php echo esc_attr( get_permalink( $post->ID ) ); ?>" data-custom-link="<?php echo esc_attr( $custom_link ); ?>" data-image="<?php echo esc_attr( $image_url ); ?>" <?php echo $this->style(); ?>> |
| 45 |
<?php $this->output_children( $post, 0, 0, $args ) ?> |
| 46 |
</div> |
| 47 |
<?php |
| 48 |
$output .= ob_get_contents(); |
| 49 |
ob_end_clean(); |
| 50 |
|
| 51 |
return $this->after_output( $output, $post ); |
| 52 |
} |
| 53 |
} |