Last active
May 12, 2022 06:58
-
-
Save plugin-republic/f3475bfab78a7d1069b691fdf0fb59de to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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