I’m using a wordpress datepicker plugin that leverages the jQuery UI datepicker into WordPress and connects it with Contact Form 7. Everything is good on it, except that I want to exclude Thursdays and Fridays from being able to be selected. I have found code that does this with the normal implementation of the datepicker, but can’t figure out how to alter this plugin to suit that code.
The existing code to take out weekends works like this…
if ($this->noWeekends)
$out .= ".{$this->type}('option', 'beforeShowDay', $.datepicker.noWeekends)";
I am trying to duplicate that implementation, but assign it to Thursdays and Fridays. I have the code connecting to the plugin and outputting correctly, but the actual script I’ve put in throws syntax errors.
if ($this->noThuFri)
$out .= ".{$this->type}('option', 'beforeShowDay', $.datepicker({ beforeShowDay: function(date) { var day = date.getDay(); return [(day != 1 && day != 2)]; } })âââââ;â)";
I’m assuming my syntax is just jacked, but I am at a loss on how to fix it. Any ideas?
The actual code it outputs into the head is below, for reference:
<script type="text/javascript">
jQuery(function($){
$('input[name="date"]').datepicker({"dateFormat":"mm/dd/yy","controlType":"slider","noWeekends":true,"noThuFri":true}).datepicker('option', 'beforeShowDay', $.datepicker.noWeekends).datepicker('option', 'beforeShowDay', function(date) {var day = date.getDay(); return [(day != 1 && day != 2)];).datepicker('option', 'minDate', "").datepicker('option', 'maxDate', "").datepicker('refresh');
});
</script>
The week starts at Monday as day 1. For Thursday and Friday update the return to day !=4 && day !=5.
In the code you posted I don’t see any obvious syntax problems. Updating the values in the return should give you the results you expect