Changeset 651785
- Timestamp:
- 01/13/2013 02:02:19 AM (13 years ago)
- Location:
- countdown-timer/trunk
- Files:
-
- 2 added
- 6 edited
-
. (modified) (1 prop)
-
.gitignore (modified) (1 diff)
-
fergcorp_countdownTimer.php (modified) (84 diffs)
-
js/fergcorp_countdownTimer_java.js (modified) (1 diff)
-
js/fergcorp_countdownTimer_java_debug.js (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
tests (added)
-
tests/CountDownTimerTest.php (added)
Legend:
- Unmodified
- Added
- Removed
-
countdown-timer/trunk
-
Property
svn:ignore
set to
deploy.sh
README.md
.git
.gitignore
assets
-
Property
svn:ignore
set to
-
countdown-timer/trunk/.gitignore
r517705 r651785 1 1 .project 2 countdown-timer.sublime-project 3 countdown-timer.sublime-workspace 4 fergcorp_debug.php 5 phpunit.xml 6 tests/bootstrap.php 7 tests/countdown-timer/CountDownTimerTest.php 8 unit_test.php 9 assets 10 assets/banner-772x250.jpg 11 report -
countdown-timer/trunk/fergcorp_countdownTimer.php
r567188 r651785 4 4 Plugin URI: http://www.andrewferguson.net/wordpress-plugins/countdown-timer/ 5 5 Description: Use shortcodes and a widget to count down or up to the years, months, weeks, days, hours, minutes, and/or seconds to a particular event. 6 Version: 3.0. 36 Version: 3.0.4 7 7 Author: Andrew Ferguson 8 8 Author URI: http://www.andrewferguson.net 9 9 10 10 Countdown Timer - Use shortcodes and a widget to count down the years, months, weeks, days, hours, and minutes to a particular event 11 Copyright (c) 2005-201 2Andrew Ferguson11 Copyright (c) 2005-2013 Andrew Ferguson 12 12 13 13 This program is free software; you can redistribute it and/or … … 33 33 @param type $varname Description 34 34 @return type Description 35 @todo 35 @todo 36 36 37 37 */ … … 39 39 /** 40 40 * Main class for Countdown related activities 41 * 41 * 42 42 * @package Countdown_Timer 43 43 * @author Andrew Ferguson … … 46 46 */ 47 47 class Fergcorp_Countdown_Timer{ 48 48 49 49 //Per instance 50 50 private $eventList; 51 51 private $eventsPresent; 52 52 private $jsUID = array(); 53 53 54 54 //Settings 55 55 private $deleteOneTimeEvents; … … 66 66 private $timeSinceTime; 67 67 private $titleSuffix; 68 private $enable dShortcodeExcerpt;69 68 private $enableShortcodeExcerpt; 69 70 70 private $version; 71 71 72 72 /** 73 73 * Load settings 74 * 74 * 75 75 * @since 3.0.4 76 76 * @access public … … 78 78 */ 79 79 public function loadSettings(){ 80 80 81 81 $this->version = get_option("fergcorp_countdownTimer_version"); 82 82 $this->deleteOneTimeEvents = get_option("fergcorp_countdownTimer_deleteOneTimeEvents"); … … 93 93 $this->timeSinceTime = get_option("fergcorp_countdownTimer_timeSinceTime"); 94 94 $this->titleSuffix = get_option("fergcorp_countdownTimer_titleSuffix"); 95 $this->enable dShortcodeExcerpt = get_option("fergcorp_countdownTimer_enableShortcodeExcerpt");96 95 $this->enableShortcodeExcerpt = get_option("fergcorp_countdownTimer_enableShortcodeExcerpt"); 96 97 97 $this->eventList = get_option("fergcorp_countdownTimer_oneTimeEvent"); //Get the events from the WPDB to make sure a fresh copy is being used 98 98 } 99 100 101 99 100 101 102 102 /** 103 103 * Default construct to initialize settings required no matter what 104 * 104 * 105 105 * @since 3.0 106 106 * @access public … … 108 108 */ 109 109 public function __construct(){ 110 // Load settings 110 // Load settings 111 111 $this->loadSettings(); 112 112 113 if(version_compare($this->version, "3.0. 2", "<")){113 if(version_compare($this->version, "3.0.4", "<")){ 114 114 add_action('admin_init', array( &$this, 'install' ) ); 115 115 add_action('admin_init', array( &$this, 'loadSettings' ) ); 116 116 117 117 } 118 118 … … 120 120 wp_register_script('webkit_sprintf', plugins_url(dirname(plugin_basename(__FILE__)) . "/js/" . 'webtoolkit.sprintf.js'), FALSE, $this->version); 121 121 wp_register_script('fergcorp_countdowntimer', plugins_url(dirname(plugin_basename(__FILE__)) . "/js/". 'fergcorp_countdownTimer_java.js'), array('jquery','webkit_sprintf'), $this->version, TRUE ); 122 122 123 123 if($this->enableJS) { 124 124 add_action('wp_footer', array ( &$this, 'json' ) ); 125 125 } 126 127 128 if($this->enable dShortcodeExcerpt) {126 127 128 if($this->enableShortcodeExcerpt) { 129 129 add_filter('the_excerpt', 'do_shortcode'); 130 130 } … … 132 132 //Priority needs to be set to 1 so that the scripts can be enqueued before the scripts are printed, since both actions are hooked into the wp_head action. 133 133 add_action('wp_head', array( &$this, 'print_countdown_scripts' ), 1); 134 134 135 135 //Admin hooks 136 136 add_action('admin_init', array( &$this, 'register_settings' ) ); //Initialized the options 137 137 add_action('admin_menu', array( &$this, 'register_settings_page' ) ); //Add Action for adding the options page to admin panel 138 138 139 139 add_shortcode('fergcorp_cdt_single', array ( &$this, 'shortcode_singleTimer' ) ); 140 140 add_shortcode('fergcorp_cdt', array ( &$this, 'shortcode_showTimer' ) ); 141 142 143 144 $plugin = plugin_basename(__FILE__); 145 add_filter("plugin_action_links_$plugin", array( &$this, 'settings_link' ) ); 141 146 142 143 144 $plugin = plugin_basename(__FILE__);145 add_filter("plugin_action_links_$plugin", array( &$this, 'settings_link' ) );146 } 147 147 $tz = get_option('timezone_string'); 148 if ( $tz ){ //Get and check if we have a valid time zone... 149 date_default_timezone_set($tz); //...if so, use it 150 } 151 } 152 148 153 /** 149 154 * Add settings link on plugin page 150 * 155 * 151 156 * @since 3.0 152 157 * @access public 153 158 * @author c.bavota (http://bavotasan.com/2009/a-settings-link-for-your-wordpress-plugins/) 159 * @codeCoverageIgnore 154 160 */ 155 156 public function settings_link($links) { 157 $settings_link = '<a href="options-general.php?page=fergcorp_countdownTimer.php">Settings</a>'; 158 array_unshift($links, $settings_link); 159 return $links; 160 } 161 161 public function settings_link($links) { 162 $settings_link = '<a href="options-general.php?page=fergcorp_countdownTimer.php">Settings</a>'; 163 array_unshift($links, $settings_link); 164 return $links; 165 } 166 162 167 /** 163 168 * Loads the appropriate scripts when in the admin page … … 170 175 wp_enqueue_script('postbox'); //These appear to be new functions in WP 2.5 171 176 } 172 177 173 178 /** 174 179 * Loads the appropriate scripts for running the timer … … 179 184 */ 180 185 public function print_countdown_scripts(){ 181 if($this->enableJS) { 186 if($this->enableJS) { 182 187 wp_enqueue_script('fergcorp_countdowntimer'); 183 188 wp_enqueue_script('webkit_sprintf'); 184 189 185 190 } 186 } 187 191 else{ 192 wp_dequeue_script('fergcorp_countdowntimer'); 193 wp_dequeue_script('webkit_sprintf'); 194 } 195 } 196 188 197 /** 189 198 * Adds the management page in the admin menu … … 198 207 add_action( 'admin_print_scripts-' . $settings_page, array( &$this, 'print_countdown_scripts' ) ); 199 208 } 200 209 201 210 /** 202 211 * Settings page 203 * 212 * 204 213 * @since 3.0 205 214 * @access private … … 207 216 */ 208 217 public function settings_page(){ ?> 209 218 210 219 <script type="text/javascript"> 211 // <![CDATA[ 220 // <![CDATA[ 212 221 jQuery(document).ready( function($) { 213 222 // close postboxes that should be closed 214 223 jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 215 224 216 225 // postboxes setup 217 226 postboxes.add_postbox_toggles('fergcorp-countdown-timer'); //For WP2.7 and above 218 227 219 228 }); 220 229 221 230 function clearField(eventType, fieldNum){ //For deleting events without reloading 222 231 var agree=confirm('<?php _e('Are you sure you wish to delete', 'fergcorp_countdownTimer'); ?> '+document.getElementsByName(eventType+'['+fieldNum+'][text]').item(0).value+'?'); … … 248 257 // ]]> 249 258 </script> 250 259 251 260 <div class="wrap" id="fergcorp_countdownTimer_div"> 252 261 <h2>Countdown Timer</h2> 253 262 <div id="poststuff"> 254 263 255 264 <?php 256 /** 257 * Creates and defines the metabox for the resources box 258 * 259 * @package Countdown_Timer 260 * @author Andrew Ferguson 261 * @internal 3.0 262 * @access private 263 * 264 */ 265 function resources_meta_box(){ 266 ?> 267 <table width="90%" border="0" cellspacing="0" cellpadding="0"> 268 <tr> 269 <td><ul><li><a href="http://andrewferguson.net/wordpress-plugins/countdown-timer/" target="_blank"><?php _e('Plugin Homepage','fergcorp_countdownTimer'); ?></a></li></ul></td> 270 <td><ul><li><a href="http://wordpress.org/tags/countdown-timer" target="_blank"><?php _e('Support Forum','fergcorp_countdownTimer'); ?></a></li></ul></td> 271 <td><ul><li><a href="http://www.amazon.com/gp/registry/registry.html?ie=UTF8&type=wishlist&id=E7Q6VO0I8XI4" target="_blank"><?php _e('Amazon Wishlist','fergcorp_countdownTimer'); ?></a></li></ul></td> 272 <td><ul><li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=38923"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" alt="Donate"/></a></li></ul></td> 273 </tr> 274 </table> 275 <p><?php _e("I've coded and supported this plugin for several years now, however I am a full-time engineer with a real, full-time job and really only do this programming thing on the side for the love of it. If you would like to continue to see updates, please consider donating above.", 'fergcorp_countdownTimer'); ?></p> 276 <?php 277 } 278 add_meta_box("fergcorp_countdownTimer_resources", __('Resources', 'fergcorp_countdownTimer'), "resources_meta_box", "fergcorp-countdown-timer"); 265 266 add_meta_box('fergcorp_countdownTimer_resources', __('Resources', 'fergcorp_countdownTimer'), array ( &$this, 'resources_meta_box'), 'fergcorp-countdown-timer'); 279 267 ?> 280 268 281 269 <form method="post" action="options.php"> 282 270 283 271 <input type="hidden" name="fergcorp_countdownTimer_noncename" id="fergcorp_countdownTimer_noncename" value="<?php wp_create_nonce( plugin_basename(__FILE__) );?>" /> 284 272 285 273 <?php 286 274 287 275 wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 288 276 wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); 289 277 settings_fields('fergcorp_countdownTimer_options'); 290 291 292 add_meta_box('fergcorp_countdownTimer_installation', __('Installation and Usage Notes', 'fergcorp_countdownTimer'), array ( &$this, 'installation_meta_box' ), 'fergcorp-countdown-timer', 'advanced', 'default'); 278 279 280 add_meta_box('fergcorp_countdownTimer_installation', __('Installation and Usage Notes', 'fergcorp_countdownTimer'), array ( &$this, 'installation_meta_box' ), 'fergcorp-countdown-timer', 'advanced', 'default'); 293 281 add_meta_box("fergcorp_countdownTimer_events", __('One Time Events', 'fergcorp_countdownTimer'), array ( &$this, 'events_meta_box' ), "fergcorp-countdown-timer"); 294 282 add_meta_box("fergcorp_countdownTimer_management", __('Management', 'fergcorp_countdownTimer'), array ( &$this, "management_meta_box" ), "fergcorp-countdown-timer"); … … 298 286 add_meta_box("fergcorp_countdownTimer_example_display", __('Example Display', 'fergcorp_countdownTimer'), array ( &$this, "example_display_meta_box" ), "fergcorp-countdown-timer"); 299 287 do_meta_boxes('fergcorp-countdown-timer','advanced',null); 300 288 301 289 ?> 302 290 … … 308 296 </form> 309 297 </div> 310 298 311 299 </div> 312 300 <?php 313 314 } 315 316 /**317 * Creates and defines the metabox for the options box318 * 301 302 } 303 304 /** 305 * Creates and defines the metabox for the resources box 306 * 319 307 * @package Countdown_Timer 320 308 * @author Andrew Ferguson 321 309 * @internal 3.0 322 310 * @access private 323 * 311 * @codeCoverageIgnore 312 * 313 */ 314 function resources_meta_box(){ 315 ?> 316 <table width="90%" border="0" cellspacing="0" cellpadding="0"> 317 <tr> 318 <td><ul><li><a href="http://andrewferguson.net/wordpress-plugins/countdown-timer/" target="_blank"><?php _e('Plugin Homepage','fergcorp_countdownTimer'); ?></a></li></ul></td> 319 <td><ul><li><a href="http://wordpress.org/tags/countdown-timer" target="_blank"><?php _e('Support Forum','fergcorp_countdownTimer'); ?></a></li></ul></td> 320 <td><ul><li><a href="http://www.amazon.com/gp/registry/registry.html?ie=UTF8&type=wishlist&id=E7Q6VO0I8XI4" target="_blank"><?php _e('Amazon Wishlist','fergcorp_countdownTimer'); ?></a></li></ul></td> 321 <td><ul><li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=38923"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" alt="Donate"/></a></li></ul></td> 322 </tr> 323 </table> 324 <p><?php _e("I've coded and supported this plugin for several years now, however I am a full-time engineer with a real, full-time job and really only do this programming thing on the side for the love of it. If you would like to continue to see updates, please consider donating above.", 'fergcorp_countdownTimer'); ?></p> 325 <?php 326 } 327 328 /** 329 * Creates and defines the metabox for the options box 330 * 331 * @package Countdown_Timer 332 * @author Andrew Ferguson 333 * @internal 3.0 334 * @access private 335 * 324 336 */ 325 337 function display_options_meta_box(){ … … 333 345 <li><?php echo __('Hours:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_showHour", $this->showHour); ?></li> 334 346 <li><?php echo __('Minutes:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_showMinute", $this->showMinute); ?></li> 335 <li><?php echo __('Seconds:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_showSecond", $this->showSecond); ?></li> 347 <li><?php echo __('Seconds:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_showSecond", $this->showSecond); ?></li> 336 348 <li><?php echo __('Strip non-significant zeros:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_stripZero", $this->stripZero); ?></li> 337 349 </ul> … … 341 353 /** 342 354 * Creates and defines the metabox for the events box 343 * 355 * 344 356 * @package Countdown_Timer 345 357 * @author Andrew Ferguson 346 358 * @internal 3.0 347 359 * @access public 348 * 349 */ 350 public function events_meta_box(){ 351 360 * 361 */ 362 public function events_meta_box(){ 363 352 364 ?> 353 365 <table border="0" cellspacing="0" cellpadding="2"> … … 360 372 </tr> 361 373 <?php 362 363 //We need a time zone to properly guess what dates the user means 364 $tz = get_option('timezone_string'); 365 if ( $tz ){ //Get and check if we have a valid time zone... 366 date_default_timezone_set($tz); //...if so, use it 367 } 368 else { //If there is no time zone... 369 date_default_timezone_set("Etc/GMT".get_option("gmt_offset")); //...we make fake it by using the ETC/GMT+7 or whatever. 370 } 371 374 372 375 $event_count = 0; 373 if ( is_array( $this->eventList ) ) { 376 if ( is_array( $this->eventList ) ) { 374 377 foreach ( $this->eventList as $thisEvent ) { 375 378 //If the user wants, cycle through the array to find out if they have already occured, if so: set them to NULL 376 if ( ( $this->deleteOneTimeEvents ) && ( $thisEvent <= new DateTime() ) && ( !$thisEvent->getTimeSince() ) ) {379 if ( ( $this->deleteOneTimeEvents ) && ( $thisEvent->getTimestamp() <= time() ) && ( !$thisEvent->getTimeSince() ) ) { 377 380 $thisEvent = NULL; 378 381 } … … 386 389 "size" => 30, 387 390 "name" => "fergcorp_countdownTimer_oneTimeEvent[{$event_count}][date]", 388 "value" => ($thisEvent->date("D, d M Y H:i:s "))391 "value" => ($thisEvent->date("D, d M Y H:i:s T")) 389 392 ) 390 393 )."</td>"; 391 394 392 395 echo "<td>".$this->build_input(array( 393 396 "type" => "text", … … 397 400 ) 398 401 )."</td>"; 399 402 400 403 echo "<td>".$this->build_input(array( 401 404 "type" => "text", … … 405 408 ) 406 409 )."</td>"; 407 410 408 411 echo "<td>".$this->build_input(array( 409 412 "type" => "checkbox", 410 413 "name" => "fergcorp_countdownTimer_oneTimeEvent[{$event_count}][timeSince]", 411 414 "value" => 1, 412 ), 415 ), 413 416 checked("1", $thisEvent->getTimeSince(), false) 414 417 )."</td>"; … … 430 433 ) 431 434 )."</td>"; 432 435 433 436 echo "<td>".$this->build_input(array( 434 437 "type" => "text", … … 437 440 ) 438 441 )."</td>"; 439 442 440 443 echo "<td>".$this->build_input(array( 441 444 "type" => "text", … … 465 468 ); 466 469 _e('Yes', 'fergcorp_countdownTimer'); 467 echo " :: "; 468 //...or No 470 echo " :: "; 471 //...or No 469 472 echo $this->build_input(array( 470 473 "type" => "radio", … … 480 483 /** 481 484 * Creates and defines the metabox for the installation box 482 * 485 * 483 486 * @package Countdown_Timer 484 487 * @author Andrew Ferguson 485 488 * @internal 3.0 486 489 * @access private 487 * 488 */ 490 * 491 */ 489 492 function installation_meta_box () { ?> 490 493 491 494 <p><?php printf(__("Countdown timer uses <a %s>PHP's strtotime function</a> and will parse about any English textual datetime description.", 'fergcorp_countdownTimer'), "href='http://us2.php.net/strtotime' target='_blank'"); ?></p> 492 495 <p><?php _e('Examples of some (but not all) valid dates', 'fergcorp_countdownTimer'); ?>:</p> … … 498 501 <li>last monday</li> 499 502 </ul> 500 503 501 504 <p><?php printf(__("To insert the Countdown Timer into your sidebar, you can use the <a %s>Countdown Timer Widget</a>.", 'fergcorp_countdownTimer'), "href='".admin_url('widgets.php')."'"); ?></p> 502 505 503 506 <p><?php printf(__("If you want to insert the Countdown Timer into a page or post, you can use the following <abbr %s %s>shortcodes</abbr> to return all or a limited number of Countdown Timers, respectively:", 'fergcorp_countdownTimer'), "title='".__('A shortcode is a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line. Shortcode = shortcut.', 'fergcorp_countdownTimer')."'", "style='cursor:pointer; border-bottom:1px black dashed'" ); ?></p> 504 507 <p> … … 508 511 </code> 509 512 </p> 510 <p><?php _e("Where <em>##</em> is maximum number of results to be displayed - ordered by date.", 'fergcorp_countdownTimer'); ?></p> 513 <p><?php _e("Where <em>##</em> is maximum number of results to be displayed - ordered by date.", 'fergcorp_countdownTimer'); ?></p> 511 514 <p><?php _e("If you want to insert individual countdown timers, such as in posts or on pages, you can use the following shortcode:", 'fergcorp_countdownTimer'); ?></p> 512 515 <p> … … 515 518 </code> 516 519 </p> 517 <p><?php printf(__("Where <em>ENTER_DATE_HERE</em> uses <a %s>PHP's strtotime function</a> and will parse about any English textual datetime description.", 'fergcorp_countdownTimer'), "href='http://us2.php.net/strtotime' target='_blank'"); ?></p> 518 <?php 520 <p><?php printf(__("Where <em>ENTER_DATE_HERE</em> uses <a %s>PHP's strtotime function</a> and will parse about any English textual datetime description.", 'fergcorp_countdownTimer'), "href='http://us2.php.net/strtotime' target='_blank'"); ?></p> 521 <?php 519 522 } 520 523 521 524 /** 522 525 * Creates and defines the metabox for the management box 523 * 526 * 524 527 * @package Countdown_Timer 525 528 * @author Andrew Ferguson 526 529 * @internal 3.0 527 530 * @access private 528 * 531 * 529 532 */ 530 533 function management_meta_box(){ … … 532 535 <p><?php _e("How long the timer remain visable if \"Display 'Time Since'\" is ticked:", 'fergcorp_countdownTimer'); ?><br /> 533 536 <?php _e("Seconds:", 'fergcorp_countdownTimer'); 534 537 535 538 echo $this->build_input(array( 536 539 "type" => "text", … … 539 542 "value" => $this->timeSinceTime 540 543 )); 541 544 542 545 _e("(0 = infinite; 86400 seconds = 1 day; 604800 seconds = 1 week)", "fergcorp_countdownTimer"); ?></p> 543 546 544 547 <p><?php _e('Enable JavaScript countdown:', 'fergcorp_countdownTimer'); 545 548 546 549 echo $this->build_yes_no("fergcorp_countdownTimer_enableJS", $this->enableJS); 547 550 548 551 ?> 549 552 </p> 550 553 551 554 <p><?php _e('By default, WordPress does not parse shortcodes that are in excerpts. If you want to enable this functionality, you can do so here. Note that this will enable the parsing of <em>all</em> shortcodes in the excerpt, not just the ones associated with Countdown Timer.', 'fergcorp_countdownTimer'); ?></p> 552 555 <p><?php _e('Enable shortcodes in the_excerpt:', 'fergcorp_countdownTimer'); 553 554 echo $this->build_yes_no("fergcorp_countdownTimer_enableShortcodeExcerpt", $this->enable dShortcodeExcerpt);556 557 echo $this->build_yes_no("fergcorp_countdownTimer_enableShortcodeExcerpt", $this->enableShortcodeExcerpt); 555 558 556 559 ?> … … 559 562 } 560 563 561 564 562 565 /** 563 566 * Creates and defines the metabox for the onHover time format box 564 * 567 * 565 568 * @package Countdown_Timer 566 569 * @author Andrew Ferguson 567 570 * @internal 3.0 568 571 * @access private 569 * 570 */ 572 * 573 */ 571 574 function onHover_time_format_meta_box(){ 572 575 ?> … … 584 587 "value" => $this->timeFormat 585 588 )); 586 587 589 590 588 591 echo "</p>"; 589 590 } 591 592 592 593 } 594 595 593 596 /** 594 597 * Creates and defines the metabox for the display format options box 595 * 598 * 596 599 * @package Countdown_Timer 597 600 * @author Andrew Ferguson 598 601 * {@internal since} 599 602 * @access private 600 * 601 */ 603 * 604 */ 602 605 function display_format_options_meta_box(){ 603 606 ?> … … 609 612 </ul> 610 613 <p><?php _e('Title Suffix', 'fergcorp_countdownTimer'); 611 614 612 615 echo $this->build_input(array( 613 616 "type" => "text", … … 618 621 echo "</p>"; 619 622 } 620 621 623 624 622 625 /** 623 626 * Creates and defines the metabox for the example display box 624 * 627 * 625 628 * @package Countdown_Timer 626 629 * @author Andrew Ferguson 627 630 * @internal 3.0 628 631 * @access private 629 * 630 */ 632 * 633 */ 631 634 function example_display_meta_box(){ 632 635 echo "<ul>"; … … 637 640 } 638 641 } 639 640 642 643 641 644 /** 642 645 * Creates a PHP-based one-off time for use outside the loop … … 648 651 */ 649 652 public function singleTimer( $date ){ 650 653 651 654 return $this->formatEvent( new Fergcorp_Countdown_Timer_Event( strtotime( $date ) ) , TRUE ); 652 655 653 656 } 654 657 … … 666 669 $this->eventsPresent = FALSE; 667 670 $toReturn = ""; 668 671 669 672 //Make sure there's something to count 670 673 if($this->eventList){ 671 674 $this->eventsPresent = TRUE; 672 675 } 673 676 674 677 $eventCount = count($this->eventList); 675 678 if($eventLimit != -1) //If the eventLimit is set … … 688 691 } 689 692 } 690 693 691 694 if(!$this->eventsPresent){ 692 695 $toReturn = __('No dates present', 'fergcorp_countdownTimer'); 693 696 } 694 697 695 698 //Echo or return 696 699 if($output) 697 700 echo $toReturn; 698 701 else 699 return $toReturn; 702 return $toReturn; 700 703 } 701 704 … … 717 720 * @return string The content of the post with the appropriate dates inserted (if any) 718 721 */ 719 function formatEvent($thisEvent, $standAlone = FALSE){ 722 function formatEvent($thisEvent, $standAlone = FALSE){ 720 723 $time_left = $thisEvent->getTimestamp() - time(); 721 724 722 725 $content = ''; 723 726 724 727 if(!$standAlone) 725 728 $content = "<li class = 'fergcorp_countdownTimer_event_li'>"; 726 729 727 730 $eventTitle = "<span class = 'fergcorp_countdownTimer_event_title'>".($thisEvent->getURL()==""?$thisEvent->getTitle():"<a href=\"".$thisEvent->getURL()."\" class = 'fergcorp_countdownTimer_event_linkTitle'>".$thisEvent->getTitle()."</a>").'</span>'.$this->titleSuffix."\n"; 728 731 729 732 if ($this->timeFormat == "") { 730 733 $this->timeFormat = get_option('date_format') . ", " . get_option('time_format'); 731 734 } 732 $timePrefix = "<abbr title = \"".date_i18n($this->timeFormat, $thisEvent->getTimestamp() , FALSE)."\" id = '".$thisEvent->getUID()."' class = 'fergcorp_countdownTimer_event_time'>";733 734 if ( ( $time_left <= 0 ) && 735 ( ( ( $thisEvent->getTimeSince() ) && 736 ( ( ( $time_left + $this->timeSinceTime ) > 0 ) || ( 0 ==$this->timeSinceTime ) ) )735 $timePrefix = "<abbr title = \"".date_i18n($this->timeFormat, $thisEvent->getTimestamp()+(3600*(get_option('gmt_offset'))), TRUE)."\" id = '".$thisEvent->getUID()."' class = 'fergcorp_countdownTimer_event_time'>"; 736 737 if ( ( $time_left <= 0 ) && 738 ( ( ( $thisEvent->getTimeSince() ) && 739 ( ( ( $time_left + (int) $this->timeSinceTime ) > 0 ) || ( 0 == (int) $this->timeSinceTime ) ) ) 737 740 || ( $standAlone) ) ) { 738 741 739 742 //If the event has already passed and we still want to display the event 740 743 741 744 $this->eventsPresent = TRUE; //Set to TRUE so we know there's an event to display 742 745 if ( $thisEvent->getTitle() ) { … … 747 750 elseif($time_left > 0){ //If the event has not yet happened yet 748 751 $this->eventsPresent = TRUE; //Set to TRUE so we know there's an event to display 749 752 750 753 if($thisEvent->getTitle()){ 751 754 $content .= $eventTitle; 752 755 } 753 $content .= $timePrefix.sprintf(__("in %s", 'fergcorp_countdownTimer'), $this->fuzzyDate($thisEvent->getTimestamp(), time() ) )."</abbr>"; 754 } 756 $content .= $timePrefix.sprintf(__("in %s", 'fergcorp_countdownTimer'), $this->fuzzyDate($thisEvent->getTimestamp(), time() ) )."</abbr>"; 757 } 755 758 else{ 756 759 return NULL; 757 760 } 758 761 759 762 array_push($this->jsUID, $thisEvent); 760 763 761 764 if(!$standAlone) 762 765 $content .= "</li>\r\n"; … … 776 779 */ 777 780 function fuzzyDate ( $targetTime, $nowTime ) { 778 781 779 782 $timeDelta = new Fergcorp_DeltaTime($targetTime, $nowTime); 780 783 … … 782 785 $s = ''; 783 786 $sigNumHit = false; 784 787 785 788 if($timeDelta->s < 0){ 786 789 $timeDelta->i--; … … 829 832 } 830 833 else{ 831 //If we don't want to show months, let's just calculate the exact number of seconds left since all other units of time are fixed (i.e. months are not a fixed unit of time) 834 //If we don't want to show months, let's just calculate the exact number of seconds left since all other units of time are fixed (i.e. months are not a fixed unit of time) 832 835 //If we showed years, but not months, we need to account for those. 833 836 if($this->showYear){ 834 837 $timeDelta->delta = $timeDelta->delta - $timeDelta->y*31536000; 835 838 } 836 839 837 840 //Re calculate the resultant times 838 $timeDelta->w = intval( $timeDelta->delta/(86400*7) ); 841 $timeDelta->w = intval( $timeDelta->delta/(86400*7) ); 839 842 $timeDelta->d = intval( $timeDelta->delta/86400 ); 840 843 $timeDelta->h = intval( ($timeDelta->delta - $timeDelta->d*86400)/3600 ); 841 844 $timeDelta->i = intval( ($timeDelta->delta - $timeDelta->d*86400 - $timeDelta->h*3600)/60 ); 842 845 $timeDelta->s = intval( ($timeDelta->delta - $timeDelta->d*86400 - $timeDelta->h*3600 - $timeDelta->i*60) ); 843 846 844 847 //and clear any rollover time 845 848 $rollover = 0; … … 850 853 if($sigNumHit || !$this->stripZero || ( ($timeDelta->d + intval($rollover/86400) )/7)){ 851 854 $timeDelta->w = $timeDelta->w + intval($rollover/86400)/7; 852 $s .= '<span class="fergcorp_countdownTimer_week fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d week,", "%d weeks,", (intval( ($timeDelta->d + intval($rollover/86400) )/7)), "fergcorp_countdownTimer"), (intval( ($timeDelta->d + intval($rollover/86400) )/7)))."</span> "; 855 $s .= '<span class="fergcorp_countdownTimer_week fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d week,", "%d weeks,", (intval( ($timeDelta->d + intval($rollover/86400) )/7)), "fergcorp_countdownTimer"), (intval( ($timeDelta->d + intval($rollover/86400) )/7)))."</span> "; 853 856 $rollover = $rollover - intval($rollover/86400)*86400; 854 857 $timeDelta->d = $timeDelta->d - intval( ($timeDelta->d + intval($rollover/86400) )/7 )*7; … … 899 902 if($this->showSecond){ 900 903 $timeDelta->s = $timeDelta->s + $rollover; 901 $s .= '<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d second,", "%d seconds,", $timeDelta->s, "fergcorp_countdownTimer"), $timeDelta->s) ."</span> ";902 } 903 904 $s .= '<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d second,", "%d seconds,", $timeDelta->s, "fergcorp_countdownTimer"), $timeDelta->s) . "</span> "; 905 } 906 904 907 //Catch blank statements 905 908 if($s==""){ 909 // @codeCoverageIgnoreStart 906 910 if($this->showSecond){ 907 $s = sprintf(_n("%d second,", "%d seconds,", "0", "fergcorp_countdownTimer"), "0");911 $s = '<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d second,", "%d seconds,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 908 912 } 909 913 elseif($this->showMinute){ 910 $s = sprintf(_n("%d minute,", "%d minute,", "0", "fergcorp_countdownTimer"), "0");914 $s = '<span class="fergcorp_countdownTimer_minute fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d minute,", "%d minutes,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 911 915 } 912 916 elseif($this->showHour){ 913 $s = sprintf(_n("%d hour,", "%d hour,", "0", "fergcorp_countdownTimer"), "0");914 } 917 $s = '<span class="fergcorp_countdownTimer_hour fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d hour,", "%d hours,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 918 } 915 919 elseif($this->showDay){ 916 $s = sprintf(_n("%d day,", "%d day,", "0", "fergcorp_countdownTimer"), "0");917 } 920 $s = '<span class="fergcorp_countdownTimer_day fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d day,", "%d days,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 921 } 918 922 elseif($this->showWeek){ 919 $s = sprintf(_n("%d week,", "%d week,", "0", "fergcorp_countdownTimer"), "0");923 $s = '<span class="fergcorp_countdownTimer_week fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d week,", "%d weeks,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 920 924 } 921 925 elseif($this->showMonth){ 922 $s = sprintf(_n("%d month,", "%d month,", "0", "fergcorp_countdownTimer"), "0"); 923 } 926 $s = '<span class="fergcorp_countdownTimer_month fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d month,", "%d months,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 927 } 928 // @codeCoverageIgnoreEnd 924 929 else{ 925 $s = sprintf(_n("%d year,", "%d year,", "0", "fergcorp_countdownTimer"), "0");930 $s = '<span class="fergcorp_countdownTimer_year fergcorp_countdownTimer_timeUnit">' . sprintf(_n("%d year,", "%d years,", "0", "fergcorp_countdownTimer"), "0") . "</span> "; 926 931 } 927 932 } 928 933 return preg_replace("/(, ?<\/span> *)$/is", "</span>", $s); 929 934 } 930 935 931 936 /** 932 937 * Processes [fergcorp_cdt max=##] shortcode … … 937 942 * @author Andrew Ferguson 938 943 * @return string countdown timer(s) 939 */ 944 */ 940 945 function shortcode_showTimer($atts) { 941 946 extract(shortcode_atts(array( … … 943 948 ), 944 949 $atts)); 945 950 946 951 return $this->showTimer($max, FALSE); 947 952 } 948 953 949 954 /** 950 955 * Processes [fergcorp_cdt_single date="_DATE_"] shortcode … … 955 960 * @author Andrew Ferguson 956 961 * @return string countdown timer 957 */ 962 */ 958 963 function shortcode_singleTimer($atts) { 959 964 extract(shortcode_atts(array( 960 965 'date' => '-1', 961 966 ), $atts)); 962 967 963 968 return $this->singleTimer( $date ); 964 969 } 965 966 970 971 967 972 /** 968 973 * Initialized the options … … 990 995 } 991 996 997 public function compare($adate, $bdate) 998 { 999 if($adate < $bdate){ 1000 return -1; 1001 }else if($adate == $bdate){ 1002 return 0; 1003 }else{ 1004 return 1; 1005 } 1006 } 1007 992 1008 /** 993 1009 * Sanitize the callback … … 996 1012 * @access public 997 1013 * @author Andrew Ferguson 998 */ 1014 */ 999 1015 public function sanitize($input){ 1000 1016 1001 1017 $event_object_array = array(); 1002 1003 //We need a time zone to properly guess what dates the user means1004 $tz = get_option('timezone_string');1005 if ( $tz ){ //Get and check if we have a valid time zone...1006 date_default_timezone_set($tz); //...if so, use it1007 }1008 else { //If there is no time zone...1009 date_default_timezone_set("Etc/GMT".get_option("gmt_offset")); //...we make fake it by using the ETC/GMT+7 or whatever.1010 }1011 1018 1012 1019 foreach($input as $event){ … … 1018 1025 } 1019 1026 } 1020 1027 1021 1028 /*Begin sorting events by time*/ 1022 function cmp($adate, $bdate) { 1023 if($adate < $bdate){ 1024 return -1; 1025 }else if($adate == $bdate){ 1026 return 0; 1027 }else{ 1028 return 1; 1029 } 1030 } 1031 usort($event_object_array, 'cmp'); 1029 usort($event_object_array, array($this,'compare')); 1032 1030 return $event_object_array; 1033 1031 } … … 1035 1033 1036 1034 function json(){ 1037 $params = array( 1035 $params = array( 1038 1036 "showYear" =>$this->showYear, 1039 1037 "showMonth" =>$this->showMonth, … … 1045 1043 "stripZero" =>$this->stripZero, 1046 1044 ); 1047 1045 1048 1046 $js_events = array(); 1049 1047 foreach($this->jsUID as $event){ … … 1054 1052 "year" => addslashes( _n( "%d year,", "%d years,", 1, "fergcorp_countdownTimer" )), 1055 1053 "years" => addslashes( _n( "%d year,", "%d years,", 2, "fergcorp_countdownTimer" )), 1056 1054 1057 1055 "month" => addslashes( _n( "%d month,", "%d months,", 1, "fergcorp_countdownTimer" )), 1058 1056 "months" => addslashes( _n( "%d month,", "%d months,", 2, "fergcorp_countdownTimer" )), 1059 1057 1060 1058 "week" => addslashes( _n( "%d week,", "%d weeks,", 1, "fergcorp_countdownTimer" )), 1061 1059 "weeks" => addslashes( _n( "%d week,", "%d weeks,", 2, "fergcorp_countdownTimer" )), 1062 1060 1063 1061 "day" => addslashes( _n( "%d day,", "%d days,", 1, "fergcorp_countdownTimer" )), 1064 1062 "days" => addslashes( _n( "%d day,", "%d days,", 2, "fergcorp_countdownTimer" )), 1065 1063 1066 1064 "hour" => addslashes( _n( "%d hour,", "%d hours,", 1, "fergcorp_countdownTimer" )), 1067 1065 "hours" => addslashes( _n( "%d hour,", "%d hours,", 2, "fergcorp_countdownTimer" )), 1068 1066 1069 1067 "minute" => addslashes( _n( "%d minute,", "%d minutes,", 1, "fergcorp_countdownTimer" )), 1070 1068 "minutes" => addslashes( _n( "%d minute,", "%d minutes,", 2, "fergcorp_countdownTimer" )), 1071 1069 1072 1070 "second" => addslashes( _n( "%d second,", "%d seconds,", 1, "fergcorp_countdownTimer" )), 1073 1071 "seconds" => addslashes( _n( "%d second,", "%d seconds,", 2, "fergcorp_countdownTimer" )), 1074 1072 1075 1073 1076 1074 "agotime" => addslashes(__('%s ago', 'fergcorp_countdownTimer')), … … 1078 1076 ); 1079 1077 wp_localize_script( 'fergcorp_countdowntimer', 'fergcorp_countdown_timer_js_lang', $js_lang); 1080 wp_localize_script( 'fergcorp_countdowntimer', 'fergcorp_countdown_timer_jsEvents', $js_events ); 1078 wp_localize_script( 'fergcorp_countdowntimer', 'fergcorp_countdown_timer_jsEvents', $js_events ); 1081 1079 wp_localize_script( 'fergcorp_countdowntimer', 'fergcorp_countdown_timer_options', $params ); 1082 1080 } … … 1092 1090 $plugin_data = get_plugin_data(__FILE__); 1093 1091 1092 //Don't test for now 1093 // @codeCoverageIgnoreStart 1094 1094 //Move widget details from old option to new option only if the new option does not exist 1095 if( ( $oldWidget = get_option( "widget_fergcorp_countdown" ) ) && (!get_option( "widget_fergcorp_countdown_timer_widget" ) ) ) { 1095 if( ( $oldWidget = get_option( "widget_fergcorp_countdown" ) ) && (!get_option( "widget_fergcorp_countdown_timer_widget" ) ) ) { 1096 1096 update_option("widget_fergcorp_countdown_timer_widget", array( "title" => $oldWidget["title"], 1097 1097 "countLimit" => $oldWidget["count"], 1098 1098 ) 1099 ); 1099 ); 1100 1100 delete_option("widget_fergcorp_countdown"); 1101 1101 1102 1102 global $sidebars_widgets; 1103 1103 //check to see if the old widget is being used … … 1108 1108 if( 'wp_inactive_widgets' == $sidebar ) 1109 1109 continue; 1110 1110 1111 1111 if ( is_array($widgets) ) { 1112 1112 foreach ( $widgets as $widget ) { … … 1120 1120 wp_set_sidebars_widgets($sidebars_widgets); 1121 1121 wp_get_sidebars_widgets(); 1122 1123 1124 1122 1123 1124 1125 1125 } 1126 1126 //If the old option exist and the new option exists (becuase of the above logic test), don't update the new option and just remove the old option … … 1128 1128 delete_option("widget_fergcorp_countdown"); 1129 1129 } 1130 1130 // @codeCoverageIgnoreEnd 1131 1132 // @codeCoverageIgnoreStart 1131 1133 //Move timeFormat data from old option to new option only if the new option does not exist 1132 if( ( $timeOffset = get_option( "fergcorp_countdownTimer_timeOffset" ) ) && (!get_option( "fergcorp_countdownTimer_timeFormat" ) ) ) { 1134 if( ( $timeOffset = get_option( "fergcorp_countdownTimer_timeOffset" ) ) && (!get_option( "fergcorp_countdownTimer_timeFormat" ) ) ) { 1133 1135 update_option( 'fergcorp_countdownTimer_timeFormat', $timeOffset); 1134 delete_option("fergcorp_countdownTimer_timeOffset"); 1136 delete_option("fergcorp_countdownTimer_timeOffset"); 1135 1137 } 1136 1138 //If the old option exist and the new option exists (becuase of the above logic test), don't update the new option and just remove the old option 1137 elseif( $timeOffset ){ 1139 elseif( $timeOffset ){ 1138 1140 delete_option("fergcorp_countdownTimer_timeOffset"); 1139 1141 } 1140 1142 // @codeCoverageIgnoreEnd 1143 1144 // @codeCoverageIgnoreStart 1141 1145 $oneTimeEvent = get_option("fergcorp_countdownTimer_oneTimeEvent"); 1142 1146 if( ( $oneTimeEvent ) && ( gettype($oneTimeEvent[0]) == "array") ) { … … 1144 1148 foreach( $oneTimeEvent as $event ) { 1145 1149 array_push($event_object_array, new Fergcorp_Countdown_Timer_Event($event["date"], $event["text"], $event["link"], $event["timeSince"])); 1146 } 1150 } 1147 1151 update_option("fergcorp_countdownTimer_oneTimeEvent", $event_object_array); 1148 1152 } 1153 // @codeCoverageIgnoreEnd 1154 1155 //Install the defaults 1156 $this->install_option('fergcorp_countdownTimer_', 'deleteOneTimeEvents', '0'); 1157 $this->install_option('fergcorp_countdownTimer_', 'timeFormat', 'F jS, Y, g:i a'); 1158 $this->install_option('fergcorp_countdownTimer_', 'showYear', '1'); 1159 $this->install_option('fergcorp_countdownTimer_', 'showMonth', '1'); 1160 $this->install_option('fergcorp_countdownTimer_', 'showWeek', '0'); 1161 $this->install_option('fergcorp_countdownTimer_', 'showDay', '1'); 1162 $this->install_option('fergcorp_countdownTimer_', 'showHour', '1'); 1163 $this->install_option('fergcorp_countdownTimer_', 'showMinute', '1'); 1164 $this->install_option('fergcorp_countdownTimer_', 'showSecond', '0'); 1165 $this->install_option('fergcorp_countdownTimer_', 'stripZero', '1'); 1166 $this->install_option('fergcorp_countdownTimer_', 'enableJS', '1'); 1167 $this->install_option('fergcorp_countdownTimer_', 'timeSinceTime', '0'); 1168 $this->install_option('fergcorp_countdownTimer_', 'titleSuffix', ':<br />'); 1169 $this->install_option('fergcorp_countdownTimer_', 'enableShortcodeExcerpt', '0'); 1170 $this->install_option('fergcorp_countdownTimer_', 'oneTimeEvent', '0'); 1171 1172 //Update version number...last thing 1173 update_option("fergcorp_countdownTimer_version", $plugin_data["Version"]); 1174 } 1149 1175 1150 1176 /** … … 1160 1186 */ 1161 1187 function install_option($prefix, $option, $default){ 1162 if(get_option($prefix.$option) != NULL){ 1188 if(get_option($prefix.$option) != NULL){ 1163 1189 return false; 1164 1190 } … … 1168 1194 } 1169 1195 } 1170 //Install the defaults1171 install_option('fergcorp_countdownTimer_', 'deleteOneTimeEvents', '0');1172 install_option('fergcorp_countdownTimer_', 'timeFormat', 'F jS, Y, g:i a');1173 install_option('fergcorp_countdownTimer_', 'showYear', '1');1174 install_option('fergcorp_countdownTimer_', 'showMonth', '1');1175 install_option('fergcorp_countdownTimer_', 'showWeek', '0');1176 install_option('fergcorp_countdownTimer_', 'showDay', '1');1177 install_option('fergcorp_countdownTimer_', 'showHour', '1');1178 install_option('fergcorp_countdownTimer_', 'showMinute', '1');1179 install_option('fergcorp_countdownTimer_', 'showSecond', '0');1180 install_option('fergcorp_countdownTimer_', 'stripZero', '1');1181 install_option('fergcorp_countdownTimer_', 'enableJS', '1');1182 install_option('fergcorp_countdownTimer_', 'timeSinceTime', '0');1183 install_option('fergcorp_countdownTimer_', 'titleSuffix', ':<br />');1184 install_option('fergcorp_countdownTimer_', 'enableShortcodeExcerpt', '0');1185 install_option('fergcorp_countdownTimer_', 'oneTimeEvent', '0');1186 1187 //Update version number...last thing1188 update_option("fergcorp_countdownTimer_version", $plugin_data["Version"]);1189 }1190 1196 1191 1197 /** 1192 1198 * Builds <input> HTML 1193 * 1199 * 1194 1200 * @package Countdown_Timer 1195 1201 * @author Andrew Ferguson … … 1199 1205 * @param string $inputString 1200 1206 * $return string HMTL code 1201 */ 1207 */ 1202 1208 public function build_input($inputArray, $inputString=''){ 1203 1209 $attributes = ""; … … 1209 1215 /** 1210 1216 * Builds Yes/No <input> HTML 1211 * 1217 * 1212 1218 * @package Countdown_Timer 1213 1219 * @author Andrew Ferguson … … 1217 1223 * @param string $option 1218 1224 * $return string HMTL code 1219 */ 1225 */ 1220 1226 public function build_yes_no($name, $option){ 1221 1227 //Yes … … 1226 1232 ), 1227 1233 checked("1", $option, false) 1228 ); 1234 ); 1229 1235 $output .= __('Yes', 'fergcorp_countdownTimer'); 1230 1236 $output .= " :: "; … … 1236 1242 ), 1237 1243 checked("0", $option, false) 1238 ); 1244 ); 1239 1245 $output .= __('No', 'fergcorp_countdownTimer'); 1240 1246 1241 1247 return $output; 1242 } 1248 } 1243 1249 } 1244 1250 … … 1249 1255 private $timeSince; 1250 1256 private $UID; 1251 1257 1252 1258 public function __construct ($time, $title = NULL, $url = NULL, $timeSince = NULL){ 1253 1259 $this->setTitle($title); … … 1258 1264 parent::__construct("@".$time); 1259 1265 } 1260 1261 public function getTimestamp() {1266 1267 /*public function getTimestamp() { 1262 1268 return method_exists('DateTime', 'getTimestamp') ? parent::getTimestamp() : $this->time; 1263 } 1264 1269 }*/ 1270 1265 1271 public function setTitle ( $title ) { 1266 1272 $this->title = (string)$title; 1267 1273 } 1268 1274 1269 1275 public function setTime ( $time ) { 1270 1276 $this->time = $time; 1271 1277 } 1272 1278 1273 1279 public function setURL ( $url ) { 1274 1280 $this->url = $url; 1275 1281 } 1276 1282 1277 1283 public function setTimeSince ( $timeSince ) { 1278 1284 $this->timeSince = $timeSince; 1279 1285 } 1280 1286 1281 1287 public function getTitle () { 1282 1288 return $this->title; 1283 1289 } 1284 1290 1285 1291 public function getTime () { 1286 1292 return $this->time; 1287 1293 } 1288 1294 1289 1295 public function getURL () { 1290 1296 return $this->url; 1291 1297 } 1292 1298 1293 1299 public function getTimeSince () { 1294 1300 return $this->timeSince; 1295 1301 } 1296 1302 1297 1303 public function getUID () { 1298 1304 return $this->UID; 1299 1305 } 1300 1306 1301 1307 public function date ( $format ) { 1302 1308 return date($format, $this->getTimestamp()); 1303 }1304 }1305 1306 if(!function_exists("cal_days_in_month")){1307 /**1308 * Returns the number of days in a given month and year, taking into account leap years.1309 * The is a replacement function should cal_days_in_month not be availible1310 *1311 * @param $calendar int ignored1312 * @param $month int month (integers 1-12)1313 * @param $year int year (any integer)1314 * @since 2.31315 * @access private1316 * @author David Bindel (dbindel at austin dot rr dot com) (http://us.php.net/manual/en/function.cal-days-in-month.php#38666)1317 * @author ben at sparkyb dot net1318 * @return int The content of the post with the appropriate dates inserted (if any)1319 */1320 function cal_days_in_month($calendar, $month, $year){1321 // calculate number of days in a month1322 return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);1323 1309 } 1324 1310 } 1325 1311 /** 1326 1312 * Widget class for Countdown Timer 1327 * 1313 * 1328 1314 * @since 3.0 1329 1315 * @access public … … 1331 1317 */ 1332 1318 class Fergcorp_Countdown_Timer_Widget extends WP_Widget{ 1333 1319 1334 1320 public function __construct(){ 1335 1321 global $fergcorp_countdownTimer_init; … … 1340 1326 ); 1341 1327 } 1342 1328 1343 1329 public function form( $instance){ 1344 1330 1345 1331 if ( $instance ) { 1346 1332 $title = esc_attr( $instance['title'] ); … … 1351 1337 $countLimit = -1; 1352 1338 } 1353 1339 1354 1340 ?> 1355 1341 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' , 'fergcorp_countdownTimer'); ?></label> … … 1360 1346 <?php 1361 1347 } 1362 1348 1363 1349 public function update( $new_instance, $old_instance ){ 1364 1350 $instance['title'] = strip_tags( $new_instance['title'] ); 1365 1351 $instance['countLimit'] = intval($new_instance['countLimit']); 1366 1352 return $instance; 1367 1368 } 1369 1353 1354 } 1355 1370 1356 public function widget( $args, $instance ){ 1371 global $fergcorp_countdownTimer_init; 1357 global $fergcorp_countdownTimer_init; 1372 1358 echo $args['before_widget']; 1373 1359 if ( ! empty( $instance['title'] ) ) { … … 1379 1365 $fergcorp_countdownTimer_init->showTimer($instance['countLimit']); 1380 1366 echo "</ul>"; 1381 1367 1382 1368 echo $args['after_widget']; 1383 1369 1384 1370 } 1385 1371 } 1386 1372 1387 1373 class Fergcorp_DeltaTime{ 1388 1374 1389 1375 public $nowYear; 1390 1376 public $nowMonth; … … 1393 1379 public $nowMinute; 1394 1380 public $nowSecond; 1395 1381 1396 1382 public $targetYear; 1397 1383 public $targetMonth; … … 1400 1386 public $targetMinute; 1401 1387 public $targetSecond; 1402 1388 1403 1389 public $y; 1404 1390 public $m; … … 1407 1393 public $i; 1408 1394 public $s; 1409 1395 1410 1396 public $w; 1411 1397 1412 1398 public $delta; 1413 1399 1414 1400 public function __construct($targetTime, $nowTime){ 1415 1401 $this->nowYear = date("Y", $nowTime); … … 1419 1405 $this->nowMinute = date("i", $nowTime); 1420 1406 $this->nowSecond = date("s", $nowTime); 1421 1407 1422 1408 $this->targetYear = date("Y", $targetTime); 1423 1409 $this->targetMonth = date("m", $targetTime); … … 1426 1412 $this->targetMinute = date("i", $targetTime); 1427 1413 $this->targetSecond = date("s", $targetTime); 1428 1414 1429 1415 $this->y = $this->targetYear - $this->nowYear; 1430 1416 $this->m = $this->targetMonth - $this->nowMonth; … … 1433 1419 $this->i = $this->targetMinute - $this->nowMinute; 1434 1420 $this->s = $this->targetSecond - $this->nowSecond; 1435 1421 1436 1422 $this->delta = $targetTime - $nowTime; 1437 1423 } … … 1443 1429 1444 1430 function fergcorp_countdownTimer($countLimit = -1) { 1445 global $fergcorp_countdownTimer_init; 1431 global $fergcorp_countdownTimer_init; 1446 1432 $fergcorp_countdownTimer_init->showTimer($countLimit, TRUE); 1447 1433 } … … 1451 1437 // Load localization domain 1452 1438 load_plugin_textdomain( 'fergcorp_countdownTimer', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); 1453 1439 1454 1440 $fergcorp_countdownTimer_init = new Fergcorp_Countdown_Timer(); 1455 1441 } -
countdown-timer/trunk/js/fergcorp_countdownTimer_java.js
r561478 r651785 7 7 c-=7*parseInt((c+parseInt(a/86400))/7),i=!0;if(parseInt(b.showDay)){if(i||!parseInt(b.stripZero)||c+parseInt(a/86400))c+=parseInt(a/86400),f=f+'<span class="fergcorp_countdownTimer_day fergcorp_countdownTimer_timeUnit">'+sprintf(_n(fergcorp_countdown_timer_js_lang.day,fergcorp_countdown_timer_js_lang.days,c),c)+"</span> ",a-=86400*parseInt(a/86400),i=!0}else a+=86400*c;if(parseInt(b.showHour)){if(i||!parseInt(b.stripZero)||g+parseInt(a/3600))g+=parseInt(a/3600),f=f+'<span class="fergcorp_countdownTimer_hour fergcorp_countdownTimer_timeUnit">'+ 8 8 sprintf(_n(fergcorp_countdown_timer_js_lang.hour,fergcorp_countdown_timer_js_lang.hours,g),g)+"<span> ",a-=3600*parseInt(a/3600),i=!0}else a+=3600*g;if(parseInt(b.showMinute)){if(i||!parseInt(b.stripZero)||h+parseInt(a/60))h+=parseInt(a/60),f=f+'<span class="fergcorp_countdownTimer_minute fergcorp_countdownTimer_timeUnit">'+sprintf(_n(fergcorp_countdown_timer_js_lang.minute,fergcorp_countdown_timer_js_lang.minutes,h),h)+"</span> ",a-=60*parseInt(a/60)}else a+=60*h;parseInt(b.showSecond)&&(l+=a,f= 9 f+'<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">'+sprintf(_n(fergcorp_countdown_timer_js_lang.second,fergcorp_countdown_timer_js_lang.seconds,l),l)+"</span> ");""==f&&(f=parseInt(b.showSecond)?sprintf(fergcorp_countdown_timer_js_lang.seconds,0):parseInt(b.showMinute)?sprintf(fergcorp_countdown_timer_js_lang.minutes,0):parseInt(b.showHour)?sprintf(fergcorp_countdown_timer_js_lang.hours,0):parseInt(b.showDay)?sprintf(fergcorp_countdown_timer_js_lang.days,0):parseInt(b.showWeek)? 10 sprintf(fergcorp_countdown_timer_js_lang.weeks,0):parseInt(b.showMonth)?sprintf(fergcorp_countdown_timer_js_lang.months,0):sprintf(fergcorp_countdown_timer_js_lang.years,0));return f.replace(/(, ?<\/span> *)$/,"</span>")}fergcorp_countdownTimer_js(); 9 f+'<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">'+sprintf(_n(fergcorp_countdown_timer_js_lang.second,fergcorp_countdown_timer_js_lang.seconds,l),l)+"</span> ");""==f&&(f=parseInt(b.showSecond)?'<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.seconds,0)+"</span> ":parseInt(b.showMinute)?'<span class="fergcorp_countdownTimer_minute fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.minutes, 10 0)+"</span> ":parseInt(b.showHour)?'<span class="fergcorp_countdownTimer_hour fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.hours,0)+"</span> ":parseInt(b.showDay)?'<span class="fergcorp_countdownTimer_day fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.days,0)+"</span> ":parseInt(b.showWeek)?'<span class="fergcorp_countdownTimer_week fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.weeks,0)+"</span> ":parseInt(b.showMonth)? 11 '<span class="fergcorp_countdownTimer_month fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.months,0)+"</span> ":'<span class="fergcorp_countdownTimer_year fergcorp_countdownTimer_timeUnit">'+sprintf(fergcorp_countdown_timer_js_lang.years,0)+"</span> ");return f.replace(/(, ?<\/span> *)$/,"</span>")}fergcorp_countdownTimer_js(); -
countdown-timer/trunk/js/fergcorp_countdownTimer_java_debug.js
r567188 r651785 222 222 if(s==''){ 223 223 if(parseInt( getOptions['showSecond'] )){ 224 s = sprintf(fergcorp_countdown_timer_js_lang.seconds, 0);224 s = '<span class="fergcorp_countdownTimer_second fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.seconds, 0) + '</span> '; 225 225 } 226 226 else if(parseInt( getOptions['showMinute'] )){ 227 s = sprintf(fergcorp_countdown_timer_js_lang.minutes, 0);227 s = '<span class="fergcorp_countdownTimer_minute fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.minutes, 0) + '</span> '; 228 228 } 229 229 else if(parseInt( getOptions['showHour'] )){ 230 s = sprintf(fergcorp_countdown_timer_js_lang.hours, 0);230 s = '<span class="fergcorp_countdownTimer_hour fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.hours, 0) + '</span> '; 231 231 } 232 232 else if(parseInt( getOptions['showDay'] )){ 233 s = sprintf(fergcorp_countdown_timer_js_lang.days, 0);233 s = '<span class="fergcorp_countdownTimer_day fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.days, 0) + '</span> '; 234 234 } 235 235 else if(parseInt( getOptions['showWeek'] )){ 236 s = sprintf(fergcorp_countdown_timer_js_lang.weeks, 0);236 s = '<span class="fergcorp_countdownTimer_week fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.weeks, 0) + '</span> '; 237 237 } 238 238 else if(parseInt( getOptions['showMonth'] )){ 239 s = sprintf(fergcorp_countdown_timer_js_lang.months, 0);239 s = '<span class="fergcorp_countdownTimer_month fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.months, 0) + '</span> '; 240 240 } 241 241 else{ 242 s = sprintf(fergcorp_countdown_timer_js_lang.years, 0);242 s = '<span class="fergcorp_countdownTimer_year fergcorp_countdownTimer_timeUnit">' + sprintf(fergcorp_countdown_timer_js_lang.years, 0) + '</span> '; 243 243 } 244 244 } -
countdown-timer/trunk/readme.txt
r567188 r651785 3 3 Donate link: http://www.andrewferguson.net/2007/03/08/general-note/ 4 4 Tags: countdown, timer, count, date, event, widget, countup, age, fun, time, international, i18n, countdown timer, wedding, localization, i18n 5 Requires at least: 3. 45 Requires at least: 3.5 6 6 Tested up to: 3.5 7 Stable tag: 3.0. 37 Stable tag: 3.0.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 175 175 2. Example on Blog 176 176 177 == Upgrade Notice == 178 = 3.0.4 = 179 A couple of major bug fixes 180 177 181 == Changelog == 182 183 184 = 3.0.4 = 185 Release date: 1/12/2013 186 187 * Bug fix: Least Common Unit will now display correctly 188 * Bug fix: Solve issues with admin page not loading 189 * Removed "cal_days_in_month" as everyone should be at the PHP level that supports this now 190 * Wrote unit test suite 178 191 179 192 = 3.0.3 = … … 499 512 500 513 Initial public release 501 502 == Upgrade Notice ==503 = 2.4.2 =504 Fixes bug where using fergcorp_countdownTimer function with event limits argument would limit events incorrectly. Fixed issue with translations not working.
Note: See TracChangeset
for help on using the changeset viewer.