Skip to content

Instantly share code, notes, and snippets.

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 plugin-republic/f3475bfab78a7d1069b691fdf0fb59de to your computer and use it in GitHub Desktop.
Save plugin-republic/f3475bfab78a7d1069b691fdf0fb59de to your computer and use it in GitHub Desktop.
<?php
/**
* Disable weekends and holidays
*/
function prefix_date_field_params_disable_weekends_holidays( $params, $item ) {
$params[] = 'beforeShowDay : function( date ) {
// Disable holidays
var holidays = ["2020-04-13","2020-04-14"];
var datestring = jQuery.datepicker.formatDate( "yy-mm-dd", date );
if( holidays.indexOf( datestring ) != -1 ) {
return [ false, false ];
}
// Disable weekends
var day = date.getDay();
if( day == 0 || day == 6 ) {
return [ false, false ];
}
return [ true ];
}';
return $params;
}
add_filter( 'pewc_filter_date_field_params', 'prefix_date_field_params_disable_weekends_holidays', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment