Plugin Directory

Changeset 3429289


Ignore:
Timestamp:
12/29/2025 08:43:31 PM (2 months ago)
Author:
ashanjay
Message:

2.2.1 (2025-12-29)

FIXED: Normal calendar to other calendar view not working
FIXED: Image view styles and layout
FIXED: Moon cycle progress bar adjustment
FIXED: Moon month switching not working
FIXED: anchor year to moon cycle holding equinox
FIXED: moon months per equinox anchor year not correct

Location:
lifepress
Files:
74 added
6 edited

Legend:

Unmodified
Added
Removed
  • lifepress/trunk/README.txt

    r3428394 r3429289  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 2.2
     7Stable tag: 2.2.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4242* Developer-friendly with pluggable actions and filters
    4343
     44
     45
     46== 🌙 Lunisolar Calendar - Moon View (New in 2.2) ==
     47
     48Switch from the standard calendar to a moon-phase (lunisolar) view and align your journaling with natural rhythms.
     49
     50Center your life awareness around:
     51
     52* New moons
     53* Full moons
     54* Waxing and waning cycles
     55
     56This view is ideal for those who prefer to plan, reflect, and reset in harmony with nature’s cycles rather than purely linear time.
     57
    4458== 🗄️ Data Metrics (New in 2.2) ==
    4559
     
    6276
    6377Your journal becomes a living dataset of your life.
    64 
    65 == 🌙 Lunisolar Calendar - Moon View (New in 2.2) ==
    66 
    67 Switch from the standard calendar to a moon-phase (lunisolar) view and align your journaling with natural rhythms.
    68 
    69 Center your life awareness around:
    70 
    71 * New moons
    72 * Full moons
    73 * Waxing and waning cycles
    74 
    75 This view is ideal for those who prefer to plan, reflect, and reset in harmony with nature’s cycles rather than purely linear time.
    7678
    7779
     
    130132
    131133== Changelog ==
     134= 2.2.1 (2025-12-29) =
     135FIXED: Normal calendar to other calendar view not working
     136FIXED: Image view styles and layout
     137FIXED: Moon cycle progress bar adjustment
     138FIXED: Moon month switching not working
     139FIXED: anchor year to moon cycle holding equinox
     140FIXED: moon months per equinox anchor year not correct
     141
    132142= 2.2 (2025-12-27) =
    133143ADDED: Option to enable Sun and moon information in footer
  • lifepress/trunk/assets/global.css

    r3428394 r3429289  
    519519        padding: 10px;
    520520    }
    521     .lp_entry_image img{border-radius: 10px;}
     521    .lp_entry_image img{border-radius: 10px;max-width: 100%;}
    522522    .lp_editor_box {flex:1;}
    523523
  • lifepress/trunk/assets/script.js

    r3428394 r3429289  
    236236
    237237                    if( 'lunar_data' in data.d){
    238                         LUNAR_DATA = data.d.lunar_data;
    239                         update_lunar_ref( data.d.lunar_data.ref );
     238                        LUNAR_DATA = data.d.lunar_data;                     
    240239                        LUNAR_NOW = {'s': data.d.lunar_data.start, 'e': data.d.lunar_data.end};
    241240                    }
     241
     242                    if( 'lunar_data' in data.d) update_lunar_ref( data.d.lunar_data.ref );
    242243                   
    243244
     
    291292
    292293            // adjust focus if direction send
    293             if(direction) FOCUS.setMonth(  (direction == 'next'? FOCUS.getMonth()+1: FOCUS.getMonth()-1) );
     294            if(direction && direction == 'next' ) FOCUS.setMonth(  FOCUS.getMonth()+1  );
     295            if(direction && direction == 'prev' ) FOCUS.setMonth(  FOCUS.getMonth()-1  );
    294296
    295297            // based on focus date set 1st of focus month as start range
     
    309311            // adjust end range to last day of week         
    310312            DE.setDate( DE.getDate() + _get_eow_daydif( DE.getDay() ) );
    311            
     313
     314            //console.log('T1 '+ DS);
    312315        }
    313316        if(VIEW == 'moon_view' ){
     
    317320            if (!FOCUS)  FOCUS = new Date(parseInt(LUNAR_DATA.start) * 1000);
    318321
    319             DS = new Date( parseInt( LUNAR_DATA.start ) * 1000 );
    320             DE = new Date( parseInt( LUNAR_DATA.end ) * 1000 );
     322            if( !direction ){
     323                DS = new Date( parseInt( LUNAR_DATA.start ) * 1000 );
     324                DE = new Date( parseInt( LUNAR_DATA.end ) * 1000 );
     325            }
     326
     327            //console.log(LUNAR_DATA);
    321328
    322329            if( direction == 'today'){
     
    327334            // move focus by ONE lunar cycle
    328335            if (direction === 'next'){
     336
     337                //console.log(LUNAR_REF);
     338                //console.log(DE.getFullYear()+'-'+ (DE.getMonth()+1) +'-'+ DE.getDate());
    329339
    330340                DE.setDate( DE.getDate() + 1 );
     
    366376            }   
    367377
     378            //console.log(DS);
     379
    368380        }
    369381        if(VIEW == 'week_view' ){
     
    434446                txt = LUNAR_DATA.moon_title ;       
    435447                var currentMoonRef = '';
     448
     449                console.log(LUNAR_REF);
    436450               
    437451                currentMoonRef = LUNAR_REF[ DS.getFullYear()+'-'+ (DS.getMonth()+1) +'-'+ DS.getDate()  ];
     
    11791193        AJAXDATA['start_u'] = DS.getTime();
    11801194        AJAXDATA['end_u'] = DE.getTime();   
    1181         AJAXDATA['nonce'] = lp_ajax.lp_nonce;       
     1195        AJAXDATA['nonce'] = lp_ajax.lp_nonce;   
     1196
     1197        //console.log('T2 '+ DS);
    11821198
    11831199        // console.log( LOADED_date_range.s+' '+ AJAXDATA.start_u);
     
    12141230                    }
    12151231
     1232
    12161233                    modify_range_start();
    12171234                    _draw_entries();
     
    13471364    BODY.on('click','.lp_goto_today',function(){
    13481365        // set new focus months
    1349             FOCUS.setDate( NOW.getDate() );
    1350             FOCUS.setMonth( NOW.getMonth() );
    1351             FOCUS.setFullYear( NOW.getFullYear() );
    1352 
    1353             modify_range_start('today');
    1354 
    1355             _load_new_entry_content_after_set();   
     1366        FOCUS.setDate( NOW.getDate() );
     1367        FOCUS.setMonth( NOW.getMonth() );
     1368        FOCUS.setFullYear( NOW.getFullYear() );
     1369
     1370        modify_range_start('today');
     1371
     1372        _load_new_entry_content_after_set();   
    13561373    });
    13571374       
  • lifepress/trunk/includes/class-ajax.php

    r3428394 r3429289  
    3838    }
    3939
     40
     41
    4042    // AJAX endpoints @since 2.1
    4143        public static function define_ajax(){
     
    130132                $LUNDATA = $LUN->get_moon_data();
    131133
    132                 if( $settings->check_yn('_moonview')){
     134                if( $settings->check_yn('_moonview') && $settings->get_prop('_dash_def_view') == 'moon_view'){
    133135                   
    134136
     
    140142
    141143                    // lunar data
    142                     $J['d']['lunar_data'] = $LUNDATA;
     144                   
    143145                    /*
    144146                    [
     
    159161                    $date_range = apply_filters('lifepress_ajax_date_range', [$startDate, $DD]);
    160162                }
     163
     164                $J['d']['lunar_data'] = $LUNDATA;
    161165       
    162166            $ENT = new LIFEPRESS_Entries();
  • lifepress/trunk/includes/class-lunisolar.php

    r3428394 r3429289  
    3636        if( $unix ) $dateTime->setTimestamp( $unix  );
    3737        $dateTime->modify( '+2 days'  );
    38         $startTS = clone $dateTime;
     38        $startDT = clone $dateTime;
    3939        $moonPhase = new MoonPhase($dateTime);
    4040
     
    4848        $start = (new DateTime('@' . $newMoon))->setTimezone( $this->tz )->setTime(0, 0, 0);
    4949        $end = (new DateTime('@' . $nextNewMoon))->setTimezone( $this->tz )->setTime(0, 0, 0);
    50         $total_days = $start->diff($end)->days;
     50        $total_days = $start->diff($end)->days + 1;
    5151        $progress = ( $moonAge / $total_days) * 100;
    5252
     
    105105
    106106        // Other
    107         $moon_index = $this->get_current_moon_index(  $newMoon );
    108         $moons_in_year = $this->new_moons_in_year( $startTS );
     107        $moon_index = $this->get_current_moon_index(  $newMoon , $nextNewMoon);
     108        $moons_in_year = $this->new_moons_in_year( $startDT );
    109109
    110110        // month references
     
    112112        $month_ref = [ $this_date => [ $newMoon, $this_cycle_end , __('Moon','lp').' '. $moon_index] ];
    113113
    114         $moon_index_prev = $moon_index - 1 <1 ? 1: $moon_index -1;
    115         $prev_date = (new DateTime('', $this->tz ))->setTimestamp( (int) $prevNewMoon )->format('Y-n-j');
    116         //$month_ref[ $prev_year ][ $moon_index_prev ]= [ $prevNewMoon, $prev_cycle_end, __('Moon','lp').' '. ( $moon_index_prev)];
     114        $prevNM_DT = (new DateTime('', $this->tz ))->setTimestamp( (int) $prevNewMoon );
     115        $prev_date = $prevNM_DT->format('Y-n-j');
     116        $moons_in_prev_year = ( $moon_index - 1  < 1) ? $this->new_moons_in_year( $prevNM_DT ):1;
     117        $moon_index_prev = $moon_index - 1 < 1 ? $moons_in_prev_year: $moon_index -1;
    117118        $month_ref[ $prev_date ]= [ $prevNewMoon, $prev_cycle_end, __('Moon','lp').' '. ( $moon_index_prev)];
    118119
     
    121122        //$month_ref[ $next_year ][ $moon_index_next ]= [ $nextNewMoon, $nextNext_cycle_end , __('Moon','lp').' '. $moon_index_next];
    122123        $month_ref[ $next_date ]= [ $nextNewMoon, $nextNext_cycle_end , __('Moon','lp').' '. $moon_index_next];
     124
     125        //error_log(print_r($prevNM_DT,true));
     126        //error_log(print_r($this->new_moons_in_year( new DateTime('2026-01-18', $this->tz )),true));
    123127       
    124128
     
    154158
    155159
    156     private function get_current_moon_index( int $current_new_moon_ts ): int {
    157         $lunar_cycle_seconds = $this->lunar_cycle_days * DAY_IN_SECONDS;
    158 
    159         $year = (int) gmdate('Y', $current_new_moon_ts);
     160    private function get_current_moon_index( int $current_new_moon_ts , int $next_new_moon_ts ): int {
     161        $year = (new DateTime('', $this->tz ))->setTimestamp( (int) $current_new_moon_ts )->format('Y');
    160162        $equinox_ts = $this->get_spring_equinox_ts( $year );
    161163
    162         // If this new moon happens before the equinox,
    163         // it belongs to the previous lunar year
    164         if ( $current_new_moon_ts < $equinox_ts ) {
     164        // If this cycle ends before the equinox, it belongs to the previous lunar year
     165        if ( $next_new_moon_ts <= $equinox_ts ) {
    165166            $year--;
    166167            $equinox_ts = $this->get_spring_equinox_ts( $year );
    167168        }
    168169
    169         $seconds_since_equinox = $current_new_moon_ts - $equinox_ts;
    170 
    171         $index = (int) floor( $seconds_since_equinox / $lunar_cycle_seconds ) + 1;
    172 
    173         // Safety clamp (some years only reach 12)
    174         if ( $index < 1 )  $index = 1;
    175         if ( $index > 13 ) $index = 13;
    176 
    177         return $index;
    178     }
    179 
    180     public function new_moons_in_year(DateTime $startDate): int {
    181         $startTs = $startDate->getTimestamp();
    182         $start_year = $startDate->format('Y');
    183         $end_year = $startDate->format('Y') + 1;
    184 
    185         // before march 20
    186         if( $startDate->format('n') <= 3 && $startDate->format('j') <= 20 ){
    187             $start_year = $startDate->format('Y') - 1; 
    188             $end_year = $startDate->format('Y');
    189         }
    190 
    191         $startTS = $this->get_spring_equinox_ts( $start_year);
    192         $endTS = $this->get_spring_equinox_ts( $end_year);
    193 
    194         $count = 0;
    195 
    196         // Start from the nearest previous new moon
    197         $moon = new MoonPhase( (new DateTime())->setTimestamp($startTS) );
    198         $currentNewMoon = (int) $moon->getPhasePrevNewMoon();
    199 
    200         if( $currentNewMoon < $startTS )    $currentNewMoon = (int) $moon->getPhaseNextNewMoon();
    201 
    202         // Loop through new moons until end date
    203         while ($currentNewMoon < $endTS) {
    204             $count++;
    205             // Move to the next new moon
    206             $moon = new MoonPhase((new DateTime())->setTimestamp( (int) $currentNewMoon + 86400)); // next day
    207             $currentNewMoon = (int) $moon->getPhaseNextNewMoon();
    208         }
    209 
    210         return $count;
     170        // Find Month 1 start: the new moon cycle that CONTAINS the equinox
     171        $moon = new MoonPhase(  (new DateTime())->setTimestamp( $equinox_ts ));
     172
     173        $month1_start = (int) $moon->getPhaseNewMoon();
     174        $month1_end   = (int) $moon->getPhaseNextNewMoon();
     175        //error_log(print_r( (new DateTime('', $this->tz))->setTimestamp( $month1_start)->format('Y-n-j'),true));
     176
     177        // If equinox hits exactly on a new moon boundary
     178        if ( $equinox_ts >= $month1_end ) {
     179            $month1_start = $month1_end;
     180            $moon = new MoonPhase( (new DateTime())->setTimestamp( $month1_start + DAY_IN_SECONDS ) );
     181            $month1_end = (int) $moon->getPhaseNextNewMoon();
     182        }
     183
     184        // If current cycle IS Month 1
     185        if (
     186            $current_new_moon_ts === $month1_start ||
     187            ( $current_new_moon_ts < $month1_end && $next_new_moon_ts > $month1_start )
     188        ) {
     189            return 1;
     190        }
     191
     192        // Count forward from Month 1 until current cycle
     193        $index = 1;
     194        $ts = $month1_start;
     195
     196        while ( $ts < $current_new_moon_ts ) {
     197            $moon = new MoonPhase(
     198                (new DateTime())->setTimestamp( $ts + DAY_IN_SECONDS )
     199            );
     200            $ts = (int) $moon->getPhaseNextNewMoon();
     201            $index++;
     202        }
     203
     204        return min( $index, 13 );
     205    }
     206
     207
     208
     209    public function new_moons_in_year(DateTime $date): int  {
     210        $year = (int) $date->format('Y');
     211        $dateTs = $date->getTimestamp();
     212
     213        $equinoxThisYear = $this->get_spring_equinox_ts( $year );
     214
     215        // If before equinox, use previous anchor year
     216        if ( $dateTs < $equinoxThisYear ) {
     217            $year--;
     218            $equinoxThisYear = $this->get_spring_equinox_ts( $year );
     219        }
     220
     221        $equinoxNextYear = $this->get_spring_equinox_ts( $year + 1 );
     222
     223        // Month 1 starts at the new moon BEFORE the equinox
     224        $moon = new MoonPhase( (new DateTime())->setTimestamp( $equinoxThisYear ) );
     225        $startTS = (int) $moon->getPhasePrevNewMoon();
     226
     227        $moon = new MoonPhase( (new DateTime())->setTimestamp( $equinoxNextYear ) );
     228        $endTS = (int) $moon->getPhasePrevNewMoon();
     229
     230        $count = 0;
     231        for ( $ts = $startTS; $ts < $endTS; ) {
     232            $count++;
     233            $moon = new MoonPhase(
     234                (new DateTime())->setTimestamp( $ts + DAY_IN_SECONDS )
     235            );
     236            $ts = (int) $moon->getPhaseNextNewMoon();
     237        }
     238
     239        return $count;     
    211240    }
    212241
  • lifepress/trunk/lifepress.php

    r3428394 r3429289  
    55 * Description: You are the creator of events in your life. Record and track progress in your life.
    66 * Author: Ashan Jay
    7  * Version: 2.2
     7 * Version: 2.2.1
    88 * Requires at least: 6.0
    99 * Tested up to: 6.9
     
    2020class LIFEPRESS{
    2121   
    22     public $version='2.2
     22    public $version='2.2.1
    2323    ';
    2424    public $name = 'LifePress';
Note: See TracChangeset for help on using the changeset viewer.