-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.atom-template.php
More file actions
63 lines (50 loc) · 1.93 KB
/
Copy pathclass.atom-template.php
File metadata and controls
63 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace CNP;
class AtomTemplate {
public $name;
public $tag;
public $tag_type;
public $content;
public $attributes;
public $markup;
public $post_object;
public $hide;
public $suppress_filters;
public function __construct( $data ) {
$this->name = isset( $data['name'] ) ? $data['name'] : '';
$this->tag = isset( $data['tag'] ) ? $data['tag'] : '';
$this->tag_type = isset( $data['tag_type'] ) ? $data['tag_type'] : '';
$this->content = isset( $data['content'] ) ? $data['content'] : '';
$this->before = isset( $data['before'] ) ? $data['before'] : '';
$this->after = isset( $data['after'] ) ? $data['after'] : '';
$this->attributes = isset( $data['attributes'] ) ? $data['attributes'] : array();
$this->hide = isset( $data['hide'] ) ? $data['hide'] : false;
$this->suppress_filters = isset( $data['suppress_filters'] ) ? $data['suppress_filters'] : true;
$this->markup = '';
if ( isset( $data['post'] ) ) {
$this->post_object = $data['post'];
} else {
$this->post_object = get_post();
}
// Ensures that the 'class' attribute is set if it wasn't passed in with attributes.
if ( ! isset( $this->attributes['class'] ) ) {
$this->attributes['class'] = array();
}
// Add the Atom name as a class
$this->attributes['class'][] = $this->name;
if ( ! empty( $data['class'] ) ) {
$classes_arr = Utility::parse_classes_as_array( $data['class'] );
if ( ! empty( $classes_arr ) ) {
$this->attributes['class'] = array_merge( $this->attributes['class'], $classes_arr );
}
}
unset( $this->class );
// Filter the Atom properties.
$atom_structure_filter = $this->name . '_properties_filter';
apply_filters( $atom_structure_filter, $this, $data );
Atom::add_debug_entry( 'Filter', $atom_structure_filter );
}
public function get_markup() {
$this->markup = Atom::assemble( $this->name, $this );
}
}