| @@ -17,9 +17,9 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * Plugin Name: iCalendrier |
| 19 | 19 | * Plugin URI: https://icalendrier.fr/widget/wordpress-plugin |
| 20 | 20 | * Description: Un simple calendrier qui affiche des infos du jour, comme le numéro de semaine, la date, la fête du jour et la phase de lune. |
| 21 | - * Version: 1.75 | |
| 21 | + * Version: 1.80 | |
| 22 | 22 | * Author: Baptiste Placé |
| 23 | 23 | * Author URI: https://icalendrier.fr/ |
| 24 | 24 | * License: GNU General Public License, version 2 |
| 25 | 25 | */ |
| @@ -59,22 +59,24 @@ | ||
| 59 | 59 | * @return array |
| 60 | 60 | */ |
| 61 | 61 | function getAttibutes($atts) |
| 62 | 62 | { |
| 63 | - $calType = isset($atts['type']) ? $atts['type'] : 'comp175'; | |
| 64 | - $language = isset($atts['language']) ? $atts['language'] : 'en'; | |
| 65 | - $timezone = isset($atts['timezone']) ? $atts['timezone'] : 0; | |
| 66 | - $showLink = ((isset($atts['showLink']) AND $atts['showLink'] == 'on') OR ! isset($atts['showLink'])) ? 1 : 0; | |
| 67 | - $bgColor = isset($atts['bgColor']) ? $atts['bgColor'] : false; | |
| 68 | - $style = isset($atts['style']) ? $atts['style'] : 'default'; | |
| 63 | + $calType = isset($atts['type']) ? $atts['type'] : 'comp175'; | |
| 64 | + $language = isset($atts['language']) ? $atts['language'] : 'en'; | |
| 65 | + $timezone = isset($atts['timezone']) ? $atts['timezone'] : 0; | |
| 66 | + $showLink = ((isset($atts['showLink']) and $atts['showLink'] == 'on') or ! isset($atts['showLink'])) ? 1 : 0; | |
| 67 | + $bgColor = isset($atts['bgColor']) ? $atts['bgColor'] : false; | |
| 68 | + $style = isset($atts['style']) ? $atts['style'] : 'default'; | |
| 69 | + $widgetTitle = isset($atts['widgetTitle']) ? $atts['widgetTitle'] : ''; | |
| 69 | 70 | |
| 70 | 71 | return [ |
| 71 | - 'calType' => $calType, | |
| 72 | - 'language' => $language, | |
| 73 | - 'timezone' => $timezone, | |
| 74 | - 'showLink' => $showLink, | |
| 75 | - 'bgColor' => $bgColor, | |
| 76 | - 'style' => $style | |
| 72 | + 'calType' => $calType, | |
| 73 | + 'language' => $language, | |
| 74 | + 'timezone' => $timezone, | |
| 75 | + 'showLink' => $showLink, | |
| 76 | + 'bgColor' => $bgColor, | |
| 77 | + 'style' => $style, | |
| 78 | + 'widgetTitle' => $widgetTitle | |
| 77 | 79 | ]; |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | |
| @@ -86,11 +88,11 @@ | ||
| 86 | 88 | |
| 87 | 89 | $iCalendrier = new Icalendrier($attributes['language'], $attributes['timezone']); |
| 88 | 90 | |
| 89 | 91 | if ('comp175' === $attributes['calType']) { |
| 90 | - echo $iCalendrier->iCalendrierComp($attributes); | |
| 92 | + return $iCalendrier->iCalendrierComp($attributes); | |
| 91 | 93 | } elseif ('wide300' === $attributes['calType']) { |
| 92 | - echo $iCalendrier->iCalendrierWide($attributes); | |
| 94 | + return $iCalendrier->iCalendrierWide($attributes); | |
| 93 | 95 | } |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | |
| @@ -127,11 +129,21 @@ | ||
| 127 | 129 | extract($args); |
| 128 | 130 | |
| 129 | 131 | $attributes = getAttibutes($instance); |
| 130 | 132 | |
| 133 | + if (empty($widgetTitle)) { | |
| 134 | + $widgetTitle = isset($attributes['widgetTitle']) ? $attributes['widgetTitle'] : ''; | |
| 135 | + } | |
| 136 | + | |
| 131 | 137 | echo $before_widget; |
| 132 | 138 | |
| 133 | - if ($widgetTitle != "") { | |
| 139 | + if (isset($widgetTitle) && $widgetTitle != "") { | |
| 140 | + if ( ! isset($before_title)) { | |
| 141 | + $before_title = ""; | |
| 142 | + } | |
| 143 | + if ( ! isset($after_title)) { | |
| 144 | + $after_title = ""; | |
| 145 | + } | |
| 134 | 146 | echo $before_title . $widgetTitle . $after_title; |
| 135 | 147 | } |
| 136 | 148 | |
| 137 | 149 | $iCalendrier = new Icalendrier($attributes['language'], $attributes['timezone']); |
| @@ -158,9 +170,9 @@ | ||
| 158 | 170 | $instance['language'] = strip_tags($new_instance['language']); |
| 159 | 171 | $instance['timezone'] = strip_tags($new_instance['timezone']); |
| 160 | 172 | $instance['widgetTitle'] = strip_tags($new_instance['widgetTitle']); |
| 161 | 173 | $instance['bgColor'] = strip_tags($new_instance['bgColor']); |
| 162 | - $instance['showLink'] = ((isset($instance['showLink']) AND $instance['showLink'] == 'on') OR ! isset($instance['showLink'])) ? 1 : 0; | |
| 174 | + $instance['showLink'] = ((isset($instance['showLink']) and $instance['showLink'] == 'on') or ! isset($instance['showLink'])) ? 1 : 0; | |
| 163 | 175 | $instance['style'] = strip_tags($new_instance['style']); |
| 164 | 176 | |
| 165 | 177 | return $instance; |
| 166 | 178 | } |
| @@ -173,9 +185,9 @@ | ||
| 173 | 185 | $type = isset($instance['type']) ? esc_attr($instance['type']) : "comp175"; |
| 174 | 186 | $language = isset($instance['language']) ? esc_attr($instance['language']) : "en"; |
| 175 | 187 | $timezone = isset($instance['timezone']) ? esc_attr($instance['timezone']) : 5; |
| 176 | 188 | $widgetTitle = isset($instance['widgetTitle']) ? esc_attr($instance['widgetTitle']) : ""; |
| 177 | - $showLink = ((isset($instance['showLink']) AND $instance['showLink'] == 'on') OR ! isset($instance['showLink'])) ? 1 : 0; | |
| 189 | + $showLink = ((isset($instance['showLink']) and $instance['showLink'] == 'on') or ! isset($instance['showLink'])) ? 1 : 0; | |
| 178 | 190 | $bgColor = isset($instance['bgColor']) ? esc_attr($instance['bgColor']) : ""; |
| 179 | 191 | $style = isset($instance['style']) ? esc_attr($instance['style']) : "default"; |
| 180 | 192 | ?> |
| 181 | 193 | |
| @@ -272,9 +284,10 @@ | ||
| 272 | 284 | </p> |
| 273 | 285 | |
| 274 | 286 | <p> |
| 275 | 287 | <label for="<?php echo $this->get_field_id('showLink'); ?>"><?php _e('MOD_ICAL_SHOWLINK_LABEL', 'icalendrier'); ?></label> |
| 276 | - <input id="<?php echo $this->get_field_id('showLink'); ?>" name="<?php echo $this->get_field_name('showLink'); ?>" type="checkbox" <?php if ($showLink) { | |
| 288 | + <input id="<?php echo $this->get_field_id('showLink'); ?>" name="<?php echo $this->get_field_name('showLink'); ?>" | |
| 289 | + type="checkbox" <?php if ($showLink) { | |
| 277 | 290 | echo ' checked="checked"'; |
| 278 | 291 | } ?> /> |
| 279 | 292 | </p> |
| 280 | 293 | |
| @@ -279,15 +292,17 @@ | ||
| 279 | 292 | </p> |
| 280 | 293 | |
| 281 | 294 | <p> |
| 282 | 295 | <label for="<?php echo $this->get_field_id('widgetTitle'); ?>"><?php _e('MOD_ICAL_WIDGET_TITLE_LABEL', 'icalendrier'); ?></label> |
| 283 | - <input class="widefat" id="<?php echo $this->get_field_id('widgetTitle'); ?>" name="<?php echo $this->get_field_name('widgetTitle'); ?>" type="text" | |
| 296 | + <input class="widefat" id="<?php echo $this->get_field_id('widgetTitle'); ?>" name="<?php echo $this->get_field_name('widgetTitle'); ?>" | |
| 297 | + type="text" | |
| 284 | 298 | value="<?php echo $widgetTitle; ?>"/> |
| 285 | 299 | </p> |
| 286 | 300 | |
| 287 | 301 | <p> |
| 288 | 302 | <label for="<?php echo $this->get_field_id('bgColor'); ?>"><?php _e('MOD_ICAL_BGCOLOR_LABEL', 'icalendrier'); ?></label><br/> |
| 289 | - <input class="widefat" id="<?php echo $this->get_field_id('bgColor'); ?>" name="<?php echo $this->get_field_name('bgColor'); ?>" type="text" | |
| 303 | + <input class="widefat" id="<?php echo $this->get_field_id('bgColor'); ?>" name="<?php echo $this->get_field_name('bgColor'); ?>" | |
| 304 | + type="text" | |
| 290 | 305 | value="<?php echo $bgColor; ?>"/> |
| 291 | 306 | </p> |
| 292 | 307 | |
| 293 | 308 | <?php |