Plugin Directory

Changeset 2316491


Ignore:
Timestamp:
06/02/2020 10:27:26 AM (6 years ago)
Author:
arena
Message:

fixing bugs on week and month schedulers and processors

Location:
mailpress/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mailpress/trunk/mp-content/add-ons/MailPress_newsletter.php

    r2315845 r2316491  
    381381        wp_schedule_single_event( $now4cron - 1, 'mp_schedule_newsletters', array( 'args' => array( 'event' => '** Install **' ) ) );
    382382
    383         $twicedaily = gmmktime( 0, 0, 50, gmdate( 'n', $now4cron ), gmdate( 'j', $now4cron ), gmdate( 'Y', $now4cron ) ) - get_option( 'gmt_offset' ) * 3600;
     383        $twicedaily = gmmktime( 0, 0, 0, gmdate( 'n', $now4cron ), gmdate( 'j', $now4cron ), gmdate( 'Y', $now4cron ) ) - get_option( 'gmt_offset' ) * 3600;
    384384        wp_schedule_event( $twicedaily, 'twicedaily', 'mp_schedule_newsletters', array( 'args' => array( 'event' => '** Twice daily **' ) ) );
    385385    }
  • mailpress/trunk/mp-includes/class/options/newsletter/processors/month-1.php

    r2273504 r2316491  
    88        $y = $this->year;
    99        $m = $this->month;
    10         $d = $this->day;
     10        $d = $this->get_day( $y, $m );
    1111
    1212        $h = $this->get_hour();
    1313        $i = $this->get_minute();
    1414
    15         $first_day = $this->get_day( $y, $m );
    16 
    17         if ( $d < $first_day )
    18         {
    19             $m--;
    20             if ( !$m ) {$m = 12; $y--;}
    21             $d = $this->get_day( $y, $m );
    22         }
     15        if ( $this->day < $d ) $m--;
     16        if ( !$m ) {$m = 12; $y--;}
     17        $d = $this->get_day( $y, $m );
    2318
    2419        $this->upper_bound = $this->format_timestamp( $y, $m, $d, $h, $i, 0 );
  • mailpress/trunk/mp-includes/class/options/newsletter/processors/week-1.php

    r2273504 r2316491  
    1919        {
    2020            $time -= WEEK_IN_SECONDS;
    21             $this->upper_bound = date( $format, $time );
     21            $this->upper_bound = wp_date( $format, $time );
    2222        }
    2323
  • mailpress/trunk/mp-includes/class/options/newsletter/schedulers/month.php

    r2273504 r2316491  
    1010        $y = $this->year;
    1111        $m = $this->month;
    12         $d = $this->day;
     12        $d = $this->get_day( $y, $m );
    1313
    1414        $h = $this->get_hour();
    1515        $i = $this->get_minute();
    1616
    17         $first_day = $this->get_day( $y, $m );
    18 
    19         if ( $d > $first_day )
     17        if ( $this->day > $d )
    2018        {
    2119            $m++;
     
    2624        $timestamp = $this->format_timestamp( $y, $m, $d, $h, $i, 0 );
    2725
    28         if ( $timestamp < $this->date )
    29         {
    30             $m++;
    31             if ( $m > 12 ) { $m = 1; $y++; }
    32             $d = $this->get_day( $y, $m );
    33 
    34             $timestamp = $this->format_timestamp( $y, $m, $d, $h, $i, 0 );
    35         }
    36 
    3726        return $this->schedule_single_event( $timestamp );
    3827    }
  • mailpress/trunk/mp-includes/class/options/newsletter/schedulers/week.php

    r2273504 r2316491  
    1212        $format = 'Y-m-d ' . zeroise( $this->get_hour(), 2 ) . ':' . zeroise( $this->get_minute(), 2 ) . ':00';
    1313
    14         $first_wday = $this->get_wday();
    15 
    16         while ( wp_date( 'w', $time ) != $first_wday ) $time += DAY_IN_SECONDS;
     14        $wdiff  = $this->get_wday() - $this->wday;
     15        if ( $wdiff < 0 ) $wdiff += 7;
     16        $time += $wdiff * DAY_IN_SECONDS;
    1717
    1818        $timestamp = wp_date( $format, $time );
    19 
    20         if ( $timestamp < $this->date )
    21         {
    22             $time += WEEK_IN_SECONDS;
    23             $timestamp = wp_date( $format, $time );
    24         }
    2519
    2620        return $this->schedule_single_event( $timestamp );
Note: See TracChangeset for help on using the changeset viewer.