-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemsPartialShortcodePlugin.php
More file actions
73 lines (56 loc) · 1.77 KB
/
ItemsPartialShortcodePlugin.php
File metadata and controls
73 lines (56 loc) · 1.77 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
64
65
66
67
68
69
70
71
72
73
<?php
class ItemsPartialShortcodePlugin extends Omeka_Plugin_AbstractPlugin {
protected $_hooks = array('initialize');
public function hookInitialize()
{
add_shortcode('itemspartial', array($this, 'shortcodeItemsPartial'));
}
public function shortcodeItemsPartial($args, $view)
{
$params = array();
if (isset($args['is_featured'])) {
$params['featured'] = $args['is_featured'];
}
if (isset($args['has_image'])) {
$params['hasImage'] = $args['has_image'];
}
if (isset($args['collection'])) {
$params['collection'] = $args['collection'];
}
if (isset($args['item_type'])) {
$params['item_type'] = $args['item_type'];
}
if (isset($args['tags'])) {
$params['tags'] = $args['tags'];
}
if (isset($args['user'])) {
$params['user'] = $args['user'];
}
if (isset($args['ids'])) {
$params['range'] = $args['ids'];
}
if (isset($args['sort'])) {
$params['sort_field'] = $args['sort'];
}
if (isset($args['order'])) {
$params['sort_dir'] = $args['order'];
}
if (isset($args['template'])) {
$params['template'] = $args['template'];
} else {
$params['template'] = 'single';
}
if (isset($args['num'])) {
$limit = $args['num'];
} else {
$limit = 10;
}
$items = get_records('Item', $params, $limit);
$content = '';
foreach ($items as $item) {
$content .= $view->partial('items/' . $params['template'] . '.php', array('item' => $item));
}
return $content;
}
}
?>