T(-) Countdown - Version 2.3.1

Version Description

  • fixed fatal bug when registering events ajax callback
  • added force load css option for systems that will not dynamically load css
  • misc cleanup
Download this release

Release Info

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

Code changes from version 2.3.0 to 2.3.1

Files changed (2) hide show
  1. countdown-timer.php +84 -61
  2. readme.txt +11 -1
countdown-timer.php CHANGED
@@ -5,7 +5,7 @@ Text Domain: tminus
5
  Domain Path: /languages
6
  Plugin URI: http://plugins.twinpictures.de/plugins/t-minus-countdown/
7
  Description: Display and configure multiple T(-) Countdown timers using a shortcode or sidebar widget.
8
- Version: 2.3.0
9
  Author: twinpictures, baden03
10
  Author URI: http://www.twinpictures.de/
11
  License: GPL2
@@ -15,7 +15,7 @@ License: GPL2
15
 
16
  class WP_TMinusCD {
17
  var $plugin_name = 'T(-) Countdown';
18
- var $version = '2.3.0';
19
  var $domain = 'tminus';
20
  var $plguin_options_page_title = 'T(-) Countdown Options';
21
  var $plugin_options_menue_title = 'T(-) Countdown';
@@ -28,6 +28,7 @@ class WP_TMinusCD {
28
  var $options = array(
29
  'custom_css' => '',
30
  'rockstar' => '',
 
31
  );
32
 
33
  var $license_group = 'tminus_countdown_licenseing';
@@ -43,9 +44,11 @@ class WP_TMinusCD {
43
 
44
  // add actions
45
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
 
46
  add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_actions' ) );
47
  add_action( 'admin_init', array( $this, 'admin_init' ) );
48
  add_action( 'wp_head', array( $this, 'plugin_head_inject' ) );
 
49
  }
50
 
51
  /**
@@ -77,6 +80,12 @@ class WP_TMinusCD {
77
 
78
  //plugin header inject
79
  function plugin_head_inject(){
 
 
 
 
 
 
80
  // custom css
81
  if( !empty( $this->options['custom_css'] ) ){
82
  echo "<style>\n";
@@ -85,6 +94,55 @@ class WP_TMinusCD {
85
  }
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  /**
89
  * Admin options page
90
  */
@@ -144,6 +202,27 @@ class WP_TMinusCD {
144
  </td>
145
  </tr>
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  <tr>
148
  <th><?php _e( 'Custom CSS', $this->domain ) ?>:</th>
149
  <td><label><textarea id="<?php echo $this->options_name ?>[custom_css]" name="<?php echo $this->options_name ?>[custom_css]" style="width: 100%; height: 537px;"><?php echo $options['custom_css']; ?></textarea>
@@ -282,60 +361,6 @@ class WP_TMinusCD {
282
  }
283
  $WP_TMinusCD = new WP_TMinusCD;
284
 
285
- //set global vars
286
- add_action( 'wp_head', 'tminus_js_vars' );
287
- function tminus_js_vars(){
288
- echo "<script type='text/javascript'>\n";
289
- $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
290
- echo "var tminusnow = '".$plugin_url."/js/now.php';\n";
291
- echo "</script>";
292
- }
293
-
294
- //load scripts on the widget admin page
295
- add_action( 'admin_enqueue_scripts', 'tminus_admin_scripts');
296
- function tminus_admin_scripts($hook){
297
- if( $hook == 'widgets.php' ){
298
- //jquery datepicker
299
- wp_enqueue_script( 'jquery-ui-datepicker' );
300
- wp_enqueue_script( 'jquery-ui-slider' );
301
-
302
- wp_register_style('jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css', array (), '1.10.4' );
303
- wp_enqueue_style('jquery-ui-css');
304
-
305
-
306
- $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
307
-
308
- //jquery widget scripts
309
- wp_register_script('jquery-ui-timepicker-addon', $plugin_url.'/js/jquery-ui-timepicker-addon.min.js', array ('jquery'), '1.5.2', true);
310
- wp_enqueue_script('jquery-ui-timepicker-addon');
311
-
312
- wp_register_script('tminus-admin-script', $plugin_url.'/js/jquery.collapse.js', array ('jquery', 'jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), '1.2.2', true);
313
- wp_enqueue_script('tminus-admin-script');
314
-
315
- wp_register_style('collapse-admin-css', $plugin_url.'/admin/collapse-style.css' );
316
- wp_enqueue_style('collapse-admin-css');
317
- }
318
- }
319
-
320
- //load front-end countdown scripts
321
- add_action('wp_enqueue_scripts', 'countdown_scripts' );
322
- function countdown_scripts(){
323
- $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
324
-
325
- //lwtCountdown script
326
- wp_register_script('countdown-script', $plugin_url.'/js/jquery.t-countdown.js', array ('jquery'), '1.5.4', 'true');
327
- wp_enqueue_script('countdown-script');
328
-
329
- // callback for t(-) events if installed
330
- if( is_plugin_active( 't-countdown-events/t-countdown-events.php' ) ){
331
- wp_localize_script( 'countdown-script', 'tCountAjax', array(
332
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
333
- 'countdownNonce' => wp_create_nonce( 'tountajax-countdownonce-nonce' ),
334
- ));
335
- }
336
-
337
- }
338
-
339
  //style folders array
340
  function folder_array($path, $exclude = ".|..") {
341
  if(is_dir($path)){
@@ -348,7 +373,6 @@ function folder_array($path, $exclude = ".|..") {
348
  }
349
  }
350
  closedir($dh);
351
- print_r($result);
352
  return $result;
353
  }
354
  }
@@ -430,7 +454,7 @@ class CountDownTimer extends WP_Widget {
430
  echo do_shortcode('[tminus '.$sc_atts.']'.$content.'[/tminus]');
431
 
432
  echo $args['after_widget'];
433
- }
434
 
435
  function get_styles($custom_css = null) {
436
  //default styles
@@ -441,7 +465,6 @@ class CountDownTimer extends WP_Widget {
441
  }
442
  natcasesort($styles_arr);
443
  return $styles_arr;
444
-
445
  }
446
 
447
  function update( $new_instance, $old_instance ) {
@@ -454,7 +477,7 @@ class CountDownTimer extends WP_Widget {
454
  return $instance;
455
  }
456
 
457
- /** Form */
458
  function form($instance) {
459
  $options = get_option('WP_TMC_options');
460
 
@@ -734,7 +757,7 @@ function tminuscountdown($atts, $content=null) {
734
 
735
  if ( file_exists( __DIR__ .'/css/'.$style.'/style.css' ) ) {
736
  if (! wp_style_is( 'countdown-'.$style.'-css', 'registered' )) {
737
- wp_register_style( 'countdown-'.$style.'-css', $style_file_url, array(), '2.0');
738
  }
739
  wp_enqueue_style( 'countdown-'.$style.'-css' );
740
  }
5
  Domain Path: /languages
6
  Plugin URI: http://plugins.twinpictures.de/plugins/t-minus-countdown/
7
  Description: Display and configure multiple T(-) Countdown timers using a shortcode or sidebar widget.
8
+ Version: 2.3.1
9
  Author: twinpictures, baden03
10
  Author URI: http://www.twinpictures.de/
11
  License: GPL2
15
 
16
  class WP_TMinusCD {
17
  var $plugin_name = 'T(-) Countdown';
18
+ var $version = '2.3.1';
19
  var $domain = 'tminus';
20
  var $plguin_options_page_title = 'T(-) Countdown Options';
21
  var $plugin_options_menue_title = 'T(-) Countdown';
28
  var $options = array(
29
  'custom_css' => '',
30
  'rockstar' => '',
31
+ 'force_css' => '',
32
  );
33
 
34
  var $license_group = 'tminus_countdown_licenseing';
44
 
45
  // add actions
46
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
47
+ add_action( 'admin_enqueue_scripts', array( $this, 'tminus_admin_scripts' ) );
48
  add_action( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'plugin_actions' ) );
49
  add_action( 'admin_init', array( $this, 'admin_init' ) );
50
  add_action( 'wp_head', array( $this, 'plugin_head_inject' ) );
51
+ add_action( 'wp_enqueue_scripts', array( $this, 'countdown_scripts' ) );
52
  }
53
 
54
  /**
80
 
81
  //plugin header inject
82
  function plugin_head_inject(){
83
+ // custom script
84
+ echo "<script type='text/javascript'>\n";
85
+ $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
86
+ echo "var tminusnow = '".$plugin_url."/js/now.php';\n";
87
+ echo "</script>";
88
+
89
  // custom css
90
  if( !empty( $this->options['custom_css'] ) ){
91
  echo "<style>\n";
94
  }
95
  }
96
 
97
+ //load scripts on the widget admin page
98
+ function tminus_admin_scripts($hook){
99
+ if( $hook == 'widgets.php' ){
100
+ //jquery datepicker
101
+ wp_enqueue_script( 'jquery-ui-datepicker' );
102
+ wp_enqueue_script( 'jquery-ui-slider' );
103
+
104
+ wp_register_style('jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css', array (), '1.10.4' );
105
+ wp_enqueue_style('jquery-ui-css');
106
+
107
+
108
+ $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
109
+
110
+ //jquery widget scripts
111
+ wp_register_script('jquery-ui-timepicker-addon', $plugin_url.'/js/jquery-ui-timepicker-addon.min.js', array ('jquery'), '1.5.2', true);
112
+ wp_enqueue_script('jquery-ui-timepicker-addon');
113
+
114
+ wp_register_script('tminus-admin-script', $plugin_url.'/js/jquery.collapse.js', array ('jquery', 'jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), '1.2.2', true);
115
+ wp_enqueue_script('tminus-admin-script');
116
+
117
+ wp_register_style('collapse-admin-css', $plugin_url.'/admin/collapse-style.css' );
118
+ wp_enqueue_style('collapse-admin-css');
119
+ }
120
+ }
121
+
122
+ //load front-end countdown scripts
123
+ function countdown_scripts(){
124
+ $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
125
+
126
+ //lwtCountdown script
127
+ wp_register_script('countdown-script', $plugin_url.'/js/jquery.t-countdown.js', array ('jquery'), '1.5.4', 'true');
128
+ wp_enqueue_script('countdown-script');
129
+
130
+ //force load styles
131
+ if( !empty( $this->options['force_css'] ) ){
132
+ $style = $this->options['force_css'];
133
+ $style_file_url = plugins_url('/css/'.$style.'/style.css', __FILE__);
134
+ wp_register_style( 'countdown-'.$style.'-css', $style_file_url, array(), '2.0');
135
+ wp_enqueue_style( 'countdown-'.$style.'-css' );
136
+ }
137
+
138
+ // callback for t(-) events
139
+ wp_localize_script( 'countdown-script', 'tCountAjax', array(
140
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
141
+ 'countdownNonce' => wp_create_nonce( 'tountajax-countdownonce-nonce' ),
142
+ ));
143
+ }
144
+
145
+
146
  /**
147
  * Admin options page
148
  */
202
  </td>
203
  </tr>
204
 
205
+
206
+ <tr>
207
+ <th><?php _e( 'Force Load CSS', $this->domain ) ?>:</th>
208
+ <td><label>
209
+ <select name="<?php echo $this->options_name ?>[force_css]" id="<?php echo $this->options_name ?>[force_css]">
210
+ <option value=''> </option>
211
+ <?php
212
+ $styles_arr = CountDownTimer::get_styles();
213
+ foreach($styles_arr as $style_name){
214
+ $selected = "";
215
+ if($options['force_css'] == $style_name){
216
+ $selected = 'SELECTED';
217
+ }
218
+ echo '<option value="'.$style_name.'" '.$selected.'>'.$style_name.'</option>';
219
+ }
220
+ ?>
221
+ </select>
222
+ <br /><span class="description"><?php _e('Force a css style to load in the header', $this->domain); ?></span></label>
223
+ </td>
224
+ </tr>
225
+
226
  <tr>
227
  <th><?php _e( 'Custom CSS', $this->domain ) ?>:</th>
228
  <td><label><textarea id="<?php echo $this->options_name ?>[custom_css]" name="<?php echo $this->options_name ?>[custom_css]" style="width: 100%; height: 537px;"><?php echo $options['custom_css']; ?></textarea>
361
  }
362
  $WP_TMinusCD = new WP_TMinusCD;
363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  //style folders array
365
  function folder_array($path, $exclude = ".|..") {
366
  if(is_dir($path)){
373
  }
374
  }
375
  closedir($dh);
 
376
  return $result;
377
  }
378
  }
454
  echo do_shortcode('[tminus '.$sc_atts.']'.$content.'[/tminus]');
455
 
456
  echo $args['after_widget'];
457
+ }
458
 
459
  function get_styles($custom_css = null) {
460
  //default styles
465
  }
466
  natcasesort($styles_arr);
467
  return $styles_arr;
 
468
  }
469
 
470
  function update( $new_instance, $old_instance ) {
477
  return $instance;
478
  }
479
 
480
+ /** Form */
481
  function form($instance) {
482
  $options = get_option('WP_TMC_options');
483
 
757
 
758
  if ( file_exists( __DIR__ .'/css/'.$style.'/style.css' ) ) {
759
  if (! wp_style_is( 'countdown-'.$style.'-css', 'registered' )) {
760
+ wp_register_style( 'countdown-'.$style.'-css', $style_file_url, array(), '2.0');
761
  }
762
  wp_enqueue_style( 'countdown-'.$style.'-css' );
763
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://plugins.twinpictures.de/plugins/t-minus-countdown/
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, twinpictures, t minus, t-minus, plugin-oven, pluginoven, G2, spaceBros, littlewebtings, jQuery, javascript
6
  Requires at least: 3.9
7
  Tested up to: 4.2
8
- Stable tag: 2.3.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -65,6 +65,11 @@ Ah yes! <a href='http://twitter.com/#!/twinpictures'>@Twinpictures</a> is on the
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
68
  = 2.3.0 =
69
  * complete code update
70
  * added plugin options page
@@ -229,6 +234,11 @@ Ah yes! <a href='http://twitter.com/#!/twinpictures'>@Twinpictures</a> is on the
229
 
230
  == Upgrade Notice ==
231
 
 
 
 
 
 
232
  = 2.3.0 =
233
  * updated method of formatting time in meta-box
234
  * error handling if the ajax call is not successful
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, twinpictures, t minus, t-minus, plugin-oven, pluginoven, G2, spaceBros, littlewebtings, jQuery, javascript
6
  Requires at least: 3.9
7
  Tested up to: 4.2
8
+ Stable tag: 2.3.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
65
 
66
  == Changelog ==
67
 
68
+ = 2.3.1 =
69
+ * fixed fatal bug when registering events ajax callback
70
+ * added force load css option for systems that will not dynamically load css
71
+ * misc cleanup
72
+
73
  = 2.3.0 =
74
  * complete code update
75
  * added plugin options page
234
 
235
  == Upgrade Notice ==
236
 
237
+ = 2.3.1 =
238
+ * fixed fatal bug when registering events ajax callback
239
+ * added force load css option for systems that will not dynamically load css
240
+ * misc cleanup
241
+
242
  = 2.3.0 =
243
  * updated method of formatting time in meta-box
244
  * error handling if the ajax call is not successful