PluginProbe
Event Post / 3.9
Event Post v3.9
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
event-post / widget.cal.php

widget.cal.php in Event Post 3.9, at widget.cal.php

146 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /** Articles de catgorie **/
4 class eventpostcal_widget extends WP_Widget {
5 var $defaults;
6 function __construct() {
7 parent::__construct(false, __( 'Events calendar', 'eventpost' ),array('description'=>__( 'Calendar presentation of events posts', 'eventpost' )));
8 $this->defaults = array(
9 'title' => '',
10 'cat' => '',
11 'date' => date('Y-n'),
12 'mf' => 0,
13 'choose' => 1,
14 'colored' => 1,
15 'thumbnail' => 0,
16 'thumbnail_size' => '',
17 );
18 }
19 public function eventpostcal_widget(){
20 $this->__construct();
21 }
22 function widget($args, $local_instance) {
23 extract( $args );
24 $instance = wp_parse_args((array) $local_instance, $this->defaults);
25
26 $date = !empty($instance['date'])?date('Y-n',strtotime(esc_attr($instance['date']))):date('Y-n');
27
28 global $EventPost;
29 $events = $EventPost->get_events(
30 array(
31 'nb'=>-1,
32 'future'=>1,
33 'past'=>1,
34 'geo'=>0,
35 'cat'=>$instance['cat']
36 )
37 );
38 if(count($events)==0){
39 return;
40 }
41 $EventPost->load_scripts();
42 echo $args['before_widget'];
43 if(!empty($title)){
44 echo $args['before_title'];
45 echo $instance['title'];
46 echo $args['after_title'];
47 }
48 echo '<div class="eventpost_calendar" data-cat="'.$instance['cat'].'" data-date="'.$date.'" data-mf="'.$instance['mf'].'" data-dp="'.$instance['choose'].'" data-color="'.$instance['colored'].'" data-thumbnail="'.($instance['thumbnail']?$instance['thumbnail_size']:'').'"></div>';
49 echo $args['after_widget'];
50 }
51
52 function update($new_instance, $old_instance) {
53 return $new_instance;
54 }
55
56 function form($local_instance) {
57 global $EventPost;
58 $instance = wp_parse_args( (array) $local_instance, $this->defaults );
59
60 $cats = get_categories();
61 $thumbnail_sizes = $EventPost->get_thumbnail_sizes();
62 ?>
63 <input type="hidden" id="<?php echo $this->get_field_id('title'); ?>-title" value="<?php echo $instance['title']; ?>">
64 <p>
65 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title','eventpost'); ?>
66 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
67 </label>
68 </p>
69
70 <p>
71 <label for="<?php echo $this->get_field_id('cat'); ?>"><?php _e('Only in :','eventpost'); ?>
72 <select id="<?php echo $this->get_field_id('cat'); ?>" name="<?php echo $this->get_field_name('cat'); ?>">
73 <option value=''><?php _e('All','eventpost') ?></option>
74 <?php foreach($cats as $cat){ ?>
75 <option value="<?php echo $cat->slug; ?>" <?php selected($cat->slug, $instance['cat'], true); ?>><?php echo $cat->cat_name; ?></option>
76 <?php } ?>
77 </select>
78 </label>
79 </p>
80
81 <p>
82 <label for="<?php echo $this->get_field_id('date'); ?>"><?php _e('Date','eventpost'); ?>
83 <select id="<?php echo $this->get_field_id('date'); ?>" name="<?php echo $this->get_field_name('date'); ?>">
84 <option value='' <?php selected($instance['date'], '', true); ?>><?php _e('Current','eventpost'); ?></option>
85 <option value='-1 Month' <?php selected($instance['date'], '-1 Month', true); ?>><?php _e('-1 Month','eventpost'); ?></option>
86 <option value='-2 Months' <?php selected($instance['date'], '-2 Months', true); ?>><?php _e('-2 Months','eventpost'); ?></option>
87 <option value='+1 Month' <?php selected($instance['date'],'+1 Month', true); ?>><?php _e('+1 Month','eventpost'); ?></option>
88 <option value='+2 Months' <?php selected($instance['date'], '+2 Months', true); ?>><?php _e('+2 Months','eventpost'); ?></option>
89 </select>
90 </label>
91 </p>
92
93 <p>
94 <label for="<?php echo $this->get_field_id('mf'); ?>"><?php _e('Weeks start on','eventpost'); ?>
95 <select id="<?php echo $this->get_field_id('mf'); ?>" name="<?php echo $this->get_field_name('mf'); ?>">
96 <option value="0" <?php selected($instance['mf'], 0, true); ?>><?php _e('Sunday','eventpost'); ?></option>
97 <option value="1" <?php selected($instance['mf'], 1, true); ?>><?php _e('Monday','eventpost'); ?></option>
98 </select>
99 </label>
100 </p>
101
102 <p>
103 <label for="<?php echo $this->get_field_id('choose'); ?>"><?php _e('Date picker','eventpost'); ?>
104 <select id="<?php echo $this->get_field_id('choose'); ?>" name="<?php echo $this->get_field_name('choose'); ?>">
105 <option value="0" <?php selected($instance['choose'], 0, true); ?>><?php _e('No','eventpost'); ?></option>
106 <option value="1" <?php selected($instance['choose'], 1, true); ?>><?php _e('Yes','eventpost'); ?></option>
107 </select>
108 </label>
109 </p>
110
111 <p>
112 <label for="<?php echo $this->get_field_id('colored'); ?>"><?php _e('Colored days','eventpost'); ?>
113 <select id="<?php echo $this->get_field_id('colored'); ?>" name="<?php echo $this->get_field_name('colored'); ?>">
114 <option value="0" <?php selected($instance['colored'], 0, true); ?>><?php _e('No','eventpost'); ?></option>
115 <option value="1" <?php selected($instance['colored'], 1, true); ?>><?php _e('Yes','eventpost'); ?></option>
116 </select>
117 </label>
118 </p>
119
120 <p style="margin-top:10px;">
121 <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
122 <input id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" value="1" <?php checked($instance['thumbnail'], true , true); ?>/>
123 <?php _e('Show thumbnails','eventpost'); ?>
124 </label>
125 </p>
126 <p>
127 <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
128 <?php _e('Thumbnail size:','eventpost'); ?>
129 <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>">
130 <option value=''></option>
131 <?php foreach($thumbnail_sizes as $size){?>
132 <option value="<?php echo $size; ?>" <?php selected($size, $instance['thumbnail_size'], true); ?>><?php echo $size; ?></option>
133 <?php } ?>
134 </select>
135 </label>
136 </p>
137 <?php
138 }
139
140 }
141
142 function register_eventpostcal_widget(){
143 register_widget('eventpostcal_widget');
144 }
145
146 add_action('widgets_init', 'register_eventpostcal_widget');