-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfunctions.php
69 lines (57 loc) · 2.22 KB
/
functions.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
<?php
function thedaily_random_featured_records_html($recordType, $featuredRecords)
{
$html = '';
$recordSinglePartial = [
'exhibit' => 'exhibit-builder/exhibits/single.php',
'collection' => 'collections/single.php',
'item' => 'items/single.php',
];
if ($featuredRecords) {
foreach ($featuredRecords as $featuredRecord) {
$html .= get_view()->partial($recordSinglePartial[$recordType], array($recordType => $featuredRecord));
}
}
if ($recordType == 'exhibit') {
$html = apply_filters('exhibit_builder_display_random_featured_exhibit', $html);
}
return $html;
}
function thedaily_get_random_featured_records($record, $num = 0, $hasImage = true)
{
return get_records($record, array('featured' => 1,
'sort_field' => 'random',
'hasImage' => $hasImage), $num);
}
function thedaily_display_featured_records()
{
$recordTypes = ['Exhibit', 'Collection', 'Item'];
$randomRecordCount = 0;
$randomRecordHtml = '';
foreach ($recordTypes as $recordType) {
if ($recordType == 'Exhibit' && !plugin_is_active('ExhibitBuilder')) {
continue;
}
$randomRecords = null;
$randomRecords = thedaily_get_random_featured_records($recordType);
if ((get_theme_option("Display Featured $recordType") !== '0') && ($randomRecords !== null)) {
$randomRecordCount += count($randomRecords);
$randomRecordHtml .= thedaily_random_featured_records_html(strtolower($recordType), $randomRecords);
}
}
$html = '<div id="featured" class="layout-' . $randomRecordCount . '">';
$html .= $randomRecordHtml;
$html .= '</div>';
return $html;
}
function thedaily_get_square_thumbnail_url($file, $view) {
if ($file->hasThumbnail()) {
$squareThumbnail = file_display_url($file, 'square_thumbnail');
} else {
$mimeType = $file->mime_type;
$fileType = (strpos($mimeType, 'image')) ? 'image' : 'video';
$squareThumbnail = $view->baseUrl() . '/application/views/scripts/images/fallback-' . $fileType . '.png';
}
return $squareThumbnail;
}
?>