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

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

69 lines 2.6 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_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 if( isset( $post->term ) && $post->term ) {
37 $link = get_term_link( intval( $post->ID ), $post->post_type );
38 $custom_link = get_term_meta( intval( $post->ID ), 'wpupg_custom_link', true );
39 $custom_link_behaviour = get_term_meta( intval( $post->ID ), 'wpupg_custom_link_behaviour', true );
40 $image = intval( get_term_meta( intval( $post->ID ), 'wpupg_custom_image', true ) );
41 $image_url = $image ? wp_get_attachment_url( $image ) : '';
42 } else {
43 $link = get_permalink( $post->ID );
44 $custom_link = trim( get_post_meta( $post->ID, 'wpupg_custom_link', true ) );
45 $custom_link_behaviour = trim( get_post_meta( $post->ID, 'wpupg_custom_link_behaviour', true ) );
46 $image = $post->post_type == 'attachment' ? $post->ID : get_post_thumbnail_id( $post->ID );
47 $image_url = $image ? wp_get_attachment_url( $image ) : '';
48 }
49
50 $output = $this->before_output();
51
52 ob_start();
53 ?>
54 <div id="wpupg-container-post-<?php echo $post->ID; ?>"
55 data-id="<?php echo $post->ID; ?>"
56 data-permalink="<?php echo esc_attr( $link ); ?>"
57 data-custom-link="<?php echo esc_attr( $custom_link ); ?>"
58 data-custom-link-behaviour="<?php echo esc_attr( $custom_link_behaviour ); ?>"
59 data-image="<?php echo esc_attr( $image_url ); ?>"
60 <?php echo $this->style(); ?>>
61 <?php $this->output_children( $post, 0, 0, $args ) ?>
62 </div>
63 <?php
64 $output .= ob_get_contents();
65 ob_end_clean();
66
67 return $this->after_output( $output, $post );
68 }
69 }