WordPress.org

Plugin Directory

Changeset 1637657


Ignore:
Timestamp:
04/14/17 12:31:41 (5 weeks ago)
Author:
travislopes
Message:

Entry Expiration for Gravity Forms (2.0.2)

  • Fixed search criteria not correctly preparing the search end date
Location:
gravity-forms-entry-expiration
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • gravity-forms-entry-expiration/trunk/class-gf-entryexpiration.php

    r1617287 r1637657  
    493493        } 
    494494 
     495        // Define next run time. 
     496        $next_run_time  = 'hours' === $settings['deletionRunTime']['unit'] ? ( $settings['deletionRunTime']['number'] * HOUR_IN_SECONDS ) : ( $settings['deletionRunTime']['number'] * DAY_IN_SECONDS ); 
     497        $next_run_time -= 5; 
     498 
    495499        // Get search criteria for form. 
    496         $search_critera = $this->get_search_criteria( $form, $settings, 'deletion' ); 
    497  
    498         // Get entry found for search criteria. 
     500        $search_critera = $this->get_search_criteria( $form, $settings ); 
     501 
     502        // Log the search criteria. 
     503        $this->log_debug( __METHOD__ . '(): Search criteria for form #' . $form['id'] . ': ' . print_r( $search_criteria, true ) ); 
     504 
     505        // Get entries found for search criteria. 
    499506        $found_entries = GFAPI::count_entries( $form['id'], $search_critera ); 
    500507 
    501508        // If no entries were found, exit. 
    502509        if ( ! $found_entries ) { 
     510 
     511            // Log that no entries were found. 
    503512            $this->log_debug( __METHOD__ . '(): Not deleting entries for form #' . $form['id'] . ' because no entries were found matching the search criteria.' ); 
     513 
     514            // Set transient. 
     515            set_transient( $this->_slug . '_' . $form['id'], '1', $next_run_time ); 
     516 
    504517            return; 
     518 
    505519        } 
    506520 
     
    508522        $this->delete_form_entries( $form, $settings ); 
    509523 
    510         // Define next run time. 
    511         $next_run_time = 'hours' === $settings['deletionRunTime']['unit'] ? ( $settings['deletionRunTime']['number'] * HOUR_IN_SECONDS ) : ( $settings['deletionRunTime']['number'] * DAY_IN_SECONDS ); 
    512  
    513524        // Set transient. 
    514525        set_transient( $this->_slug . '_' . $form['id'], '1', $next_run_time ); 
     526 
    515527    } 
    516528 
     
    548560        while ( $entries_processed < $found_entries ) { 
    549561 
     562            // Log the page number. 
     563            $this->log_debug( __METHOD__ . '(): Starting deletion of page ' . ( round( $entries_processed / $paging['page_size'] ) + 1 ) . ' of ' . ( round( $found_entries / $paging['page_size'] ) ) ); 
     564 
    550565            // Get entries. 
    551566            $entries = GFAPI::get_entries( $form['id'], $search_critera, null, $paging ); 
    552567 
     568            // If no more entries were found, break. 
     569            if ( empty( $entries ) ) { 
     570                $this->log_debug( __METHOD__ . '(): No entries were found for this page.' ); 
     571                break; 
     572            } 
     573 
    553574            // Loop through entries. 
    554575            foreach ( $entries as $entry ) { 
     
    566587 
    567588        } 
     589 
     590        // Log that deletion has been completed. 
     591        $this->log_debug( __METHOD__ . '(): Deletion completed.' ); 
    568592 
    569593    } 
     
    585609        $search_critera = array( 
    586610            'start_date'     => date( 'Y-m-d H:i:s', 0 ), 
    587             'end_date'       => date( 'Y-m-d H:i:s', strtotime( '-' . $settings[ $type . 'Date' ]['number'] . ' ' . $settings[ $type . 'Date' ]['unit'] ) ), 
     611            'end_date'       => date( 'Y-m-d H:i:s', strtotime( '-' . $settings['deletionDate']['number'] . ' ' . $settings['deletionDate']['unit'] ) ), 
    588612            'payment_status' => null, 
    589613        ); 
  • gravity-forms-entry-expiration/trunk/entryexpiration.php

    r1617287 r1637657  
    44Plugin URI: http://travislop.es/plugins/gravity-forms-entry-expiration/ 
    55Description: Provides a simple way to remove old entries in Gravity Forms. 
    6 Version: 2.0.1 
     6Version: 2.0.2 
    77Author: travislopes 
    88Author URI: http://travislop.es 
     
    1111 **/ 
    1212 
    13 define( 'GF_ENTRYEXPIRATION_VERSION', '2.0.1' ); 
     13define( 'GF_ENTRYEXPIRATION_VERSION', '2.0.2' ); 
    1414 
    1515// If Gravity Forms is loaded, bootstrap the Entry Expiration Add-On. 
  • gravity-forms-entry-expiration/trunk/readme.txt

    r1617287 r1637657  
    3535== Changelog == 
    3636 
     37= v2.0.2 = 
     38* Fixed search criteria not correctly preparing the search end date. 
     39 
    3740= v2.0.1 = 
    3841* Fixed fatal error during 2.0 upgrade process. 
Note: See TracChangeset for help on using the changeset viewer.