-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy paththeme-widgets.php
More file actions
57 lines (53 loc) · 1.3 KB
/
theme-widgets.php
File metadata and controls
57 lines (53 loc) · 1.3 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
<?php
/**
* Extended widgets for the themes
*
* @package Metro
* @since Metro 1.0
*/
/**
* Display a list of the categories as Tiles
*/
class MetroCategoriesWidget extends WP_Widget_Categories
{
public function __construct()
{
parent::WP_Widget(false, "* Metro Category Tiles", "description=" . __("List of categories that will be styled like Metro Tiles", "metro"));
}
public function form($instance)
{
// Content for the widget form
// I'll add a list of categories to exclude in here soon
}
public function update($new_instance, $old_instance)
{
// processes widget options to be saved
}
public function widget($args, $instance)
{
?>
<li id="category_tiles" class="widget-container">
<ul>
<?php
$args = array("orderby" => "name", "order" => "ASC");
$categories = get_categories($args);
foreach ($categories as $category)
{
$class_name = "";
if ($category === end($categories)) $class_name .= "last";
?>
<li class="theme_background <?php echo $class_name; ?>">
<a href="<?php echo get_category_link($category->term_id); ?>" title="<?php _e("View all posts in", "metro"); ?> <?php echo $category->name; ?>">
<span><?php echo $category->name; ?></span>
</a>
</li>
<?php
}
?>
</ul>
<div class="clear"></div>
</li>
<?php
}
}
register_widget("MetroCategoriesWidget");