Forum Replies Created
- AuthorPosts
kbrands
ParticipantThank you Ally! That code worked a treat!!! π
kbrands
ParticipantHere it isβ¦sorryβ¦Iβm a bit of a newb π
function mytheme_get_dates_to_disable()
{
return array(
'2013-1-26',
'2013-1-28',
'2013-3-29',
'2013-4-1',
'2013-4-25',
'2013-6-10',
'2013-7-10',
'2013-12-25',
'2013-12-26',
'2014-1-1',
'2014-1-27',
'2014-4-1',
'2014-4-18',
'2014-4-21',
'2014-4-25',
'2014-6-9',
'2014-10-6',
'2014-12-25',
'2014-12-26',
'2015-1-1',
'2015-1-26',
'2015-4-3',
'2015-4-6',
'2015-6-8',
'2015-10-5',
'2015-12-25',
'2015-12-28',
'2016-1-1',
'2016-1-26',
'2016-3-25',
'2016-3-28',
'2016-4-25',
'2016-6-13',
'2016-10-3',
'2016-12-26',
'2016-12-27'
);
}function mytheme_prevent_specific_dates($valid, $value, $element)
{
if ($valid) {
$disabledDates = mytheme_get_dates_to_disable();
$submittedDate = "{$value['year']}-{$value['month']}-{$value['day']}";if (in_array($submittedDate, $disabledDates)) {
$element->addError('That date is not available');
$valid = false;
}
}return $valid;
}
add_filter('iphorm_element_valid_iphorm_1_23', 'mytheme_prevent_specific_dates', 10, 3);function mytheme_datepicker_prevent_specific_dates($options, $dpMinYear, $dpMaxYear, $element)
{
return "{
beforeShowDay: function (date) {
if (quformDisabledDates) {
for (var i = 0; i < quformDisabledDates.length; i++) {
var parts = quformDisabledDates[i].split('-');
if (date.getFullYear() == parts[0] && (date.getMonth()+1) == parts[1] && date.getDate() == parts[2]) {
return [false];
}
}
}
return [true];
}
}";
}
add_filter('iphorm_datepicker_options_iphorm_1_23', 'mytheme_datepicker_prevent_specific_dates', 10, 4);
function mytheme_print_dates_to_disable()
{
?>
<script type="text/javascript">
var quformDisabledDates = <?php echo json_encode(mytheme_get_dates_to_disable()); ?>;
</script>
<?php
}
add_action('wp_head', 'mytheme_print_dates_to_disable');function mytheme_datepicker_block_days($options, $dpMinYear, $dpMaxYear, $element)
{
return "{
beforeShowDay: function (date) {
var day = date.getDay();
if (day == 0 || day == 6) {
// It's a Sunday or Saturday, block the date
return [false, ''];
} else {
return [true, ''];
}
}
}";
}
add_filter('iphorm_datepicker_options_iphorm_1_23', 'mytheme_datepicker_block_days', 10, 4);
function mytheme_block_days($valid, $value, $element)
{
if ($valid) {
$time = strtotime("{$value['year']}-{$value['month']}-{$value['day']}");
$day = date('w', $time);if ($day == 0 || $day == 6) {
$element->addError('Please choose another day');
$valid = false;
}
}return $valid;
}
add_filter('iphorm_element_valid_iphorm_1_23', 'mytheme_block_days', 10, 3);
kbrands
ParticipantThank you for your reply. I apologise for the delay in mineβ¦changed hosts and lost access for a few days. I tried adding the code you provided but I fear I have not put it in the right spot as the specific days are blocked out but not the weekends π I have included the full function code I currently have belowβ¦I would appreciate it if you could advise how I should be structuring it as I find myself a bit clueless at this pointβ¦ Thank you!
function mytheme_get_dates_to_disable()
{
return array(
β2013-1-26β,
β2013-1-28β,
β2013-3-29β,
β2013-4-1β,
β2013-4-25β,
β2013-6-10β,
β2013-7-10β,
β2013-12-25β,
β2013-12-26β,
β2014-1-1β,
β2014-1-27β,
β2014-4-1β,
β2014-4-18β,
β2014-4-21β,
β2014-4-25β,
β2014-6-9β,
β2014-10-6β,
β2014-12-25β,
β2014-12-26β,
β2015-1-1β,
β2015-1-26β,
β2015-4-3β,
β2015-4-6β,
β2015-6-8β,
β2015-10-5β,
β2015-12-25β,
β2015-12-28β,
β2016-1-1β,
β2016-1-26β,
β2016-3-25β,
β2016-3-28β,
β2016-4-25β,
β2016-6-13β,
β2016-10-3β,
β2016-12-26β,
β2016-12-27β
);
}function mytheme_prevent_specific_dates($valid, $value, $element)
{
if ($valid) {
$disabledDates = mytheme_get_dates_to_disable();
$submittedDate = β{$value[βyearβ]}-{$value[βmonthβ]}-{$value[βdayβ]}β;if (in_array($submittedDate, $disabledDates)) {
$element->addError(βThat date is not availableβ);
$valid = false;
}
}return $valid;
}
add_filter(βiphorm_element_valid_iphorm_1_23β, βmytheme_prevent_specific_datesβ, 10, 3);function mytheme_datepicker_prevent_specific_dates($options, $dpMinYear, $dpMaxYear, $element)
{
return β{
beforeShowDay: function (date) {
if (quformDisabledDates) {
for (var i = 0; ivar quformDisabledDates = ;
<?php
}
add_action('wp_head', 'mytheme_print_dates_to_disable');
return "{
beforeShowDay: function (date) {
if (quformDisabledDates) {
for (var i = 0; i < quformDisabledDates.length; i++) {
var parts = quformDisabledDates[i].split('-');
if (date.getFullYear() == parts[0] && (date.getMonth()+1) == parts[1] && date.getDate() == parts[2]) {
return [false];
}
}
}var day = date.getDay();
if (day == 0 || day == 6) {
// It's a Sunday or Saturday, block the date
return [false, ''];
} else {
return [true, ''];
}
}
}";kbrands
ParticipantSo easy! I promise I did try and find the answer myself but clearly I missed the advised post. Thank you again Ally!
kbrands
ParticipantAll fixed thank you Ally! It was an issue on the hosting/server end. I really appreciate the assistance you provided! π
kbrands
ParticipantOh, Iβm sorry, one more thingβ¦could the update to wordpress 3.5 have caused this?
kbrands
ParticipantThanks again for your response. I tried viewing in explorer (I usually use firefox) and the same errors are coming up. I will contact my hosting company now and see what they have to say. Thanks Ally. π
kbrands
ParticipantThank you for your prompt response. I applied your instructions and the plugin installed successfully and showed up in my WP plugins page, I activated it and the forms were still there as advised. However, the same error messages came up. I have taken a screen shot of the error messages and attached for you. Thanks in advance for your continued assistance π
Attachments:
You must be logged in to view attached files.- AuthorPosts