Last active
September 22, 2016 09:01
-
-
Save spivurno/22cde09a3eabfc3a76c0b8fa5f6996d4 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Limit Dates // Dynamically Enable Specific Dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Perks // GP Limit Dates // Dynamically Enable Specific Dates | |
*/ | |
// replace "123" with your form ID, and "1" with your Date field ID | |
add_filter( 'gpld_limit_dates_options_123_1', 'gpld_dynamic_exceptions', 10, 3 ); | |
function gpld_dynamic_exceptions( $options, $form, $field ) { | |
$date_values = array( '2016-09-04', '2016-09-16', '2016-09-22', '2016-09-26' ); // replace with your own method for getting a date | |
$max_date = time(); | |
foreach( $date_values as $date_value ) { | |
$date_value = strtotime( $date_value ); | |
if( $date_value > $max_date ) { | |
$options['exceptions'][] = date( 'm/d/Y', $date_value ); | |
} | |
} | |
$options['exceptionMode'] = 'enable'; | |
$options['disableAll'] = true; | |
return $options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment