Plugin Directory

Changeset 651785


Ignore:
Timestamp:
01/13/2013 02:02:19 AM (13 years ago)
Author:
fergbrain
Message:

Version 3.0.4

Location:
countdown-timer/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • countdown-timer/trunk

    • Property svn:ignore set to
      deploy.sh
      README.md
      .git
      .gitignore
      assets
  • countdown-timer/trunk/.gitignore

    r517705 r651785  
    11.project
     2countdown-timer.sublime-project
     3countdown-timer.sublime-workspace
     4fergcorp_debug.php
     5phpunit.xml
     6tests/bootstrap.php
     7tests/countdown-timer/CountDownTimerTest.php
     8unit_test.php
     9assets
     10assets/banner-772x250.jpg
     11report
  • countdown-timer/trunk/fergcorp_countdownTimer.php

    r567188 r651785  
    44Plugin URI: http://www.andrewferguson.net/wordpress-plugins/countdown-timer/
    55Description: 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.3
     6Version: 3.0.4
    77Author: Andrew Ferguson
    88Author URI: http://www.andrewferguson.net
    99
    1010Countdown 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-2012 Andrew Ferguson
     11Copyright (c) 2005-2013 Andrew Ferguson
    1212
    1313This program is free software; you can redistribute it and/or
     
    3333@param      type        $varname    Description
    3434@return     type                    Description
    35 @todo       
     35@todo
    3636
    3737*/
     
    3939/**
    4040 * Main class for Countdown related activities
    41  * 
     41 *
    4242 * @package Countdown_Timer
    4343 * @author Andrew Ferguson
     
    4646 */
    4747class Fergcorp_Countdown_Timer{
    48        
     48
    4949    //Per instance
    5050    private $eventList;
    5151    private $eventsPresent;
    5252    private $jsUID = array();
    53    
     53
    5454    //Settings
    5555    private $deleteOneTimeEvents;
     
    6666    private $timeSinceTime;
    6767    private $titleSuffix;
    68     private $enabledShortcodeExcerpt;   
    69    
     68    private $enableShortcodeExcerpt;
     69
    7070    private $version;
    71    
     71
    7272    /**
    7373     * Load settings
    74      * 
     74     *
    7575     * @since 3.0.4
    7676     * @access public
     
    7878     */
    7979    public function loadSettings(){
    80            
     80
    8181        $this->version = get_option("fergcorp_countdownTimer_version");
    8282        $this->deleteOneTimeEvents = get_option("fergcorp_countdownTimer_deleteOneTimeEvents");
     
    9393        $this->timeSinceTime = get_option("fergcorp_countdownTimer_timeSinceTime");
    9494        $this->titleSuffix = get_option("fergcorp_countdownTimer_titleSuffix");
    95         $this->enabledShortcodeExcerpt = get_option("fergcorp_countdownTimer_enableShortcodeExcerpt");
    96        
     95        $this->enableShortcodeExcerpt = get_option("fergcorp_countdownTimer_enableShortcodeExcerpt");
     96
    9797        $this->eventList  = get_option("fergcorp_countdownTimer_oneTimeEvent"); //Get the events from the WPDB to make sure a fresh copy is being used
    9898    }
    99    
    100    
    101    
     99
     100
     101
    102102    /**
    103103     * Default construct to initialize settings required no matter what
    104      * 
     104     *
    105105     * @since 3.0
    106106     * @access public
     
    108108     */
    109109    public function __construct(){
    110         // Load settings       
     110        // Load settings
    111111        $this->loadSettings();
    112112
    113         if(version_compare($this->version, "3.0.2", "<")){
     113        if(version_compare($this->version, "3.0.4", "<")){
    114114            add_action('admin_init', array( &$this, 'install' ) );
    115115            add_action('admin_init', array( &$this, 'loadSettings' ) );
    116            
     116
    117117        }
    118118
     
    120120        wp_register_script('webkit_sprintf', plugins_url(dirname(plugin_basename(__FILE__)) . "/js/" . 'webtoolkit.sprintf.js'), FALSE, $this->version);
    121121        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
    123123        if($this->enableJS) {
    124124            add_action('wp_footer', array ( &$this, 'json' ) );
    125125        }
    126    
    127 
    128         if($this->enabledShortcodeExcerpt) {
     126
     127
     128        if($this->enableShortcodeExcerpt) {
    129129            add_filter('the_excerpt', 'do_shortcode');
    130130        }
     
    132132        //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.
    133133        add_action('wp_head', array( &$this, 'print_countdown_scripts' ), 1);
    134        
     134
    135135        //Admin hooks
    136136        add_action('admin_init', array( &$this, 'register_settings' ) );            //Initialized the options
    137137        add_action('admin_menu', array( &$this, 'register_settings_page' ) );   //Add Action for adding the options page to admin panel
    138        
     138
    139139        add_shortcode('fergcorp_cdt_single', array ( &$this, 'shortcode_singleTimer' ) );
    140140        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' ) );
    141146       
    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
    148153    /**
    149154     * Add settings link on plugin page
    150      * 
     155     *
    151156     * @since 3.0
    152157     * @access public
    153158     * @author c.bavota (http://bavotasan.com/2009/a-settings-link-for-your-wordpress-plugins/)
     159     * @codeCoverageIgnore
    154160     */
    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
    162167    /**
    163168     * Loads the appropriate scripts when in the admin page
     
    170175        wp_enqueue_script('postbox'); //These appear to be new functions in WP 2.5
    171176    }
    172        
     177
    173178    /**
    174179     * Loads the appropriate scripts for running the timer
     
    179184     */
    180185    public function print_countdown_scripts(){
    181         if($this->enableJS) {   
     186        if($this->enableJS) {
    182187            wp_enqueue_script('fergcorp_countdowntimer');
    183188            wp_enqueue_script('webkit_sprintf');
    184189
    185190        }
    186     }
    187    
     191        else{
     192            wp_dequeue_script('fergcorp_countdowntimer');
     193            wp_dequeue_script('webkit_sprintf');
     194        }
     195    }
     196
    188197    /**
    189198     * Adds the management page in the admin menu
     
    198207        add_action( 'admin_print_scripts-' . $settings_page, array( &$this, 'print_countdown_scripts' ) );
    199208    }
    200    
     209
    201210    /**
    202211     * Settings page
    203      * 
     212     *
    204213     * @since 3.0
    205214     * @access private
     
    207216     */
    208217    public function settings_page(){ ?>
    209    
     218
    210219        <script type="text/javascript">
    211         // <![CDATA[   
     220        // <![CDATA[
    212221            jQuery(document).ready( function($) {
    213222                // close postboxes that should be closed
    214223                jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
    215                
     224
    216225                // postboxes setup
    217226                postboxes.add_postbox_toggles('fergcorp-countdown-timer'); //For WP2.7 and above
    218    
     227
    219228            });
    220            
     229
    221230            function clearField(eventType, fieldNum){ //For deleting events without reloading
    222231                var agree=confirm('<?php _e('Are you sure you wish to delete', 'fergcorp_countdownTimer'); ?> '+document.getElementsByName(eventType+'['+fieldNum+'][text]').item(0).value+'?');
     
    248257        // ]]>
    249258        </script>
    250        
     259
    251260        <div class="wrap" id="fergcorp_countdownTimer_div">
    252261            <h2>Countdown Timer</h2>
    253262            <div id="poststuff">
    254                
     263
    255264            <?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&amp;type=wishlist&amp;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&amp;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');
    279267                ?>
    280        
     268
    281269                <form method="post" action="options.php">
    282            
     270
    283271                <input type="hidden" name="fergcorp_countdownTimer_noncename" id="fergcorp_countdownTimer_noncename" value="<?php wp_create_nonce( plugin_basename(__FILE__) );?>" />
    284                
     272
    285273                <?php
    286                
     274
    287275                wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
    288276                wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
    289277                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');
    293281                add_meta_box("fergcorp_countdownTimer_events",                  __('One Time Events', 'fergcorp_countdownTimer'),               array ( &$this, 'events_meta_box' ),                    "fergcorp-countdown-timer");
    294282                add_meta_box("fergcorp_countdownTimer_management",              __('Management', 'fergcorp_countdownTimer'),                    array ( &$this, "management_meta_box" ),                "fergcorp-countdown-timer");
     
    298286                add_meta_box("fergcorp_countdownTimer_example_display",         __('Example Display', 'fergcorp_countdownTimer'),               array ( &$this, "example_display_meta_box" ),           "fergcorp-countdown-timer");
    299287                do_meta_boxes('fergcorp-countdown-timer','advanced',null);
    300                    
     288
    301289            ?>
    302290
     
    308296            </form>
    309297    </div>
    310    
     298
    311299        </div>
    312300        <?php
    313                    
    314     }
    315 
    316         /**
    317          * Creates and defines the metabox for the options box
    318          * 
     301
     302    }
     303
     304        /**
     305         * Creates and defines the metabox for the resources box
     306         *
    319307         * @package Countdown_Timer
    320308         * @author Andrew Ferguson
    321309         * @internal 3.0
    322310         * @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&amp;type=wishlist&amp;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&amp;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         *
    324336         */
    325337        function display_options_meta_box(){
     
    333345                <li><?php echo __('Hours:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_showHour", $this->showHour); ?></li>
    334346                <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>
    336348                <li><?php echo __('Strip non-significant zeros:', 'fergcorp_countdownTimer') . $this->build_yes_no("fergcorp_countdownTimer_stripZero", $this->stripZero); ?></li>
    337349            </ul>
     
    341353        /**
    342354         * Creates and defines the metabox for the events box
    343          * 
     355         *
    344356         * @package Countdown_Timer
    345357         * @author Andrew Ferguson
    346358         * @internal 3.0
    347359         * @access public
    348          * 
    349          */         
    350         public function events_meta_box(){             
    351            
     360         *
     361         */
     362        public function events_meta_box(){
     363
    352364        ?>
    353365            <table border="0" cellspacing="0" cellpadding="2">
     
    360372                </tr>
    361373                <?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
    372375                $event_count = 0;
    373                     if ( is_array( $this->eventList ) ) {   
     376                    if ( is_array( $this->eventList ) ) {
    374377                        foreach ( $this->eventList as $thisEvent ) {
    375378                        //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() ) ) {
    377380                            $thisEvent = NULL;
    378381                        }
     
    386389                                                        "size" => 30,
    387390                                                        "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"))
    389392                                                        )
    390393                                                    )."</td>";
    391                                
     394
    392395                            echo "<td>".$this->build_input(array(
    393396                                                        "type" => "text",
     
    397400                                                        )
    398401                                                    )."</td>";
    399                                
     402
    400403                            echo "<td>".$this->build_input(array(
    401404                                                        "type" => "text",
     
    405408                                                        )
    406409                                                    )."</td>";
    407        
     410
    408411                            echo "<td>".$this->build_input(array(
    409412                                                        "type" => "checkbox",
    410413                                                        "name" => "fergcorp_countdownTimer_oneTimeEvent[{$event_count}][timeSince]",
    411414                                                        "value" => 1,
    412                                                         ), 
     415                                                        ),
    413416                                                    checked("1", $thisEvent->getTimeSince(), false)
    414417                                                    )."</td>";
     
    430433                                                )
    431434                                            )."</td>";
    432                        
     435
    433436                    echo "<td>".$this->build_input(array(
    434437                                                "type" => "text",
     
    437440                                                )
    438441                                            )."</td>";
    439                        
     442
    440443                    echo "<td>".$this->build_input(array(
    441444                                                "type" => "text",
     
    465468                            );
    466469            _e('Yes', 'fergcorp_countdownTimer');
    467             echo " :: "; 
    468             //...or No 
     470            echo " :: ";
     471            //...or No
    469472            echo $this->build_input(array(
    470473                                "type"  => "radio",
     
    480483        /**
    481484         * Creates and defines the metabox for the installation box
    482          * 
     485         *
    483486         * @package Countdown_Timer
    484487         * @author Andrew Ferguson
    485488         * @internal 3.0
    486489         * @access private
    487          * 
    488          */                         
     490         *
     491         */
    489492        function installation_meta_box () { ?>
    490            
     493
    491494        <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>
    492495                    <p><?php _e('Examples of some (but not all) valid dates', 'fergcorp_countdownTimer'); ?>:</p>
     
    498501                                <li>last monday</li>
    499502                    </ul>
    500      
     503
    501504        <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
    503506                    <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>
    504507                    <p>
     
    508511                        </code>
    509512                    </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>
    511514                    <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>
    512515                    <p>
     
    515518                        </code>
    516519                    </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
    519522        }
    520523
    521524        /**
    522525         * Creates and defines the metabox for the management box
    523          * 
     526         *
    524527         * @package Countdown_Timer
    525528         * @author Andrew Ferguson
    526529         * @internal 3.0
    527530         * @access private
    528          * 
     531         *
    529532         */
    530533        function management_meta_box(){
     
    532535            <p><?php _e("How long the timer remain visable if \"Display 'Time Since'\" is ticked:", 'fergcorp_countdownTimer'); ?><br />
    533536            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php _e("Seconds:", 'fergcorp_countdownTimer');
    534            
     537
    535538            echo $this->build_input(array(
    536539                                "type"  => "text",
     
    539542                                "value" => $this->timeSinceTime
    540543                                ));
    541                                
     544
    542545            _e("(0 = infinite; 86400 seconds = 1 day; 604800 seconds = 1 week)", "fergcorp_countdownTimer"); ?></p>
    543546
    544547            <p><?php _e('Enable JavaScript countdown:', 'fergcorp_countdownTimer');
    545            
     548
    546549            echo $this->build_yes_no("fergcorp_countdownTimer_enableJS", $this->enableJS);
    547550
    548551            ?>
    549552            </p>
    550            
     553
    551554            <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>
    552555            <p><?php _e('Enable shortcodes in the_excerpt:', 'fergcorp_countdownTimer');
    553            
    554             echo $this->build_yes_no("fergcorp_countdownTimer_enableShortcodeExcerpt", $this->enabledShortcodeExcerpt);
     556
     557            echo $this->build_yes_no("fergcorp_countdownTimer_enableShortcodeExcerpt", $this->enableShortcodeExcerpt);
    555558
    556559            ?>
     
    559562        }
    560563
    561        
     564
    562565    /**
    563566     * Creates and defines the metabox for the onHover time format box
    564      * 
     567     *
    565568     * @package Countdown_Timer
    566569     * @author Andrew Ferguson
    567570     * @internal 3.0
    568571     * @access private
    569      * 
    570      */                         
     572     *
     573     */
    571574    function onHover_time_format_meta_box(){
    572575        ?>
     
    584587                            "value" => $this->timeFormat
    585588                            ));
    586            
    587            
     589
     590
    588591        echo "</p>";
    589        
    590     }
    591        
    592        
     592
     593    }
     594
     595
    593596    /**
    594597     * Creates and defines the metabox for the display format options box
    595      * 
     598     *
    596599     * @package Countdown_Timer
    597600     * @author Andrew Ferguson
    598601     * {@internal since}
    599602     * @access private
    600      * 
    601      */                                 
     603     *
     604     */
    602605    function display_format_options_meta_box(){
    603606        ?>
     
    609612        </ul>
    610613        <p><?php _e('Title Suffix', 'fergcorp_countdownTimer');
    611        
     614
    612615        echo $this->build_input(array(
    613616                            "type"  => "text",
     
    618621        echo "</p>";
    619622    }
    620        
    621        
     623
     624
    622625    /**
    623626     * Creates and defines the metabox for the example display box
    624      * 
     627     *
    625628     * @package Countdown_Timer
    626629     * @author Andrew Ferguson
    627630     * @internal 3.0
    628631     * @access private
    629      * 
    630      */     
     632     *
     633     */
    631634    function example_display_meta_box(){
    632635        echo "<ul>";
     
    637640        }
    638641    }
    639        
    640        
     642
     643
    641644    /**
    642645     * Creates a PHP-based one-off time for use outside the loop
     
    648651    */
    649652    public function singleTimer( $date ){
    650        
     653
    651654        return $this->formatEvent( new Fergcorp_Countdown_Timer_Event( strtotime( $date ) ) , TRUE );
    652        
     655
    653656    }
    654657
     
    666669        $this->eventsPresent = FALSE;
    667670        $toReturn = "";
    668        
     671
    669672        //Make sure there's something to count
    670673        if($this->eventList){
    671674            $this->eventsPresent = TRUE;
    672675        }
    673        
     676
    674677        $eventCount = count($this->eventList);
    675678        if($eventLimit != -1)   //If the eventLimit is set
     
    688691            }
    689692        }
    690        
     693
    691694        if(!$this->eventsPresent){
    692695                $toReturn = __('No dates present', 'fergcorp_countdownTimer');
    693696        }
    694        
     697
    695698        //Echo or return
    696699        if($output)
    697700            echo $toReturn;
    698701        else
    699             return $toReturn;   
     702            return $toReturn;
    700703    }
    701704
     
    717720     * @return string The content of the post with the appropriate dates inserted (if any)
    718721    */
    719     function formatEvent($thisEvent, $standAlone = FALSE){ 
     722    function formatEvent($thisEvent, $standAlone = FALSE){
    720723        $time_left = $thisEvent->getTimestamp() - time();
    721        
     724
    722725        $content = '';
    723        
     726
    724727        if(!$standAlone)
    725728            $content = "<li class = 'fergcorp_countdownTimer_event_li'>";
    726            
     729
    727730        $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
    729732        if ($this->timeFormat == "") {
    730733            $this->timeFormat = get_option('date_format') . ", " . get_option('time_format');
    731734        }
    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 ) ) )
    737740                || ( $standAlone) ) ) {
    738                        
     741
    739742                    //If the event has already passed and we still want to display the event
    740                
     743
    741744            $this->eventsPresent = TRUE; //Set to TRUE so we know there's an event to display
    742745            if ( $thisEvent->getTitle() ) {
     
    747750        elseif($time_left > 0){ //If the event has not yet happened yet
    748751            $this->eventsPresent = TRUE; //Set to TRUE so we know there's an event to display
    749            
     752
    750753            if($thisEvent->getTitle()){
    751754                $content .= $eventTitle;
    752755            }
    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        }
    755758        else{
    756759            return NULL;
    757760        }
    758        
     761
    759762        array_push($this->jsUID, $thisEvent);
    760        
     763
    761764        if(!$standAlone)
    762765            $content .= "</li>\r\n";
     
    776779    */
    777780    function fuzzyDate ( $targetTime, $nowTime ) {
    778            
     781
    779782        $timeDelta = new Fergcorp_DeltaTime($targetTime, $nowTime);
    780783
     
    782785        $s = '';
    783786        $sigNumHit = false;
    784        
     787
    785788        if($timeDelta->s < 0){
    786789            $timeDelta->i--;
     
    829832        }
    830833        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)
    832835            //If we showed years, but not months, we need to account for those.
    833836            if($this->showYear){
    834837                $timeDelta->delta = $timeDelta->delta - $timeDelta->y*31536000;
    835838            }
    836            
     839
    837840            //Re calculate the resultant times
    838             $timeDelta->w = intval( $timeDelta->delta/(86400*7) ); 
     841            $timeDelta->w = intval( $timeDelta->delta/(86400*7) );
    839842            $timeDelta->d = intval( $timeDelta->delta/86400 );
    840843            $timeDelta->h = intval( ($timeDelta->delta - $timeDelta->d*86400)/3600 );
    841844            $timeDelta->i = intval( ($timeDelta->delta - $timeDelta->d*86400 - $timeDelta->h*3600)/60 );
    842845            $timeDelta->s = intval( ($timeDelta->delta - $timeDelta->d*86400 - $timeDelta->h*3600 - $timeDelta->i*60) );
    843            
     846
    844847            //and clear any rollover time
    845848            $rollover = 0;
     
    850853            if($sigNumHit || !$this->stripZero || ( ($timeDelta->d + intval($rollover/86400) )/7)){
    851854                $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> ";
    853856                $rollover = $rollover - intval($rollover/86400)*86400;
    854857                $timeDelta->d = $timeDelta->d - intval( ($timeDelta->d + intval($rollover/86400) )/7 )*7;
     
    899902        if($this->showSecond){
    900903            $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
    904907        //Catch blank statements
    905908        if($s==""){
     909             // @codeCoverageIgnoreStart
    906910            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> ";
    908912            }
    909913            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> ";
    911915            }
    912916            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            }
    915919            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            }
    918922            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> ";
    920924            }
    921925            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
    924929            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> ";
    926931            }
    927932        }
    928933        return preg_replace("/(, ?<\/span> *)$/is", "</span>", $s);
    929934    }
    930    
     935
    931936        /**
    932937     * Processes [fergcorp_cdt max=##] shortcode
     
    937942     * @author Andrew Ferguson
    938943     * @return string countdown timer(s)
    939     */ 
     944    */
    940945    function shortcode_showTimer($atts) {
    941946        extract(shortcode_atts(array(
     
    943948                                ),
    944949                                $atts));
    945    
     950
    946951        return $this->showTimer($max, FALSE);
    947952    }
    948    
     953
    949954    /**
    950955     * Processes [fergcorp_cdt_single date="_DATE_"] shortcode
     
    955960     * @author Andrew Ferguson
    956961     * @return string countdown timer
    957     */ 
     962    */
    958963    function shortcode_singleTimer($atts) {
    959964        extract(shortcode_atts(array(
    960965            'date' => '-1',
    961966        ), $atts));
    962    
     967
    963968        return $this->singleTimer( $date );
    964969    }
    965    
    966    
     970
     971
    967972    /**
    968973     * Initialized the options
     
    990995    }
    991996
     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
    9921008    /**
    9931009     * Sanitize the callback
     
    9961012     * @access public
    9971013     * @author Andrew Ferguson
    998      */ 
     1014     */
    9991015    public function sanitize($input){
    10001016
    10011017                $event_object_array = array();
    1002                
    1003                 //We need a time zone to properly guess what dates the user means   
    1004                 $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 it
    1007                 }
    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                 }
    10111018
    10121019                foreach($input as $event){
     
    10181025                    }
    10191026                }
    1020    
     1027
    10211028                /*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'));
    10321030        return $event_object_array;
    10331031    }
     
    10351033
    10361034    function json(){
    1037         $params = array(   
     1035        $params = array(
    10381036                        "showYear"      =>$this->showYear,
    10391037                        "showMonth"     =>$this->showMonth,
     
    10451043                        "stripZero"     =>$this->stripZero,
    10461044                    );
    1047                    
     1045
    10481046        $js_events = array();
    10491047        foreach($this->jsUID as $event){
     
    10541052                        "year"  => addslashes( _n( "%d year,", "%d years,", 1, "fergcorp_countdownTimer" )),
    10551053                        "years" => addslashes( _n( "%d year,", "%d years,", 2, "fergcorp_countdownTimer" )),
    1056                        
     1054
    10571055                        "month"     => addslashes( _n( "%d month,", "%d months,", 1, "fergcorp_countdownTimer" )),
    10581056                        "months"    => addslashes( _n( "%d month,", "%d months,", 2, "fergcorp_countdownTimer" )),
    1059                        
     1057
    10601058                        "week"  => addslashes( _n( "%d week,", "%d weeks,", 1, "fergcorp_countdownTimer" )),
    10611059                        "weeks" => addslashes( _n( "%d week,", "%d weeks,", 2, "fergcorp_countdownTimer" )),
    1062                        
     1060
    10631061                        "day"   => addslashes( _n( "%d day,", "%d days,", 1, "fergcorp_countdownTimer" )),
    10641062                        "days"  => addslashes( _n( "%d day,", "%d days,", 2, "fergcorp_countdownTimer" )),
    1065                        
     1063
    10661064                        "hour"  => addslashes( _n( "%d hour,", "%d hours,", 1, "fergcorp_countdownTimer" )),
    10671065                        "hours" => addslashes( _n( "%d hour,", "%d hours,", 2, "fergcorp_countdownTimer" )),
    1068                        
     1066
    10691067                        "minute"    => addslashes( _n( "%d minute,", "%d minutes,", 1, "fergcorp_countdownTimer" )),
    10701068                        "minutes"   => addslashes( _n( "%d minute,", "%d minutes,", 2, "fergcorp_countdownTimer" )),
    1071                        
     1069
    10721070                        "second"    => addslashes( _n( "%d second,", "%d seconds,", 1, "fergcorp_countdownTimer" )),
    10731071                        "seconds"   => addslashes( _n( "%d second,", "%d seconds,", 2, "fergcorp_countdownTimer" )),
    1074                        
     1072
    10751073
    10761074                        "agotime"   => addslashes(__('%s ago', 'fergcorp_countdownTimer')),
     
    10781076                    );
    10791077        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 );
    10811079        wp_localize_script( 'fergcorp_countdowntimer', 'fergcorp_countdown_timer_options', $params );
    10821080    }
     
    10921090        $plugin_data = get_plugin_data(__FILE__);
    10931091
     1092        //Don't test for now
     1093        // @codeCoverageIgnoreStart
    10941094        //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" ) ) ) {
    10961096            update_option("widget_fergcorp_countdown_timer_widget",  array( "title"         => $oldWidget["title"],
    10971097                                                                            "countLimit"    => $oldWidget["count"],
    10981098                                                                            )
    1099             ); 
     1099            );
    11001100            delete_option("widget_fergcorp_countdown");
    1101            
     1101
    11021102            global $sidebars_widgets;
    11031103            //check to see if the old widget is being used
     
    11081108                if( 'wp_inactive_widgets' == $sidebar )
    11091109                    continue;
    1110                    
     1110
    11111111                if ( is_array($widgets) ) {
    11121112                    foreach ( $widgets as $widget ) {
     
    11201120        wp_set_sidebars_widgets($sidebars_widgets);
    11211121        wp_get_sidebars_widgets();
    1122        
    1123        
    1124        
     1122
     1123
     1124
    11251125        }
    11261126        //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
     
    11281128            delete_option("widget_fergcorp_countdown");
    11291129        }
    1130        
     1130        // @codeCoverageIgnoreEnd
     1131
     1132        // @codeCoverageIgnoreStart
    11311133        //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" ) ) ) {
    11331135            update_option( 'fergcorp_countdownTimer_timeFormat', $timeOffset);
    1134             delete_option("fergcorp_countdownTimer_timeOffset");           
     1136            delete_option("fergcorp_countdownTimer_timeOffset");
    11351137        }
    11361138        //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 ){
    11381140            delete_option("fergcorp_countdownTimer_timeOffset");
    11391141        }
    1140        
     1142        // @codeCoverageIgnoreEnd
     1143
     1144        // @codeCoverageIgnoreStart
    11411145        $oneTimeEvent = get_option("fergcorp_countdownTimer_oneTimeEvent");
    11421146        if( ( $oneTimeEvent )  && ( gettype($oneTimeEvent[0]) == "array") ) {
     
    11441148            foreach( $oneTimeEvent as $event ) {
    11451149                array_push($event_object_array, new Fergcorp_Countdown_Timer_Event($event["date"], $event["text"], $event["link"], $event["timeSince"]));
    1146             } 
     1150            }
    11471151            update_option("fergcorp_countdownTimer_oneTimeEvent", $event_object_array);
    11481152        }
     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    }
    11491175
    11501176        /**
     
    11601186        */
    11611187        function install_option($prefix, $option, $default){
    1162             if(get_option($prefix.$option) != NULL){   
     1188            if(get_option($prefix.$option) != NULL){
    11631189                return false;
    11641190            }
     
    11681194            }
    11691195        }
    1170         //Install the defaults
    1171         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 thing
    1188         update_option("fergcorp_countdownTimer_version", $plugin_data["Version"]);
    1189     }
    11901196
    11911197        /**
    11921198         * Builds <input> HTML
    1193          * 
     1199         *
    11941200         * @package Countdown_Timer
    11951201         * @author Andrew Ferguson
     
    11991205         * @param string    $inputString
    12001206         * $return string HMTL code
    1201          */     
     1207         */
    12021208        public function build_input($inputArray, $inputString=''){
    12031209            $attributes = "";
     
    12091215        /**
    12101216         * Builds Yes/No <input> HTML
    1211          * 
     1217         *
    12121218         * @package Countdown_Timer
    12131219         * @author Andrew Ferguson
     
    12171223         * @param string    $option
    12181224         * $return string HMTL code
    1219          */     
     1225         */
    12201226        public function build_yes_no($name, $option){
    12211227            //Yes
     
    12261232                                ),
    12271233                            checked("1", $option, false)
    1228                             ); 
     1234                            );
    12291235            $output .= __('Yes', 'fergcorp_countdownTimer');
    12301236            $output .= " :: ";
     
    12361242                                ),
    12371243                            checked("0", $option, false)
    1238                             ); 
     1244                            );
    12391245            $output .= __('No', 'fergcorp_countdownTimer');
    1240            
     1246
    12411247            return $output;
    1242         }   
     1248        }
    12431249}
    12441250
     
    12491255    private $timeSince;
    12501256    private $UID;
    1251    
     1257
    12521258    public function __construct ($time, $title = NULL, $url = NULL, $timeSince = NULL){
    12531259        $this->setTitle($title);
     
    12581264        parent::__construct("@".$time);
    12591265    }
    1260    
    1261     public function getTimestamp() {
     1266
     1267    /*public function getTimestamp() {
    12621268         return method_exists('DateTime', 'getTimestamp') ? parent::getTimestamp() : $this->time;
    1263     }
    1264    
     1269    }*/
     1270
    12651271    public function setTitle ( $title ) {
    12661272        $this->title = (string)$title;
    12671273    }
    1268    
     1274
    12691275    public function setTime ( $time ) {
    12701276        $this->time = $time;
    12711277    }
    1272    
     1278
    12731279    public function setURL ( $url ) {
    12741280        $this->url = $url;
    12751281    }
    1276    
     1282
    12771283    public function setTimeSince ( $timeSince ) {
    12781284        $this->timeSince = $timeSince;
    12791285    }
    1280    
     1286
    12811287    public function getTitle () {
    12821288        return $this->title;
    12831289    }
    1284    
     1290
    12851291    public function getTime () {
    12861292        return $this->time;
    12871293    }
    1288    
     1294
    12891295    public function getURL () {
    12901296        return $this->url;
    12911297    }
    1292    
     1298
    12931299    public function getTimeSince () {
    12941300        return $this->timeSince;
    12951301    }
    1296    
     1302
    12971303    public function getUID () {
    12981304        return $this->UID;
    12991305    }
    1300    
     1306
    13011307    public function date ( $format ) {
    13021308        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 availible
    1310      *
    1311      * @param $calendar int ignored
    1312      * @param $month int month (integers 1-12)
    1313      * @param $year int year (any integer)
    1314      * @since 2.3
    1315      * @access private
    1316      * @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 net
    1318      * @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 month
    1322         return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
    13231309    }
    13241310}
    13251311/**
    13261312 * Widget class for Countdown Timer
    1327  * 
     1313 *
    13281314 * @since 3.0
    13291315 * @access public
     
    13311317 */
    13321318class Fergcorp_Countdown_Timer_Widget extends WP_Widget{
    1333    
     1319
    13341320    public function __construct(){
    13351321        global $fergcorp_countdownTimer_init;
     
    13401326        );
    13411327    }
    1342    
     1328
    13431329    public function form( $instance){
    1344        
     1330
    13451331        if ( $instance ) {
    13461332            $title = esc_attr( $instance['title'] );
     
    13511337            $countLimit = -1;
    13521338        }
    1353        
     1339
    13541340        ?>
    13551341        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' , 'fergcorp_countdownTimer'); ?></label>
     
    13601346                        <?php
    13611347    }
    1362    
     1348
    13631349    public function update( $new_instance, $old_instance ){
    13641350        $instance['title'] = strip_tags( $new_instance['title'] );
    13651351        $instance['countLimit'] = intval($new_instance['countLimit']);
    13661352        return $instance;
    1367        
    1368     }
    1369        
     1353
     1354    }
     1355
    13701356    public function widget( $args, $instance ){
    1371         global $fergcorp_countdownTimer_init;   
     1357        global $fergcorp_countdownTimer_init;
    13721358        echo $args['before_widget'];
    13731359        if ( ! empty( $instance['title'] ) ) {
     
    13791365        $fergcorp_countdownTimer_init->showTimer($instance['countLimit']);
    13801366        echo "</ul>";
    1381    
     1367
    13821368        echo $args['after_widget'];
    1383    
     1369
    13841370    }
    13851371}
    13861372
    13871373class Fergcorp_DeltaTime{
    1388        
     1374
    13891375    public $nowYear;
    13901376    public $nowMonth;
     
    13931379    public $nowMinute;
    13941380    public $nowSecond;
    1395    
     1381
    13961382    public $targetYear;
    13971383    public $targetMonth;
     
    14001386    public $targetMinute;
    14011387    public $targetSecond;
    1402    
     1388
    14031389    public $y;
    14041390    public $m;
     
    14071393    public $i;
    14081394    public $s;
    1409    
     1395
    14101396    public $w;
    1411    
     1397
    14121398    public $delta;
    1413    
     1399
    14141400    public function __construct($targetTime, $nowTime){
    14151401        $this->nowYear = date("Y", $nowTime);
     
    14191405        $this->nowMinute = date("i", $nowTime);
    14201406        $this->nowSecond = date("s", $nowTime);
    1421        
     1407
    14221408        $this->targetYear = date("Y", $targetTime);
    14231409        $this->targetMonth = date("m", $targetTime);
     
    14261412        $this->targetMinute = date("i", $targetTime);
    14271413        $this->targetSecond = date("s", $targetTime);
    1428        
     1414
    14291415        $this->y = $this->targetYear - $this->nowYear;
    14301416        $this->m  = $this->targetMonth - $this->nowMonth;
     
    14331419        $this->i = $this->targetMinute - $this->nowMinute;
    14341420        $this->s = $this->targetSecond - $this->nowSecond;
    1435        
     1421
    14361422        $this->delta = $targetTime - $nowTime;
    14371423    }
     
    14431429
    14441430function fergcorp_countdownTimer($countLimit = -1) {
    1445     global $fergcorp_countdownTimer_init;   
     1431    global $fergcorp_countdownTimer_init;
    14461432    $fergcorp_countdownTimer_init->showTimer($countLimit, TRUE);
    14471433}
     
    14511437            // Load localization domain
    14521438    load_plugin_textdomain( 'fergcorp_countdownTimer', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
    1453                        
     1439
    14541440    $fergcorp_countdownTimer_init = new Fergcorp_Countdown_Timer();
    14551441}
  • countdown-timer/trunk/js/fergcorp_countdownTimer_java.js

    r561478 r651785  
    77c-=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">'+
    88sprintf(_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();
     9f+'<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,
     100)+"</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  
    222222    if(s==''){
    223223        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> ';
    225225        }
    226226        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> ';
    228228        }
    229229        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> ';
    231231        }   
    232232        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> ';
    234234        }
    235235        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> ';
    237237        }
    238238        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> ';
    240240        }
    241241        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> ';
    243243        }
    244244    }
  • countdown-timer/trunk/readme.txt

    r567188 r651785  
    33Donate link: http://www.andrewferguson.net/2007/03/08/general-note/
    44Tags: countdown, timer, count, date, event, widget, countup, age, fun, time, international, i18n, countdown timer, wedding, localization, i18n
    5 Requires at least: 3.4
     5Requires at least: 3.5
    66Tested up to: 3.5
    7 Stable tag: 3.0.3
     7Stable tag: 3.0.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1751752. Example on Blog
    176176
     177== Upgrade Notice ==
     178= 3.0.4 =
     179A couple of major bug fixes
     180
    177181== Changelog ==
     182
     183
     184= 3.0.4 =
     185Release 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
    178191
    179192= 3.0.3 =
     
    499512
    500513Initial 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.