This repository has been archived by the owner on May 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollapsArchWidget.php
54 lines (50 loc) · 1.74 KB
/
collapsArchWidget.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
<?php
class collapsArchWidget extends WP_Widget {
function collapsArchWidget() {
$widget_ops = array('classname' => 'widget_collapsarch', 'description' =>
'Collapsible archives listing' );
$control_ops = array (
'width' => '400',
'height' => '400'
);
$this->WP_Widget('collapsarch', 'Collapsing Archives', $widget_ops,
$control_ops);
}
function widget($args, $instance) {
extract($args, EXTR_SKIP);
$title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
echo $before_widget . $before_title . $title . $after_title;
$instance['number'] = $this->get_field_id('top');
$instance['number'] = preg_replace('/[a-zA-Z-]/', '', $instance['number']);
echo "<ul id='" . $this->get_field_id('top') .
"' class='collapsing archives list'>\n";
if( function_exists('collapsArch') ) {
collapsArch($instance);
} else {
wp_list_archives();
}
echo "</ul>\n";
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
include('updateOptions.php');
return $instance;
}
function form($instance) {
include('defaults.php');
include('collapsArchStyles.php');
$options=wp_parse_args($instance, $defaults);
extract($options);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
<?php
include('options.txt');
?>
<?php
}
}
function registerCollapsArchWidget() {
register_widget('collapsArchWidget');
}
add_action('widgets_init', 'registerCollapsArchWidget');