T(-) Countdown - Version 2.0.1

Version Description

  • Verify that a style has been set before looping - was throwing an error.
  • Inproved loadtimes by printing all javascript in the footer
  • Workaround for strange behavor with html content sent using shortcode
Download this release

Release Info

Developer baden03
Plugin Icon 128x128 T(-) Countdown
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

Files changed (2) hide show
  1. countdown-timer.php +90 -61
  2. readme.txt +10 -2
countdown-timer.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: jQuery T(-) Countdown - v2.0
4
  Plugin URI: http://www.twinpictures.de/jquery-t-minus-2-0/
5
  Description: Display and configure multiple jQuery countdown timers using a shortcode or as a sidebar widget.
6
- Version: 2.0
7
  Author: Twinpictures
8
  Author URI: http://www.twinpictures.de
9
  License: GPL2
@@ -70,9 +70,11 @@ function countdown_style(){
70
  //$styleizer = array('carbonite','darth','jedi');
71
  $styleizer = get_option('t-minus_styles');
72
  $plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
73
- foreach($styleizer as $style){
74
- wp_register_style( 'countdown-'.$style.'-css', $plugin_url.'/css/'.$style.'/style.css', array (), '1.1' );
75
- wp_enqueue_style( 'countdown-'.$style.'-css' );
 
 
76
  }
77
  }
78
 
@@ -92,8 +94,8 @@ class CountDownTimer extends WP_Widget {
92
 
93
  /** Widget */
94
  function widget($args, $instance) {
 
95
  extract( $args );
96
-
97
  //insert some style into your life
98
  $style = empty($instance['style']) ? 'jedi' : apply_filters('widget_style', $instance['style']);
99
  //$styleizer[$style] = $style;
@@ -186,7 +188,7 @@ class CountDownTimer extends WP_Widget {
186
  echo $before_title . $title . $after_title;
187
  }
188
  echo '<div id="'.$args['widget_id'].'-widget">';
189
- echo '<div id="'.$args['widget_id'].'-tophtml" class="'.$style.'-tophtml">';
190
  if($tophtml){
191
  echo $tophtml;
192
  }
@@ -268,33 +270,23 @@ class CountDownTimer extends WP_Widget {
268
  else if($launchtarget == "Entire Widget"){
269
  $launchdiv = "widget";
270
  }
271
- ?>
272
- <script language="javascript" type="text/javascript">
273
- jQuery(document).ready(function() {
274
- //only trigger the countdown if one actually exists.
275
- if(jQuery('#<?php echo $args['widget_id']; ?>-dashboard').length){
276
- //alert('Clock <?php echo $args['widget_id']; ?>-dashboard is Tickin, Dude.');
277
- jQuery('#<?php echo $args['widget_id']; ?>-dashboard').countDown({
278
- targetDate: {
279
- 'day': <?php echo $day; ?>,
280
- 'month': <?php echo $month; ?>,
281
- 'year': <?php echo $year; ?>,
282
- 'hour': <?php echo $hour; ?>,
283
- 'min': <?php echo $min; ?>,
284
- 'sec': <?php echo $sec; ?>,
285
- 'localtime': '<?php echo $t; ?>',
286
- },
287
- style: '<?php echo $style; ?>',
288
- omitWeeks: <?php echo $omitweeks;
289
- if($launchhtml){
290
- echo ", onComplete: function() { jQuery('#".$args['widget_id']."-".$launchdiv."').html('".do_shortcode($launchhtml)."'); }";
291
- }
292
- ?>
293
- });
294
- }
295
- });
296
- </script>
297
- <?php
298
  }
299
 
300
  /** Update */
@@ -470,7 +462,51 @@ class CountDownTimer extends WP_Widget {
470
  add_action('widgets_init', create_function('', 'return register_widget("CountDownTimer");'));
471
 
472
  //the short code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  function tminuscountdown($atts, $content=null) {
 
474
  //find a random number, incase there is no id assigned
475
  $ran = rand(1, 10000);
476
 
@@ -493,6 +529,7 @@ function tminuscountdown($atts, $content=null) {
493
  'launchtarget' => 'countdown',
494
  ), $atts));
495
 
 
496
  //update the styles
497
  $style_arr = get_option('t-minus_styles');
498
  $style_arr[$style] = $style;
@@ -616,40 +653,32 @@ function tminuscountdown($atts, $content=null) {
616
  $tminus .= '</div></div>';
617
 
618
  $t = date( 'n/j/Y H:i:s', gmmktime() + ( get_option( 'gmt_offset' ) * 3600));
 
619
  if(is_numeric($launchwidth)){
620
  $launchwidth .= 'px';
621
  }
622
  if(is_numeric($launchheight)){
623
  $launchheight .= 'px';
624
  }
625
- ?>
626
- <script language="javascript" type="text/javascript">
627
- jQuery(document).ready(function() {
628
- //only trigger the countdown if one actually exists.
629
- if(jQuery('#<?php echo $id; ?>-dashboard').length){
630
- jQuery('#<?php echo $id; ?>-dashboard').countDown({
631
- targetDate: {
632
- 'day': <?php echo $day; ?>,
633
- 'month': <?php echo $month; ?>,
634
- 'year': <?php echo $year; ?>,
635
- 'hour': <?php echo $hour; ?>,
636
- 'min': <?php echo $min; ?>,
637
- 'sec': <?php echo $sec; ?>,
638
- 'localtime': '<?php echo $t; ?>',
639
- },
640
- style: '<?php echo $style; ?>',
641
- omitWeeks: <?php echo $omitweeks;
642
- if($content){
643
- echo ", onComplete: function() {
644
- jQuery('#".$id."-".$launchtarget."').css({'width' : '".$launchwidth."', 'height' : '".$launchheight."'});
645
- jQuery('#".$id."-".$launchtarget."').html('".do_shortcode($content)."');
646
- }";
647
- }?>
648
- });
649
- }
650
- });
651
- </script>
652
- <?php
653
  return $tminus;
654
  }
655
  add_shortcode('tminus', 'tminuscountdown');
3
  Plugin Name: jQuery T(-) Countdown - v2.0
4
  Plugin URI: http://www.twinpictures.de/jquery-t-minus-2-0/
5
  Description: Display and configure multiple jQuery countdown timers using a shortcode or as a sidebar widget.
6
+ Version: 2.0.1
7
  Author: Twinpictures
8
  Author URI: http://www.twinpictures.de
9
  License: GPL2
70
  //$styleizer = array('carbonite','darth','jedi');
71
  $styleizer = get_option('t-minus_styles');
72
  $plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
73
+ if($styleizer){
74
+ foreach((array) $styleizer as $style){
75
+ wp_register_style( 'countdown-'.$style.'-css', $plugin_url.'/css/'.$style.'/style.css', array (), '1.1' );
76
+ wp_enqueue_style( 'countdown-'.$style.'-css' );
77
+ }
78
  }
79
  }
80
 
94
 
95
  /** Widget */
96
  function widget($args, $instance) {
97
+ global $add_my_script;
98
  extract( $args );
 
99
  //insert some style into your life
100
  $style = empty($instance['style']) ? 'jedi' : apply_filters('widget_style', $instance['style']);
101
  //$styleizer[$style] = $style;
188
  echo $before_title . $title . $after_title;
189
  }
190
  echo '<div id="'.$args['widget_id'].'-widget">';
191
+ echo '<div id="'.$args['widget_id'].'-tophtml" class="'.$style.'-tophtml" >';
192
  if($tophtml){
193
  echo $tophtml;
194
  }
270
  else if($launchtarget == "Entire Widget"){
271
  $launchdiv = "widget";
272
  }
273
+
274
+ $add_my_script[$id] = array(
275
+ 'id' => $args['widget_id'],
276
+ 'day' => $day,
277
+ 'month' => $month,
278
+ 'year' => $year,
279
+ 'hour' => $hour,
280
+ 'min' => $min,
281
+ 'sec' => $sec,
282
+ 'localtime' => $t,
283
+ 'style' => $style,
284
+ 'omitweeks' => $omitweeks,
285
+ 'content' => trim($launchhtml),
286
+ 'launchtarget' => $launchdiv,
287
+ 'launchwidth' => 'auto',
288
+ 'launchheight' => 'auto'
289
+ );
 
 
 
 
 
 
 
 
 
 
290
  }
291
 
292
  /** Update */
462
  add_action('widgets_init', create_function('', 'return register_widget("CountDownTimer");'));
463
 
464
  //the short code
465
+ //code fore the footer
466
+ add_action('wp_footer', 'print_my_script');
467
+
468
+ function print_my_script() {
469
+ global $add_my_script;
470
+
471
+ if ( ! $add_my_script ){
472
+ return;
473
+ }
474
+
475
+ ?>
476
+ <script language="javascript" type="text/javascript">
477
+ jQuery(document).ready(function() {
478
+ <?php
479
+ foreach((array) $add_my_script as $script){
480
+ ?>
481
+ jQuery('#<?php echo $script['id']; ?>-dashboard').countDown({
482
+ targetDate: {
483
+ 'day': <?php echo $script['day']; ?>,
484
+ 'month': <?php echo $script['month']; ?>,
485
+ 'year': <?php echo $script['year']; ?>,
486
+ 'hour': <?php echo $script['hour']; ?>,
487
+ 'min': <?php echo $script['min']; ?>,
488
+ 'sec': <?php echo $script['sec']; ?>,
489
+ 'localtime': '<?php echo $script['localtime']; ?>',
490
+ },
491
+ style: '<?php echo $script['style']; ?>',
492
+ omitWeeks: <?php echo $script['omitweeks'];
493
+ if($script['content']){
494
+ echo ", onComplete: function() {
495
+ jQuery('#".$script['id']."-".$script['launchtarget']."').css({'width' : '".$script['launchwidth']."', 'height' : '".$script['launchheight']."'});
496
+ jQuery('#".$script['id']."-".$script['launchtarget']."').html('".do_shortcode($script['content'])."');
497
+ }";
498
+ }?>
499
+ });
500
+ <?php
501
+ }
502
+ ?>
503
+ });
504
+ </script>
505
+ <?php
506
+ }
507
+
508
  function tminuscountdown($atts, $content=null) {
509
+ global $add_my_script;
510
  //find a random number, incase there is no id assigned
511
  $ran = rand(1, 10000);
512
 
529
  'launchtarget' => 'countdown',
530
  ), $atts));
531
 
532
+
533
  //update the styles
534
  $style_arr = get_option('t-minus_styles');
535
  $style_arr[$style] = $style;
653
  $tminus .= '</div></div>';
654
 
655
  $t = date( 'n/j/Y H:i:s', gmmktime() + ( get_option( 'gmt_offset' ) * 3600));
656
+
657
  if(is_numeric($launchwidth)){
658
  $launchwidth .= 'px';
659
  }
660
  if(is_numeric($launchheight)){
661
  $launchheight .= 'px';
662
  }
663
+ $content = mysql_real_escape_string( $content);
664
+ $content = str_replace(array('\r\n', '\r', '\n<p>', '\n'), '', $content);
665
+ $add_my_script[$id] = array(
666
+ 'id' => $id,
667
+ 'day' => $day,
668
+ 'month' => $month,
669
+ 'year' => $year,
670
+ 'hour' => $hour,
671
+ 'min' => $min,
672
+ 'sec' => $sec,
673
+ 'localtime' => $t,
674
+ 'style' => $style,
675
+ 'omitweeks' => $omitweeks,
676
+ 'content' => $content,
677
+ 'launchtarget' => $launchtarget,
678
+ 'launchwidth' => $launchwidth,
679
+ 'launchheight' => $launchheight
680
+ );
681
+
 
 
 
 
 
 
 
 
 
682
  return $tminus;
683
  }
684
  add_shortcode('tminus', 'tminuscountdown');
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://www.twinpictures.de/jquery-t-minus-2-0/
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, t minus, t-minus, twinpictures, G2, spaceBros, littlewebtings, jQuery, javascript
6
  Requires at least: 2.8
7
  Tested up to: 3.1
8
- Stable tag: 2.0
9
 
10
  jQuery T(-) CountDown v2.0 will dispaly a highly customizable, sweet-n-sexy flash-free countdown timer in the sidebar or in your post using a shortcode.
11
 
@@ -22,7 +22,7 @@ jQuery T(-) CountDown v2.0 will display a sweet, sexy and totally flash-free cou
22
  1. Test that the this plugin meets your demanding needs.
23
  1. Tweak the css files for premium enjoyment.
24
  1. Rate the plugin and verify that it works at wordpress.org.
25
- 1. Leave a comment regarding bugs, feature request, cocktail recipes at http://www.twinpictures.de/t-minus-countdown-widget/
26
 
27
  == Frequently Asked Questions ==
28
 
@@ -45,6 +45,11 @@ The Daily Show with John Stewart
45
 
46
  == Changelog ==
47
 
 
 
 
 
 
48
  = 2.0 =
49
  * Multiple instance sidebar widgets.
50
  * Advanced above and below HTML areas.
@@ -79,6 +84,9 @@ The Daily Show with John Stewart
79
 
80
  == Upgrade Notice ==
81
 
 
 
 
82
  = 2.0 =
83
  Requires WordPress version 2.8 or higher. Backup custom CSS folders.
84
 
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, t minus, t-minus, twinpictures, G2, spaceBros, littlewebtings, jQuery, javascript
6
  Requires at least: 2.8
7
  Tested up to: 3.1
8
+ Stable tag: 2.0.1
9
 
10
  jQuery T(-) CountDown v2.0 will dispaly a highly customizable, sweet-n-sexy flash-free countdown timer in the sidebar or in your post using a shortcode.
11
 
22
  1. Test that the this plugin meets your demanding needs.
23
  1. Tweak the css files for premium enjoyment.
24
  1. Rate the plugin and verify that it works at wordpress.org.
25
+ 1. Leave a comment regarding bugs, feature request, cocktail recipes at http://www.twinpictures.de/jquery-t-minus-2-0/
26
 
27
  == Frequently Asked Questions ==
28
 
45
 
46
  == Changelog ==
47
 
48
+ = 2.0.1 =
49
+ * Verify that a style has been set before looping - was throwing an error.
50
+ * Inproved loadtimes by printing all javascript in the footer
51
+ * Workaround for strange behavor with html content sent using shortcode
52
+
53
  = 2.0 =
54
  * Multiple instance sidebar widgets.
55
  * Advanced above and below HTML areas.
84
 
85
  == Upgrade Notice ==
86
 
87
+ = 2.0.1 =
88
+ Minor bug fixes and improved load times.
89
+
90
  = 2.0 =
91
  Requires WordPress version 2.8 or higher. Backup custom CSS folders.
92