-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cision-block.php
110 lines (107 loc) · 4.07 KB
/
cision-block.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* Template name: Cision Block
*
* Template used to display a feed from Cision.
*
* @var string $id
* String id of block.
* @var string $readmore
* Read more button text.
* @var boolean $mark_regulatory
* Indicates if the items should be marked as regulatory and non-regulatory.
* @var string $regulatory_text
* Text to display for regulatory feed items.
* @var string $non_regulatory_text
* Text to display for non-regulatory feed items.
* @var boolean $show_excerpt
* Display excerpts or not.
* @var boolean $show_filters
* States if we are to display filters for the feed items or not.
* @var string $filter_all_text
* Text for the 'all' filter button.
* @var string $filter_regulatory_text
* Text for the 'regulatory' filter button.
* @var string $filter_non_regulatory_text
* Text for the 'non-regulatory' filter button.
* @var array $cision_feed
* An array of all feed items.
* @var string $pager
* Markup for pager.
* @var array $wrapper_attributes
* Array of attributes for wrapper element.
* @var string $prefix
* String prefix to add to start of wrapper.
* @var string $suffix
* String suffix to add to end of wrapper.
* @var array $attributes
* Array of attributes for article wrapper element.
* @var array $options
* Array of options.
*
* @package Cision Block
* @since 1.0
* @version 2.5.0
*/
?>
<?php if ($cision_feed) : ?>
<section data-block-id="<?php echo $id; ?>"<?php echo $wrapper_attributes; ?>>
<?php echo $prefix; ?>
<?php if ($show_filters) : ?>
<ul class="cision-feed-filters">
<?php if ($filter_all_text !== '<none>') : ?>
<li>
<button class="all">
<?php echo $filter_all_text; ?>
</button>
</li>
<?php endif; ?>
<?php if ($filter_regulatory_text !== '<none>') : ?>
<li>
<button class="regulatory">
<?php echo $filter_regulatory_text; ?>
</button>
</li>
<?php endif; ?>
<?php if ($filter_non_regulatory_text !== '<none>') : ?>
<li>
<button class="non-regulatory">
<?php echo $filter_non_regulatory_text; ?>
</button>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<?php foreach ($cision_feed as $item) : ?>
<article data-regulatory="<?php echo $item->IsRegulatory ?: 0; ?>"<?php echo $attributes; ?>>
<h2><?php echo esc_html($item->Title); ?></h2>
<time><?php echo date($options['date_format'], $item->PublishDate); ?></time>
<?php if ($mark_regulatory && (($item->IsRegulatory && $regulatory_text !== '<none>') || (!$item->IsRegulatory && $non_regulatory_text !== '<none>'))) : ?>
<span class="cision-feed-regulatory"><?php echo $item->IsRegulatory ? $regulatory_text : $non_regulatory_text; ?></span>
<?php endif; ?>
<p>
<?php if (isset($item->Images[0])) : ?>
<span class="cision-feed-item-media">
<img
src="<?php echo esc_url($item->Images[0]->DownloadUrl); ?>"
alt="<?php echo esc_html($item->Images[0]->Description); ?>"
title="<?php echo esc_html($item->Images[0]->Title); ?>"
/>
</span>
<?php endif; ?>
<?php if ($show_excerpt) : ?>
<?php echo wp_trim_words(esc_html($item->Intro ?: $item->Body)); ?>
<?php endif; ?>
</p>
<?php if (isset($item->CisionWireUrl, $readmore)) : ?>
<a
href="<?php echo esc_url($item->CisionWireUrl); ?>"
target="<?php echo $item->LinkTarget; ?>"
><?php echo $readmore; ?></a>
<?php endif; ?>
</article>
<?php endforeach; ?>
<?php echo $pager; ?>
<?php echo $suffix; ?>
</section>
<?php endif; ?>