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

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

66 lines 1.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 {
4
5 public $blocks;
6 public $container;
7 public $fonts;
8
9 public function __construct( $blocks, $fonts = array() )
10 {
11 $this->fonts = $fonts;
12
13 // Set object blocks before sorting to maintain index
14 $this->blocks = $blocks;
15
16 // Sort according to block order
17 usort( $blocks, array( $this, 'sortByOrder' ) );
18
19 // Generate children, children will be sorted correctly due to above sort
20 foreach( $blocks as $block )
21 {
22 if( isset( $block->parent ) && isset( $block->row ) && isset( $block->column ) )
23 {
24 // Set container block, there should only be one
25 if( $block->type == 'container' ) {
26 $this->container = $block;
27 }
28 // Add child to parent
29 else
30 {
31 $this->blocks[$block->parent]->add_child( $block );
32 }
33 }
34 }
35
36 }
37
38 public function sortByOrder( $a, $b )
39 {
40 return $a->order > $b->order ? 1 : -1;
41 }
42
43 public function serialize()
44 {
45 return serialize( $this );
46 }
47
48 public function encode()
49 {
50 return base64_encode( $this->serialize() );
51 }
52
53 public function output_string( $post, $classes )
54 {
55 $args = array(
56 'classes' => $classes,
57 );
58
59 return $this->container->output( $post, $args );
60 }
61
62 public function output( $post, $classes )
63 {
64 echo $this->output_string( $post, $classes );
65 }
66 }