Skip to content

Instantly share code, notes, and snippets.

@spivurno
Created April 12, 2018 12:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/dc451f80cc242c42f86f31516c18672c to your computer and use it in GitHub Desktop.
Save spivurno/dc451f80cc242c42f86f31516c18672c to your computer and use it in GitHub Desktop.
Gravity Perks // GP Limit Dates // Block Date Range via Exceptions
<?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