forked from openarun/hamro-patro-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdateconverter.php
70 lines (53 loc) · 2.01 KB
/
dateconverter.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
<?php
class HamroPatro_DateConverter_Widget extends WP_Widget {
// Main constructor
public function __construct()
{
parent::__construct(
'hamropatro_date_converter_widget',
__('Hamro Patro Date Converter', 'hamro-nepali-patro-calendar'),
array('customize_selective_refresh' => true)
);
}
// The widget form (for the backend )
public function form($instance)
{
// Set widget defaults
$defaults = array(
'title' => ''
);
// Parse current settings with defaults
extract(wp_parse_args((array) $instance, $defaults));?>
<?php // Widget Title ?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title', 'hamro-nepali-patro-calendar');?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
</p>
<?php }
// Update widget settings
public function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = isset($new_instance['title']) ? wp_strip_all_tags($new_instance['title']) : '';
return $instance;
}
// Display the widget
public function widget($args, $instance)
{
extract($args);
// Check the widget options
$title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
// WordPress core before_widget hook (always include )
echo $before_widget;
// Display the widget
echo '<div class="widget-text hamro-patro-dateconverter">';
// Display widget title if defined
if ($title) {
echo $before_title . $title . $after_title;
}
echo do_shortcode('[hamropatro-dateconverter]');
echo '</div>';
// WordPress core after_widget hook (always include )
echo $after_widget;
}
}