diff --git a/gravity-forms/gw-populate-date.php b/gravity-forms/gw-populate-date.php index 862585a74..066beaf6b 100644 --- a/gravity-forms/gw-populate-date.php +++ b/gravity-forms/gw-populate-date.php @@ -4,17 +4,16 @@ * * Provides the ability to populate a Date field with a modified date based on the current date or a user-submitted date. * - * @version 2.8 + * @version 2.6 * @author David Smith * @license GPL-2.0+ * @link http://gravitywiz.com/populate-dates-gravity-form-fields/ */ class GW_Populate_Date { - protected static $is_script_output = false; + protected $_args; - private $_args = array(); - private $_field_values = array(); + protected static $is_script_output = false; public function __construct( $args = array() ) { @@ -28,7 +27,6 @@ public function __construct( $args = array() ) { 'min_date' => false, 'enable_i18n' => false, 'override_on_submission' => false, - 'utc_offset' => get_option( 'gmt_offset' ), // Used only for time calculations on the current date. ) ); $this->_field_values = array(); @@ -49,8 +47,7 @@ public function init() { return; } - // Always load the script if a modifier is provided, even if no source_field_id is set - if ( $this->_args['modifier'] || $this->_args['source_field_id'] ) { + if ( $this->_args['source_field_id'] ) { add_filter( 'gform_pre_render', array( $this, 'load_form_script' ) ); add_filter( 'gform_register_init_scripts', array( $this, 'add_init_script' ) ); add_filter( 'gform_enqueue_scripts', array( $this, 'enqueue_form_scripts' ) ); @@ -245,9 +242,7 @@ public function get_modified_date( $field, $timestamp = false ) { $hour = 12; } } - // Ensure the time value is retained as a String. - // If saved in array format, it will not reload the value after conditional viewing/hiding. - $date = "{$hour}:{$minute} {$ampm}"; + $date = array( $hour, $minute, $ampm ); } elseif ( $this->_args['enable_i18n'] ) { $date = strftime( $format, $timestamp ); } else { @@ -287,6 +282,16 @@ public static function output_script() {