Created
April 12, 2018 12:40
-
-
Save spivurno/dc451f80cc242c42f86f31516c18672c to your computer and use it in GitHub Desktop.
Gravity Perks // GP Limit Dates // Block Date Range via Exceptions
This file contains hidden or 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 // Block Date Range via Exceptions | |
*/ | |
add_filter( 'gpld_limit_dates_options_1364_1', 'gpld_except_date_range', 10, 3 ); | |
function gpld_except_date_range( $options, $form, $field ) { | |
$start_date = '2016-07-15'; | |
$end_date = '2017-01-01'; | |
// do not modify below this line | |
$start_date = new DateTime( $start_date ); | |
$end_date = new DateTime( $end_date ); | |
$period = new DatePeriod( $start_date, new DateInterval( 'P1D' ), $end_date ); | |
foreach( $period as $date ) { | |
array_push( $options['exceptions'], $date->format( 'm/d/Y' ) ); | |
} | |
$options['exceptionMode'] = 'disable'; | |
return $options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment