Plugin Directory

Changeset 527360


Ignore:
Timestamp:
04/04/2012 03:06:55 PM (14 years ago)
Author:
rxn
Message:

added friday feature

Location:
sunrise-sunset/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sunrise-sunset/trunk/readme.txt

    r527331 r527360  
    44Requires at least: 3.0
    55Tested up to: 3.3.1
    6 Stable tag: 1.1.3
     6Stable tag: 1.1.4
    77License: GPLv2
    88
     
    1313Displays sunrise and sunset times for the capital cities of the America (including miscellaneous cities).
    1414Times displayed are local time.
     15
     16You can also set the sunrise/sunset times for only Friday.
    1517
    1618IF YOU ARE UPGRADING please change the settings of the widget in the dashboard right after upgrading.
     
    4648I will try to accommodate you ASAP.
    4749
     50= Why is there an options to limit the sunrise/sunset display to only Friday? =
     51These times are important for certain religious denomination.
     52
     53
    4854= What updates are planned for this widget? =
    4955Here are some:
     
    6571
    6672== Changelog ==
    67 = 1.1.3 =
    68 * Updated README and screenshot.
     73= 1.1.4 =
     74* Added "Friday" feature.
     75* Added Timezone in Display.
    6976
    7077= 1.1.2 =
  • sunrise-sunset/trunk/sunrisesunset.php

    r527331 r527360  
    44Plugin URI: http://wordpress.org/extend/plugins/sunrise-sunset/
    55Description: Displays Sunrise and Sunset Times
    6 Version:  1.1.3
     6Version:  1.1.4
    77Author: Rex Posadas ([email protected])
    88Author URI: http://www.rxnfx.com/ss-plugin
     
    5959        $showsunset = strip_tags($instance['showsunset']);
    6060        $showsunrise = strip_tags($instance['showsunrise']);
     61        $friday = strip_tags($instance['showfriday']);
    6162
    6263        ?>
     
    8586        $field_sunset = $this->get_field_name('showsunset');
    8687        $field_sunrise = $this->get_field_name('showsunrise');
     88        $field_friday = $this->get_field_name('showfriday');
    8789
    88         $showsunset_checkbox;
    89         $showsunrise_checkbox;
     90        $sunset_checkbox;
     91        $sunrise_checkbox;
     92        $friday_checkbox;
    9093
    9194        if ($instance['showsunset']) {
    92             $showsunset_checkbox = sprintf('<input type="checkbox" name="%s" value="%s" checked/> Display Sunset Time', $field_sunset, $field_sunset);
     95            $sunset_checkbox = sprintf('<input type="checkbox" name="%s" value="%s" checked/> Display Sunset Time', $field_sunset, $field_sunset);
    9396        } else {
    94             $showsunset_checkbox = sprintf('<input type="checkbox" name="%s" value="%s"/> Display Sunset Time', $field_sunset, $field_sunset);
     97            $sunset_checkbox = sprintf('<input type="checkbox" name="%s" value="%s"/> Display Sunset Time', $field_sunset, $field_sunset);
    9598        }
    9699
    97100        if ($instance['showsunrise']) {
    98             $showsunrise_checkbox = sprintf('<input type="checkbox" name="%s" value="%s" checked/> Display Sunrise Time', $field_sunrise, $field_sunrise);
     101            $sunrise_checkbox = sprintf('<input type="checkbox" name="%s" value="%s" checked/> Display Sunrise Time', $field_sunrise, $field_sunrise);
    99102        } else {
    100             $showsunrise_checkbox = sprintf('<input type="checkbox" name="%s" value="%s"/> Display Sunrise Time', $field_sunrise, $field_sunrise);
     103            $sunrise_checkbox = sprintf('<input type="checkbox" name="%s" value="%s"/> Display Sunrise Time', $field_sunrise, $field_sunrise);
    101104        }
    102105
    103         echo "<br/>" . $showsunset_checkbox;
    104         echo "<br/>" . $showsunrise_checkbox;
     106        if ($instance['showfriday']) {
     107            $friday_checkbox = sprintf('<input type="checkbox" name="%s" value="%s" checked/> Display only Friday', $field_friday, $field_friday);
     108        } else {
     109            $friday_checkbox = sprintf('<input type="checkbox" name="%s" value="%s"/> Display only Friday', $field_friday, $field_friday);
     110        }
     111
     112
     113        echo "<br/>" . $sunrise_checkbox;
     114        echo "<br/>" . $sunset_checkbox;
     115        echo "<br/>" . $friday_checkbox;
    105116
    106117        ?>
     
    120131        $instance['showsunset'] = strip_tags($new_instance['showsunset']);
    121132        $instance['showsunrise'] = strip_tags($new_instance['showsunrise']);
     133        $instance['showfriday'] = strip_tags($new_instance['showfriday']);
    122134        return $instance;
    123135    }
    124136
    125     // display our widget
     137    /**
     138     * The Front end of our widget.
     139     * @param $args
     140     * @param $instance
     141     */
    126142    function widget($args, $instance)
    127143    {
     
    137153        }
    138154
    139         $result = SSUtils::getTimes($instance, $this->_cities);
     155        $showOnlyFriday = $instance['showfriday']? true: false;
     156
     157
     158        $result = SSUtils::getTimes($instance, $this->_cities, $showOnlyFriday);
    140159
    141160        echo $today . "<br/>";
  • sunrise-sunset/trunk/utils.php

    r527331 r527360  
    5959    }
    6060
    61     static public function getTimes($instance, $cities)
     61
     62    static public function getTime($onlyFriday)
     63    {
     64
     65        if (!$onlyFriday) return time();
     66
     67
     68        $currentDay = date('N', time());
     69
     70        //1 (for Monday) through 7 (for Sunday)
     71        $aDay = 24 * 60 * 60;
     72
     73        $newTime = time();
     74        switch (intval($currentDay)) {
     75            case 1: // Monday
     76                $newTime = time() + (4 * $aDay);
     77                break;
     78            case 2: // Tuesday
     79                $newTime = time() + (3 * $aDay);
     80                break;
     81            case 3: // Wednesday
     82                $newTime = time() + (2 * $aDay);
     83                break;
     84            case 4: // Thursday
     85                $newTime = time() + (1 * $aDay);
     86                break;
     87            case 6: // Saturday
     88                $newTime = time() + (6 * $aDay);
     89                break;
     90            case 7: // Sunday
     91                $newTime = time() + (5 * $aDay);
     92                break;
     93        }
     94
     95
     96        $newDay = date('N', $newTime);
     97
     98        return $newTime;
     99    }
     100
     101    static public function getTimes($instance, $cities, $onlyFriday)
    62102    {
    63103        $time_format = 'h:i A';
     
    67107        $long = $targetCity->getLongitude();
    68108
    69         $suninfo = date_sun_info(time(), $lat, $long);
     109
     110        $suninfo = date_sun_info(self::getTime($onlyFriday), $lat, $long);
    70111
    71112        $convertedSunriseTime = self::convertTimezone($suninfo['sunrise'], $targetCity);
Note: See TracChangeset for help on using the changeset viewer.