| 1 |
<?php |
| 2 |
|
| 3 |
/*############################### WIDGET CODE ######################################*/ |
| 4 |
|
| 5 |
class wpdevart_countdown extends WP_Widget { |
| 6 |
private static $id_for_content=0; |
| 7 |
// Constructor // |
| 8 |
function __construct() { |
| 9 |
$widget_ops = array( 'classname' => 'wpdevart_countdown', 'description' => 'Countdown timer for widget ' ); // Widget code |
| 10 |
$control_ops = array( 'id_base' => 'wpdevart_countdown' ); // Widget Controls |
| 11 |
parent::__construct( 'wpdevart_countdown', 'Countdown', $widget_ops, $control_ops ); // Create the widget |
| 12 |
|
| 13 |
} |
| 14 |
|
| 15 |
/* Displaying countdown in the front end*/ |
| 16 |
|
| 17 |
function widget($args, $instance) { |
| 18 |
self::$id_for_content++; |
| 19 |
extract( $args ); |
| 20 |
$title = $instance['title']; |
| 21 |
// Before widget code // |
| 22 |
echo $before_widget; |
| 23 |
if(!isset($instance['font_color'])){ |
| 24 |
$instance['font_color']="#000000"; |
| 25 |
} |
| 26 |
|
| 27 |
// Widget title// |
| 28 |
if ( $title ) { echo $before_title . $title . $after_title; } |
| 29 |
// Widget output // |
| 30 |
echo $this->wpdevart_generete_front_end($instance); |
| 31 |
// After widget part// |
| 32 |
|
| 33 |
echo $after_widget; |
| 34 |
} |
| 35 |
|
| 36 |
/*############################### Update settings Function #######################################*/ |
| 37 |
|
| 38 |
function update($new_instance, $old_instance) { |
| 39 |
extract( $args ); |
| 40 |
$instance['title'] = strip_tags($new_instance['title']); |
| 41 |
$instance['text_for_day'] = $new_instance['text_for_day']; |
| 42 |
$instance['text_for_hour'] = $new_instance['text_for_hour']; |
| 43 |
$instance['text_for_minut'] = $new_instance['text_for_minut']; |
| 44 |
$instance['text_for_second'] = $new_instance['text_for_second']; |
| 45 |
$instance['hide_on_mobile'] = $new_instance['hide_on_mobile']; |
| 46 |
$instance['end_time_type'] = $new_instance['end_time_type']; |
| 47 |
$instance['end_time_date'] = $new_instance['end_time_date']; |
| 48 |
$instance['end_time'] = $new_instance['end_time']; |
| 49 |
$instance['font_color'] = $new_instance['font_color']; |
| 50 |
$instance['start_time'] = $new_instance['start_time']; |
| 51 |
$instance['content'] = $new_instance['content']; |
| 52 |
$instance['action_end_time'] = $new_instance['action_end_time']; |
| 53 |
$instance['redirect_url'] = $new_instance['redirect_url']; |
| 54 |
$instance['content_position'] = $new_instance['content_position']; |
| 55 |
$instance['top_ditance'] = $new_instance['top_ditance']; |
| 56 |
$instance['bottom_distance'] = $new_instance['bottom_distance']; |
| 57 |
return $instance; /// Function that returns parameters new value |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
/* Function of the Admin page standard options */ |
| 62 |
function form($instance) { |
| 63 |
|
| 64 |
$defaults = array( |
| 65 |
'title' => '', |
| 66 |
'text_for_day' => __( 'Days', "wpdevart_countdown" ), |
| 67 |
'text_for_hour' => __( 'Hours', "wpdevart_countdown" ), |
| 68 |
'text_for_minut' => __( 'Minutes', "wpdevart_countdown" ), |
| 69 |
'text_for_second' => __( 'Seconds', "wpdevart_countdown" ), |
| 70 |
'start_time' => mktime (date("H"), date("i"), date("s"),date("n"), date("j"),date("Y")), |
| 71 |
'hide_on_mobile' => 'show', |
| 72 |
'end_time_type' => 'time', |
| 73 |
'end_time' => '0,9,9', |
| 74 |
'end_time_date' => date('d-m-Y 23:59'), |
| 75 |
'font_color' => '#000000', |
| 76 |
'action_end_time' => 'hide', |
| 77 |
'redirect_url' => get_home_url(), |
| 78 |
'content' => '', |
| 79 |
'content_position' => 'center', |
| 80 |
'top_ditance' => '15', |
| 81 |
'bottom_distance' => '15', |
| 82 |
); |
| 83 |
$instance = wp_parse_args( (array) $instance, $defaults ); |
| 84 |
?> |
| 85 |
|
| 86 |
|
| 87 |
<p class="flb_field"> |
| 88 |
<label for="title">Title:</label> |
| 89 |
<br> |
| 90 |
<input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" class="widefat"> |
| 91 |
</p> |
| 92 |
|
| 93 |
<p class="flb_field"> |
| 94 |
<label for="<?php echo $this->get_field_id('text_for_day'); ?>">Day field text:</label> |
| 95 |
<br> |
| 96 |
<input id="<?php echo $this->get_field_id('text_for_day'); ?>" name="<?php echo $this->get_field_name('text_for_day'); ?>" type="text" value="<?php echo $instance['text_for_day']; ?>" class="widefat"> |
| 97 |
</p> |
| 98 |
|
| 99 |
<p class="flb_field"> |
| 100 |
<label for="<?php echo $this->get_field_id('text_for_hour'); ?>">Hour field text:</label> |
| 101 |
<br> |
| 102 |
<input id="<?php echo $this->get_field_id('text_for_hour'); ?>" name="<?php echo $this->get_field_name('text_for_hour'); ?>" type="text" value="<?php echo $instance['text_for_hour']; ?>" class="widefat"> |
| 103 |
</p> |
| 104 |
|
| 105 |
<p class="flb_field"> |
| 106 |
<label for="<?php echo $this->get_field_id('text_for_minut'); ?>">Minute field text:</label> |
| 107 |
<br> |
| 108 |
<input id="<?php echo $this->get_field_id('text_for_minut'); ?>" name="<?php echo $this->get_field_name('text_for_minut'); ?>" type="text" value="<?php echo $instance['text_for_minut']; ?>" class="widefat"> |
| 109 |
</p> |
| 110 |
|
| 111 |
<p class="flb_field"> |
| 112 |
<label for="<?php echo $this->get_field_id('text_for_second'); ?>">Second field text:</label> |
| 113 |
<br> |
| 114 |
<input id="<?php echo $this->get_field_id('text_for_second'); ?>" name="<?php echo $this->get_field_name('text_for_second'); ?>" type="text" value="<?php echo $instance['text_for_second']; ?>" class="widefat"> |
| 115 |
</p> |
| 116 |
|
| 117 |
|
| 118 |
<?php $time_end=explode(',',$instance['end_time']); |
| 119 |
|
| 120 |
if(isset($time_end[0]) && isset($time_end[1]) && isset($time_end[2]) ){ |
| 121 |
$time_diferent_seconds=$time_end[0]*24*3600+$time_end[1]*3600+$time_end[2]*60; |
| 122 |
$ancac_jamanaky=mktime (date("H"), date("i"), date("s"),date("n"), date("j"),date("Y"))-$instance['start_time']; |
| 123 |
$time_diferent_seconds=$time_diferent_seconds-$ancac_jamanaky; |
| 124 |
if($time_diferent_seconds<0) |
| 125 |
$time_diferent_seconds=0; |
| 126 |
} |
| 127 |
else{ |
| 128 |
$time_diferent_seconds=0; |
| 129 |
} |
| 130 |
|
| 131 |
$day_of_end =(int)($time_diferent_seconds/(24*3600)); |
| 132 |
$day_of_end =($day_of_end>=0)?$day_of_end:0; |
| 133 |
$hour_of_end =(int)(($time_diferent_seconds-$day_of_end*24*3600)/3600); |
| 134 |
$hour_of_end =($hour_of_end>=0)?$hour_of_end:0; |
| 135 |
$minute_of_end =(int)(($time_diferent_seconds-$day_of_end*24*3600-$hour_of_end*3600)/60); |
| 136 |
$minute_of_end =($minute_of_end>=0)?$minute_of_end:0; |
| 137 |
|
| 138 |
|
| 139 |
?> |
| 140 |
<script> var countdown_pro_text="If you want to use this feature upgrade to Countdown Pro"</script> |
| 141 |
<style>.pro_feature { |
| 142 |
font-size: 13px; |
| 143 |
font-weight: bold; |
| 144 |
color: rgba(10, 154, 62, 1); |
| 145 |
}</style> |
| 146 |
<p class="experet_type"> |
| 147 |
<label for="<?php echo $this->get_field_id('end_time_type'); ?>">Mobile devices</label> |
| 148 |
<br> |
| 149 |
<select class="show_hide_experet_type" id="<?php echo $this->get_field_id('end_time_type'); ?>" name="<?php echo $this->get_field_name('hide_on_mobile'); ?>"> |
| 150 |
<option <?php selected('show',$instance['hide_on_mobile']) ?> value="show">Show</option> |
| 151 |
<option <?php selected('hide',$instance['hide_on_mobile']) ?> value="hide">Hide</option> |
| 152 |
</select> |
| 153 |
</p> |
| 154 |
<p class="experet_type"> |
| 155 |
<label for="<?php echo $this->get_field_id('end_time_type'); ?>">Countdown date picker type :</label> |
| 156 |
<br> |
| 157 |
<select class="show_hide_experet_type" id="<?php echo $this->get_field_id('end_time_type'); ?>" name="<?php echo $this->get_field_name('end_time_type'); ?>"> |
| 158 |
<option <?php selected('time',$instance['end_time_type']) ?> value="time">Time</option> |
| 159 |
<option <?php selected('date',$instance['end_time_type']) ?> value="date">Date</option> |
| 160 |
</select> |
| 161 |
</p> |
| 162 |
<p class="experet_type_date"> |
| 163 |
<label>Countdown expiry date :</label> |
| 164 |
<br> |
| 165 |
<input type="text" id="<?php echo $this->get_field_id('end_time_date'); ?>" name="<?php echo $this->get_field_name('end_time_date'); ?>" value="<?php echo $instance['end_time_date'] ?>" class="wpdevart-date-time-picker" /><small>dd-mm-yyyy hh:ii</small> |
| 166 |
</p> |
| 167 |
<p class="flb_field experet_type_time"> |
| 168 |
<label>Countdown expire time: </label> |
| 169 |
<br> |
| 170 |
<span style="display:inline-block; margin-right:3px; width:70px; float: left;"> |
| 171 |
<input onChange="insert_in_input();" type="text" placeholder="Day" class="countdownday" size="3" value="<?php echo $day_of_end ?>"/><small style="display:block">Day</small> |
| 172 |
</span> |
| 173 |
|
| 174 |
<span style="display:inline-block; width:72px; float: left;"> |
| 175 |
<input onChange="insert_in_input();" type="text" placeholder="Hour" class="countdownhour" size="3" value="<?php echo $hour_of_end ?>"/><small>Hour</small> |
| 176 |
</span> |
| 177 |
|
| 178 |
<span style="display:inline-block; width:70px;"> |
| 179 |
<input onChange="insert_in_input();" type="text" placeholder="Minute" class="countdownminute" size="3" value="<?php echo $minute_of_end ?>"/><small>Minute</small> |
| 180 |
</span> |
| 181 |
<script>function insert_in_input(){ |
| 182 |
document.getElementById('<?php echo $this->get_field_id('end_time'); ?>').value=document.getElementById('<?php echo $this->get_field_id('end_time'); ?>').parentNode.getElementsByClassName('countdownday')[0].value+','+document.getElementById('<?php echo $this->get_field_id('end_time'); ?>').parentNode.getElementsByClassName('countdownhour')[0].value+','+document.getElementById('<?php echo $this->get_field_id('end_time'); ?>').parentNode.getElementsByClassName('countdownminute')[0].value |
| 183 |
}</script> |
| 184 |
<input type="hidden" value='<?php echo $day_of_end.','.$hour_of_end.','.$minute_of_end; ?>' id="<?php echo $this->get_field_id('end_time'); ?>" name="<?php echo $this->get_field_name('end_time'); ?>"/> |
| 185 |
<input type="hidden" value='<?php echo mktime (date("H"), date("i"), date("s"),date("n"), date("j"),date("Y")); ?>' id="<?php echo $this->get_field_id('start_time'); ?>" name="<?php echo $this->get_field_name('start_time'); ?>" /> |
| 186 |
</p> |
| 187 |
|
| 188 |
<p class="flb_field"> |
| 189 |
<label>After Countdown expire: </label> |
| 190 |
<br> |
| 191 |
<select id="<?php echo $this->get_field_id('action_end_time'); ?>" name="<?php echo $this->get_field_name('action_end_time'); ?>"> |
| 192 |
<option <?php selected('show_text',$instance['action_end_time']) ?> value="show_text">Show text</option> |
| 193 |
<option <?php selected('redirect',$instance['action_end_time']) ?> value="redirect">Redirect</option> |
| 194 |
<option <?php selected('hide',$instance['action_end_time']) ?> value="hide">Hide Timer</option> |
| 195 |
</select> |
| 196 |
</p> |
| 197 |
|
| 198 |
<p class="flb_field"> |
| 199 |
<label for="<?php echo $this->get_field_id('content'); ?>">Text after countdown expire:</label> |
| 200 |
<br> |
| 201 |
<textarea type="text" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo $instance['content']; ?></textarea> |
| 202 |
</p> |
| 203 |
<p class="flb_field"> |
| 204 |
<label for="<?php echo $this->get_field_id('redirect_url'); ?>">Redirect URL:</label> |
| 205 |
<br> |
| 206 |
<input id="<?php echo $this->get_field_id('redirect_url'); ?>" name="<?php echo $this->get_field_name('redirect_url'); ?>" type="text" value="<?php echo $instance['redirect_url']; ?>" class="widefat"> |
| 207 |
</p> |
| 208 |
|
| 209 |
<p class="flb_field"> |
| 210 |
<label>Countdown position: </label> |
| 211 |
<br> |
| 212 |
<select id="<?php echo $this->get_field_id('content_position'); ?>" name="<?php echo $this->get_field_name('content_position'); ?>"> |
| 213 |
<option <?php selected('left',$instance['content_position']) ?> value="left">Left</option> |
| 214 |
<option <?php selected('center',$instance['content_position']) ?> value="center">Center</option> |
| 215 |
<option <?php selected('right',$instance['content_position']) ?> value="right">Right</option> |
| 216 |
</select> |
| 217 |
</p> |
| 218 |
|
| 219 |
<p class="flb_field"> |
| 220 |
<label for="<?php echo $this->get_field_id('top_ditance'); ?>">Countdown distance from top:</label> |
| 221 |
<br> |
| 222 |
<input id="<?php echo $this->get_field_id('top_ditance'); ?>" name="<?php echo $this->get_field_name('top_ditance'); ?>" type="text" value="<?php echo $instance['top_ditance']; ?>" class="widefat"> |
| 223 |
</p> |
| 224 |
|
| 225 |
<p class="flb_field"> |
| 226 |
<label for="<?php echo $this->get_field_id('bottom_distance'); ?>">Countdown distance from bottom:</label> |
| 227 |
<br> |
| 228 |
<input id="<?php echo $this->get_field_id('bottom_distance'); ?>" name="<?php echo $this->get_field_name('bottom_distance'); ?>" type="text" value="<?php echo $instance['bottom_distance']; ?>" class="widefat"> |
| 229 |
</p> |
| 230 |
|
| 231 |
<p class="flb_field"> |
| 232 |
<label>Countdown Buttons type:<span class="pro_feature"> (pro)</span> </label> |
| 233 |
<br> |
| 234 |
<select onChange="alert(countdown_pro_text)"> |
| 235 |
<option selected="selected" value="button">Button</option> |
| 236 |
<option value="circle">Circle</option> |
| 237 |
<option value="vertical_slide">Vertical Slider</option> |
| 238 |
</select> |
| 239 |
</p> |
| 240 |
|
| 241 |
<p class="flb_field tr_button tr_circle tr_vertical_slide"> |
| 242 |
<label for="<?php echo $this->get_field_id('font_color'); ?>">Countdown timer text color:</label> |
| 243 |
<br> |
| 244 |
<input class="color_option" id="<?php echo $this->get_field_id('font_color'); ?>" name="<?php echo $this->get_field_name('font_color'); ?>" type="text" value="<?php echo $instance['font_color']; ?>"> |
| 245 |
</p> |
| 246 |
|
| 247 |
<p class="flb_field tr_button tr_circle tr_vertical_slide"> |
| 248 |
<label> Countdown background color:<span class="pro_feature"> (pro)</span></label> |
| 249 |
<br> |
| 250 |
<div onClick="alert(countdown_pro_text)"> |
| 251 |
<div class="wp-picker-container disabled_picker"> |
| 252 |
<button type="button" class="button wp-color-result" aria-expanded="false" style="background-color: rgb(62, 89, 165);"><span class="wp-color-result-text">Select Color</span></button> |
| 253 |
</div> |
| 254 |
</div> |
| 255 |
</p> |
| 256 |
|
| 257 |
<p class="flb_field tr_circle"> |
| 258 |
<label >Countdown timer size:<span class="pro_feature"> (pro)</span></label> |
| 259 |
<br> |
| 260 |
<input onClick="alert(countdown_pro_text)" type="text" value="50" class="widefat">(Px) |
| 261 |
</p> |
| 262 |
|
| 263 |
<p class="flb_field tr_circle"> |
| 264 |
<label>Countdown border width:<span class="pro_feature"> (pro)</span></label> |
| 265 |
<br> |
| 266 |
<input onClick="alert(countdown_pro_text)" type="text" value="5" class="widefat">%(0-100) |
| 267 |
</p> |
| 268 |
|
| 269 |
<p class="flb_field tr_button"> |
| 270 |
<label>Countdown border radius:<span class="pro_feature"> (pro)</span></label> |
| 271 |
<br> |
| 272 |
<input onClick="alert(countdown_pro_text)" type="text" value="8" class="widefat"> |
| 273 |
</p> |
| 274 |
|
| 275 |
<p class="flb_field tr_button tr_vertical_slide"> |
| 276 |
<label>Countdown font-size:<span class="pro_feature"> (pro)</span></label> |
| 277 |
<br> |
| 278 |
<input onClick="alert(countdown_pro_text)" type="text" value="20" class="widefat">(Px) |
| 279 |
</p> |
| 280 |
|
| 281 |
<p class="flb_field tr_button tr_circle tr_vertical_slide"> |
| 282 |
<label>Countdown Font family:<span class="pro_feature"> (pro)</span></label> |
| 283 |
<br> |
| 284 |
<?php wpdevart_countdown_setting::generete_fonts('font_famely','monospace') ?> |
| 285 |
</p> |
| 286 |
<p class="flb_field"> |
| 287 |
<label for="animation">Countdown animation type:<span class="pro_feature"> (pro)</span></label> |
| 288 |
<br> |
| 289 |
<?php wpdevart_countdown_setting::generete_animation_select('animation','monospace') ?> |
| 290 |
</p> |
| 291 |
<br> |
| 292 |
<input type="hidden" id="flb-submit" name="flb-submit" value="1"> |
| 293 |
<script> |
| 294 |
jQuery(".color_option").ready(function(e) { |
| 295 |
jQuery(".color_option").each(function(index, element) { |
| 296 |
if(!jQuery(this).hasClass('wp-color-picker') && jQuery(this).attr('name').indexOf('__i__')==-1){jQuery(this).wpColorPicker()}; |
| 297 |
}); |
| 298 |
|
| 299 |
}); |
| 300 |
jQuery('.wpdevart-date-time-picker').ready(function(){ |
| 301 |
var nowTemp = new Date(); |
| 302 |
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); |
| 303 |
jQuery('.wpdevart-date-time-picker').fdatepicker({ |
| 304 |
format: 'dd-mm-yyyy hh:ii', |
| 305 |
pickTime: true, |
| 306 |
onRender: function (date) { |
| 307 |
return date.valueOf() < now.valueOf() ? 'disabled' : ''; |
| 308 |
} |
| 309 |
}); |
| 310 |
}); |
| 311 |
jQuery('.show_hide_experet_type').ready(function(){ |
| 312 |
jQuery('.show_hide_experet_type').each(function(index, element) { |
| 313 |
if(jQuery(this).val()=='time'){ |
| 314 |
jQuery(this).parent().parent().find(jQuery('.experet_type_date')).hide(); |
| 315 |
jQuery(this).parent().parent().find(jQuery('.experet_type_time')).show(); |
| 316 |
} |
| 317 |
if(jQuery(this).val()=='date'){ |
| 318 |
jQuery(this).parent().parent().find(jQuery('.experet_type_date')).show(); |
| 319 |
jQuery(this).parent().parent().find(jQuery('.experet_type_time')).hide(); |
| 320 |
} |
| 321 |
}); |
| 322 |
jQuery('.show_hide_experet_type').change(function(){ |
| 323 |
if(jQuery(this).val()=='time'){ |
| 324 |
jQuery(this).parent().parent().find(jQuery('.experet_type_date')).hide(); |
| 325 |
jQuery(this).parent().parent().find(jQuery('.experet_type_time')).show(); |
| 326 |
} |
| 327 |
if(jQuery(this).val()=='date'){ |
| 328 |
jQuery(this).parent().parent().find(jQuery('.experet_type_date')).show(); |
| 329 |
jQuery(this).parent().parent().find(jQuery('.experet_type_time')).hide(); |
| 330 |
} |
| 331 |
}) |
| 332 |
}) |
| 333 |
</script> |
| 334 |
<a href="http://wpdevart.com/wordpress-countdown-plugin/" target="_blank" style="color: rgba(10, 154, 62, 1);; font-weight: bold; font-size: 18px; text-decoration: none;">Upgrade to Pro Version</a> |
| 335 |
<?php |
| 336 |
} |
| 337 |
|
| 338 |
/*############################### Function for generating front-end ########################################*/ |
| 339 |
|
| 340 |
private function wpdevart_generete_front_end($parametrs){ |
| 341 |
self::$id_for_content++; |
| 342 |
$output_html=''; |
| 343 |
if($parametrs['hide_on_mobile']=="hidee" && wp_is_mobile()){ |
| 344 |
return ""; |
| 345 |
} |
| 346 |
if(isset($parametrs['end_time_type']) && $parametrs['end_time_type']=='date'){ |
| 347 |
$end_date=explode(' ',$parametrs['end_time_date']); |
| 348 |
$end_date_only_date=explode('-',$end_date[0]); |
| 349 |
$end_date_hour=explode(':',$end_date[1]); |
| 350 |
$curent_time=mktime ($end_date_hour['0'], $end_date_hour[1],0,$end_date_only_date[1], $end_date_only_date[0],$end_date_only_date[2]); |
| 351 |
$time_diferent=$curent_time-mktime (date("H"), date("i"), date("s"),date("n"), date("j"),date("Y")); |
| 352 |
}else{ |
| 353 |
$time_experit=explode(',',$parametrs['end_time']); |
| 354 |
$time_diferent=(int)$time_experit[0]*24*3600+(int)+$time_experit[1]*3600+(int)$time_experit[2]*60+$parametrs['start_time']-mktime (date("H"), date("i"), date("s"),date("n"), date("j"),date("Y")); |
| 355 |
} |
| 356 |
$day_left=(int)($time_diferent/(3600*24)); |
| 357 |
$hourse_left=(int)(($time_diferent-$day_left*24*3600)/(3600)); |
| 358 |
$minuts_left=(int)(($time_diferent-$day_left*24*3600-$hourse_left*3600)/(60)); |
| 359 |
$seconds_left=(int)(($time_diferent-$day_left*24*3600-$hourse_left*3600 - $minuts_left*60)); |
| 360 |
if(strlen("".$day_left)>0 && strlen("".$day_left)<2) |
| 361 |
$day_left='0'.$day_left; |
| 362 |
if(strlen("".$hourse_left)>0 && strlen("".$hourse_left)<2) |
| 363 |
$hourse_left='0'.$hourse_left; |
| 364 |
if(strlen("".$minuts_left)>0 && strlen("".$minuts_left)<2) |
| 365 |
$minuts_left='0'.$minuts_left; |
| 366 |
if(strlen("".$seconds_left)>0 && strlen("".$seconds_left)<2) |
| 367 |
$seconds_left='0'.$seconds_left; |
| 368 |
|
| 369 |
$output_html.='<div class="content_countdown" id="main_countedown_widget_'.self::$id_for_content.'">'; |
| 370 |
$output_html.='<div class="countdown"> |
| 371 |
<span class="element_conteiner"><span class="days time_left">'.$day_left.'</span><span class="time_description">'.$parametrs['text_for_day'].'</span></span> |
| 372 |
<span class="element_conteiner"><span class="hourse time_left">'.$hourse_left.'</span><span class="time_description">'.$parametrs['text_for_hour'].'</span></span> |
| 373 |
<span class="element_conteiner"><span class="minutes time_left">'.$minuts_left.'</span><span class="time_description">'.$parametrs['text_for_minut'].'</span></span> |
| 374 |
<span class="element_conteiner"><span class="secondes time_left">'.$seconds_left.'</span><span class="time_description">'.$parametrs['text_for_second'].'</span></span> |
| 375 |
</div>'; |
| 376 |
$output_html.='</div>'; |
| 377 |
|
| 378 |
/************************** JS Output Code ************************************/ |
| 379 |
$output_js=''; |
| 380 |
|
| 381 |
$output_js_code=''; |
| 382 |
|
| 383 |
if(($day_left<=0 && $hourse_left<=0 && $minuts_left<=0 && $seconds_left<=0)){ |
| 384 |
if($parametrs['action_end_time']=='redirect'){ |
| 385 |
$output_js_code="window.location.replace('".$parametrs['redirect_url']."')"; |
| 386 |
} |
| 387 |
elseif($parametrs['action_end_time']=='show_text'){ |
| 388 |
$output_js_code="jQuery('#main_countedown_widget_".self::$id_for_content." .countdown').html('".htmlspecialchars($parametrs['content'])."')"; |
| 389 |
} |
| 390 |
else{ |
| 391 |
$output_js_code="jQuery('#main_countedown_widget_".self::$id_for_content." .countdown').html('')"; |
| 392 |
} |
| 393 |
}else{ |
| 394 |
$output_js_code="setInterval(function(){countdown_wpdevart_timer('main_countedown_widget_".self::$id_for_content."');},1000);"; |
| 395 |
|
| 396 |
} |
| 397 |
$output_js.=" |
| 398 |
document.addEventListener('DOMContentLoaded', function(event) { |
| 399 |
".$output_js_code." |
| 400 |
});"; |
| 401 |
|
| 402 |
/************************** CSS Output Code ***********************************/ |
| 403 |
|
| 404 |
$output_css=''; |
| 405 |
$output_css.='#main_countedown_widget_'.self::$id_for_content.' .countdown{text-align:'.$parametrs['content_position'].';}'; |
| 406 |
$output_css.= '#main_countedown_widget_'.self::$id_for_content.' .countdown{margin-top:'.$parametrs['top_ditance'].'px;margin-bottom:'.$parametrs['bottom_distance'].'px}'; |
| 407 |
$output_css.= "#main_countedown_widget_".self::$id_for_content." .time_left{\r\n"; |
| 408 |
$output_css.= "border-radius:8px;\r\n"; |
| 409 |
$output_css.= "background-color:#3DA8CC;\r\n"; |
| 410 |
$output_css.= "font-size:20px;\r\n"; |
| 411 |
$output_css.= "font-family:monospace;\r\n"; |
| 412 |
$output_css.= "color:".$parametrs['font_color'].";\r\n"; |
| 413 |
$output_css.= "}\r\n"; |
| 414 |
$output_css.= "#main_countedown_widget_".self::$id_for_content." .time_description{\r\n"; |
| 415 |
$output_css.= "font-size:20px;\r\n"; |
| 416 |
$output_css.= "font-family:monospace;\r\n"; |
| 417 |
$output_css.= "color:".$parametrs['font_color'].";\r\n"; |
| 418 |
$output_css.= "}\r\n"; |
| 419 |
$output_css.= "#main_countedown_widget_".self::$id_for_content." .element_conteiner{min-width:73px}"; |
| 420 |
$output_html.='<script>'.$output_js.'</script><style>'.$output_css.'</style>'; |
| 421 |
return $output_html; |
| 422 |
} |
| 423 |
} |
| 424 |
|